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"
46 * rbd_children object in each pool contains omap entries
47 * that map parent (poolid, imageid, snapid) to a list of children
48 * (imageids; snapids aren't required because we get all the snapshot
49 * info from a read of the child's header object anyway).
51 * The clone operation writes a new item to this child list, and rm or
52 * flatten removes an item, and may remove the whole entry if no children
53 * exist after the rm/flatten.
55 * When attempting to remove a parent, all pools are searched for
56 * rbd_children objects with entries referring to that parent; if any
57 * exist (and those children exist), the parent removal is prevented.
59 #define RBD_CHILDREN "rbd_children"
60 #define RBD_LOCK_NAME "rbd_lock"
63 * rbd_mirroring object in each pool contains pool-specific settings
64 * for configuring mirroring.
66 #define RBD_MIRRORING "rbd_mirroring"
69 * rbd_mirror_leader and rbd_mirror_instance.<instance id> objects are used
70 * for pool-level coordination between rbd-mirror daemons.
72 #define RBD_MIRROR_LEADER "rbd_mirror_leader"
73 #define RBD_MIRROR_INSTANCE_PREFIX "rbd_mirror_instance."
75 #define RBD_MAX_OBJ_NAME_SIZE 96
76 #define RBD_MAX_BLOCK_NAME_SIZE 24
79 * Maximum string length of the RBD v2 image id (not including
80 * null termination). This limit was derived from the existing
81 * RBD_MAX_BLOCK_NAME_SIZE limit which needs to hold the "rbd_data."
82 * prefix and null termination.
84 #define RBD_MAX_IMAGE_ID_LENGTH 14
87 * Maximum string length of the RBD block object name prefix (not including
90 * v1 format: rb.<max 8-byte high id>.<max 8-byte low id>.<max 8-byte extra>
91 * v2 format: rbd_data.[<max 19-byte pool id>.]<max 14-byte image id>
93 * Note: new features might require increasing this maximum prefix length.
95 #define RBD_MAX_BLOCK_NAME_PREFIX_LENGTH 43
97 #define RBD_COMP_NONE 0
98 #define RBD_CRYPT_NONE 0
100 #define RBD_HEADER_TEXT "<<< Rados Block Device Image >>>\n"
101 #define RBD_HEADER_SIGNATURE "RBD"
102 #define RBD_HEADER_VERSION "001.005"
104 #define RBD_GROUP_HEADER_PREFIX "rbd_group_header."
106 #define RBD_GROUP_DIRECTORY "rbd_group_directory"
108 #define RBD_TRASH "rbd_trash"
112 } __attribute__ ((packed));
114 struct rbd_obj_snap_ondisk {
117 } __attribute__((packed));
119 struct rbd_obj_header_ondisk {
121 char block_name[RBD_MAX_BLOCK_NAME_SIZE];
129 } __attribute__((packed)) options;
134 __le64 snap_names_len;
135 struct rbd_obj_snap_ondisk snaps[0];
136 } __attribute__((packed));
139 RBD_PROTECTION_STATUS_UNPROTECTED = 0,
140 RBD_PROTECTION_STATUS_UNPROTECTING = 1,
141 RBD_PROTECTION_STATUS_PROTECTED = 2,
142 RBD_PROTECTION_STATUS_LAST = 3