2 * Ceph - scalable distributed file system
4 * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
6 * This is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License version 2.1, as published by the Free Software
9 * Foundation. See file COPYING.
13 #ifndef CEPH_RBD_TYPES_H
14 #define CEPH_RBD_TYPES_H
16 #include "include/types.h"
17 #include "rbd/features.h"
19 /* New-style rbd image 'foo' consists of objects
20 * rbd_id.foo - id of image
21 * rbd_header.<id> - image metadata
22 * rbd_object_map.<id> - optional image object map
23 * rbd_data.<id>.00000000
24 * rbd_data.<id>.00000001
28 #define RBD_HEADER_PREFIX "rbd_header."
29 #define RBD_OBJECT_MAP_PREFIX "rbd_object_map."
30 #define RBD_DATA_PREFIX "rbd_data."
31 #define RBD_ID_PREFIX "rbd_id."
34 * old-style rbd image 'foo' consists of objects
35 * foo.rbd - image metadata
36 * rb.<idhi>.<idlo>.00000000
37 * rb.<idhi>.<idlo>.00000001
41 #define RBD_SUFFIX ".rbd"
42 #define RBD_DIRECTORY "rbd_directory"
43 #define RBD_INFO "rbd_info"
44 #define RBD_NAMESPACE "rbd_namespace"
45 #define RBD_TASK "rbd_task"
48 * rbd_children object in each pool contains omap entries
49 * that map parent (poolid, imageid, snapid) to a list of children
50 * (imageids; snapids aren't required because we get all the snapshot
51 * info from a read of the child's header object anyway).
53 * The clone operation writes a new item to this child list, and rm or
54 * flatten removes an item, and may remove the whole entry if no children
55 * exist after the rm/flatten.
57 * When attempting to remove a parent, all pools are searched for
58 * rbd_children objects with entries referring to that parent; if any
59 * exist (and those children exist), the parent removal is prevented.
61 #define RBD_CHILDREN "rbd_children"
62 #define RBD_LOCK_NAME "rbd_lock"
65 * rbd_mirroring object in each pool contains pool-specific settings
66 * for configuring mirroring.
68 #define RBD_MIRRORING "rbd_mirroring"
71 * rbd_mirror_leader and rbd_mirror_instance.<instance id> objects are used
72 * for pool-level coordination between rbd-mirror daemons.
74 #define RBD_MIRROR_LEADER "rbd_mirror_leader"
75 #define RBD_MIRROR_INSTANCE_PREFIX "rbd_mirror_instance."
77 #define RBD_MAX_OBJ_NAME_SIZE 96
78 #define RBD_MAX_BLOCK_NAME_SIZE 24
81 * Maximum string length of the RBD v2 image id (not including
82 * null termination). This limit was derived from the existing
83 * RBD_MAX_BLOCK_NAME_SIZE limit which needs to hold the "rbd_data."
84 * prefix and null termination.
86 #define RBD_MAX_IMAGE_ID_LENGTH 14
89 * Maximum string length of the RBD block object name prefix (not including
92 * v1 format: rb.<max 8-byte high id>.<max 8-byte low id>.<max 8-byte extra>
93 * v2 format: rbd_data.[<max 19-byte pool id>.]<max 14-byte image id>
95 * Note: new features might require increasing this maximum prefix length.
97 #define RBD_MAX_BLOCK_NAME_PREFIX_LENGTH 43
99 #define RBD_COMP_NONE 0
100 #define RBD_CRYPT_NONE 0
102 #define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
103 #define RBD_MIGRATE_HEADER_TEXT "<<< Migrating RBD Image >>>\n"
104 #define RBD_HEADER_SIGNATURE "RBD"
105 #define RBD_HEADER_VERSION "001.005"
107 #define RBD_GROUP_INVALID_POOL (-1)
109 #define RBD_GROUP_HEADER_PREFIX "rbd_group_header."
111 #define RBD_GROUP_DIRECTORY "rbd_group_directory"
113 #define RBD_TRASH "rbd_trash"
116 * MON config-key prefix for storing optional remote cluster connectivity
119 #define RBD_MIRROR_PEER_CONFIG_KEY_PREFIX "rbd/mirror/peer/"
123 } __attribute__ ((packed
));
125 struct rbd_obj_snap_ondisk
{
128 } __attribute__((packed
));
130 struct rbd_obj_header_ondisk
{
132 char block_name
[RBD_MAX_BLOCK_NAME_SIZE
];
140 } __attribute__((packed
)) options
;
145 __le64 snap_names_len
;
146 struct rbd_obj_snap_ondisk snaps
[0];
147 } __attribute__((packed
));
150 RBD_PROTECTION_STATUS_UNPROTECTED
= 0,
151 RBD_PROTECTION_STATUS_UNPROTECTING
= 1,
152 RBD_PROTECTION_STATUS_PROTECTED
= 2,
153 RBD_PROTECTION_STATUS_LAST
= 3