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   	
(1) Event include_recursion: #include file "/ceph/src/include/types.h" includes itself: types.h -> rbd_types.h -> types.h
(2) Event caretline: ^
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_CONFIG_KEY_PREFIX          "rbd/mirror/"
120  	#define RBD_MIRROR_SITE_NAME_CONFIG_KEY       RBD_MIRROR_CONFIG_KEY_PREFIX "site_name"
121  	#define RBD_MIRROR_PEER_CLIENT_ID_CONFIG_KEY  RBD_MIRROR_CONFIG_KEY_PREFIX "peer_client_id"
122  	#define RBD_MIRROR_PEER_CONFIG_KEY_PREFIX     RBD_MIRROR_CONFIG_KEY_PREFIX "peer/"
123  	
124  	struct rbd_info {
125  		ceph_le64 max_id;
126  	} __attribute__ ((packed));
127  	
128  	struct rbd_obj_snap_ondisk {
129  		ceph_le64 id;
130  		ceph_le64 image_size;
131  	} __attribute__((packed));
132  	
133  	struct rbd_obj_header_ondisk {
134  		char text[40];
135  		char block_name[RBD_MAX_BLOCK_NAME_SIZE];
136  		char signature[4];
137  		char version[8];
138  		struct {
139  			__u8 order;
140  			__u8 crypt_type;
141  			__u8 comp_type;
142  			__u8 unused;
143  		} __attribute__((packed)) options;
144  		ceph_le64 image_size;
145  		ceph_le64 snap_seq;
146  		ceph_le32 snap_count;
147  		ceph_le32 reserved;
148  		ceph_le64 snap_names_len;
149  		struct rbd_obj_snap_ondisk snaps[0];
150  	} __attribute__((packed));
151  	
152  	enum {
153  	  RBD_PROTECTION_STATUS_UNPROTECTED  = 0,
154  	  RBD_PROTECTION_STATUS_UNPROTECTING = 1,
155  	  RBD_PROTECTION_STATUS_PROTECTED    = 2,
156  	  RBD_PROTECTION_STATUS_LAST         = 3
157  	};
158  	
159  	#endif
160