Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / 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
45 /*
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).
50  *
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.
54  *
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.
58  */
59 #define RBD_CHILDREN            "rbd_children"
60 #define RBD_LOCK_NAME           "rbd_lock"
61
62 /**
63  * rbd_mirroring object in each pool contains pool-specific settings
64  * for configuring mirroring.
65  */
66 #define RBD_MIRRORING       "rbd_mirroring"
67
68 /**
69  * rbd_mirror_leader and rbd_mirror_instance.<instance id> objects are used
70  * for pool-level coordination between rbd-mirror daemons.
71  */
72 #define RBD_MIRROR_LEADER               "rbd_mirror_leader"
73 #define RBD_MIRROR_INSTANCE_PREFIX      "rbd_mirror_instance."
74
75 #define RBD_MAX_OBJ_NAME_SIZE   96
76 #define RBD_MAX_BLOCK_NAME_SIZE 24
77
78 /**
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.
83  */
84 #define RBD_MAX_IMAGE_ID_LENGTH 14
85
86 /**
87  * Maximum string length of the RBD block object name prefix (not including
88  * null termination).
89  *
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>
92  *
93  * Note: new features might require increasing this maximum prefix length.
94  */
95 #define RBD_MAX_BLOCK_NAME_PREFIX_LENGTH 43
96
97 #define RBD_COMP_NONE           0
98 #define RBD_CRYPT_NONE          0
99
100 #define RBD_HEADER_TEXT         "<<< Rados Block Device Image >>>\n"
101 #define RBD_HEADER_SIGNATURE    "RBD"
102 #define RBD_HEADER_VERSION      "001.005"
103
104 #define RBD_GROUP_HEADER_PREFIX "rbd_group_header."
105
106 #define RBD_GROUP_DIRECTORY "rbd_group_directory"
107
108 #define RBD_TRASH "rbd_trash"
109
110 struct rbd_info {
111         __le64 max_id;
112 } __attribute__ ((packed));
113
114 struct rbd_obj_snap_ondisk {
115         __le64 id;
116         __le64 image_size;
117 } __attribute__((packed));
118
119 struct rbd_obj_header_ondisk {
120         char text[40];
121         char block_name[RBD_MAX_BLOCK_NAME_SIZE];
122         char signature[4];
123         char version[8];
124         struct {
125                 __u8 order;
126                 __u8 crypt_type;
127                 __u8 comp_type;
128                 __u8 unused;
129         } __attribute__((packed)) options;
130         __le64 image_size;
131         __le64 snap_seq;
132         __le32 snap_count;
133         __le32 reserved;
134         __le64 snap_names_len;
135         struct rbd_obj_snap_ondisk snaps[0];
136 } __attribute__((packed));
137
138 enum {
139   RBD_PROTECTION_STATUS_UNPROTECTED  = 0,
140   RBD_PROTECTION_STATUS_UNPROTECTING = 1,
141   RBD_PROTECTION_STATUS_PROTECTED    = 2,
142   RBD_PROTECTION_STATUS_LAST         = 3
143 };
144
145 #endif