]> git.proxmox.com Git - ceph.git/blob - ceph/src/include/rbd_types.h
94799ab6f1de60016409529ec5ef7ecbe1651c5d
[ceph.git] / ceph / src / include / rbd_types.h
1 /*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2004-2010 Sage Weil <sage@newdream.net>
5 *
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.
10 *
11 */
12
13 #ifndef CEPH_RBD_TYPES_H
14 #define CEPH_RBD_TYPES_H
15
16 #include "include/types.h"
17 #include "rbd/features.h"
18
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
25 * ... - data
26 */
27
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."
32
33 /*
34 * old-style rbd image 'foo' consists of objects
35 * foo.rbd - image metadata
36 * rb.<idhi>.<idlo>.00000000
37 * rb.<idhi>.<idlo>.00000001
38 * ... - data
39 */
40
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"
46
47 /*
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).
52 *
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.
56 *
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.
60 */
61 #define RBD_CHILDREN "rbd_children"
62 #define RBD_LOCK_NAME "rbd_lock"
63
64 /**
65 * rbd_mirroring object in each pool contains pool-specific settings
66 * for configuring mirroring.
67 */
68 #define RBD_MIRRORING "rbd_mirroring"
69
70 /**
71 * rbd_mirror_leader and rbd_mirror_instance.<instance id> objects are used
72 * for pool-level coordination between rbd-mirror daemons.
73 */
74 #define RBD_MIRROR_LEADER "rbd_mirror_leader"
75 #define RBD_MIRROR_INSTANCE_PREFIX "rbd_mirror_instance."
76
77 #define RBD_MAX_OBJ_NAME_SIZE 96
78 #define RBD_MAX_BLOCK_NAME_SIZE 24
79
80 /**
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.
85 */
86 #define RBD_MAX_IMAGE_ID_LENGTH 14
87
88 /**
89 * Maximum string length of the RBD block object name prefix (not including
90 * null termination).
91 *
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>
94 *
95 * Note: new features might require increasing this maximum prefix length.
96 */
97 #define RBD_MAX_BLOCK_NAME_PREFIX_LENGTH 43
98
99 #define RBD_COMP_NONE 0
100 #define RBD_CRYPT_NONE 0
101
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"
106
107 #define RBD_GROUP_INVALID_POOL (-1)
108
109 #define RBD_GROUP_HEADER_PREFIX "rbd_group_header."
110
111 #define RBD_GROUP_DIRECTORY "rbd_group_directory"
112
113 #define RBD_TRASH "rbd_trash"
114
115 /**
116 * MON config-key prefix for storing optional remote cluster connectivity
117 * parameters
118 */
119 #define RBD_MIRROR_PEER_CONFIG_KEY_PREFIX "rbd/mirror/peer/"
120
121 struct rbd_info {
122 __le64 max_id;
123 } __attribute__ ((packed));
124
125 struct rbd_obj_snap_ondisk {
126 __le64 id;
127 __le64 image_size;
128 } __attribute__((packed));
129
130 struct rbd_obj_header_ondisk {
131 char text[40];
132 char block_name[RBD_MAX_BLOCK_NAME_SIZE];
133 char signature[4];
134 char version[8];
135 struct {
136 __u8 order;
137 __u8 crypt_type;
138 __u8 comp_type;
139 __u8 unused;
140 } __attribute__((packed)) options;
141 __le64 image_size;
142 __le64 snap_seq;
143 __le32 snap_count;
144 __le32 reserved;
145 __le64 snap_names_len;
146 struct rbd_obj_snap_ondisk snaps[0];
147 } __attribute__((packed));
148
149 enum {
150 RBD_PROTECTION_STATUS_UNPROTECTED = 0,
151 RBD_PROTECTION_STATUS_UNPROTECTING = 1,
152 RBD_PROTECTION_STATUS_PROTECTED = 2,
153 RBD_PROTECTION_STATUS_LAST = 3
154 };
155
156 #endif