Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ceph_fs.h - Ceph constants and data types to share between kernel and |
| 3 | * user space. |
| 4 | * |
| 5 | * Most types in this file are defined as little-endian, and are |
| 6 | * primarily intended to describe data structures that pass over the |
| 7 | * wire or that are stored on disk. |
| 8 | * |
| 9 | * LGPL2 |
| 10 | */ |
| 11 | |
Sage Weil | 5cd068c | 2010-07-07 08:38:17 -0700 | [diff] [blame] | 12 | #ifndef CEPH_FS_H |
| 13 | #define CEPH_FS_H |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 14 | |
David Howells | a1ce392 | 2012-10-02 18:01:25 +0100 | [diff] [blame] | 15 | #include <linux/ceph/msgr.h> |
| 16 | #include <linux/ceph/rados.h> |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 19 | * subprotocol versions. when specific messages types or high-level |
| 20 | * protocols change, bump the affected components. we keep rev |
| 21 | * internal cluster protocols separately from the public, |
| 22 | * client-facing protocol. |
| 23 | */ |
Yehuda Sadeh | 0c94899 | 2010-02-01 16:10:45 -0800 | [diff] [blame] | 24 | #define CEPH_OSDC_PROTOCOL 24 /* server/client */ |
Sage Weil | 3ea25f9 | 2010-01-25 11:18:17 -0800 | [diff] [blame] | 25 | #define CEPH_MDSC_PROTOCOL 32 /* server/client */ |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 26 | #define CEPH_MONC_PROTOCOL 15 /* server/client */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 27 | |
| 28 | |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 29 | #define CEPH_INO_ROOT 1 |
| 30 | #define CEPH_INO_CEPH 2 /* hidden .ceph dir */ |
| 31 | #define CEPH_INO_DOTDOT 3 /* used by ceph fuse for parent (..) */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 32 | |
| 33 | /* arbitrary limit on max # of monitors (cluster of 3 is typical) */ |
| 34 | #define CEPH_MAX_MON 31 |
| 35 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 36 | /* |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 37 | * legacy ceph_file_layoute |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 38 | */ |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 39 | struct ceph_file_layout_legacy { |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 40 | /* file -> object mapping */ |
| 41 | __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple |
| 42 | of page size. */ |
| 43 | __le32 fl_stripe_count; /* over this many objects */ |
| 44 | __le32 fl_object_size; /* until objects are this big, then move to |
| 45 | new objects */ |
Sage Weil | 6c0f3af | 2010-11-16 11:14:34 -0800 | [diff] [blame] | 46 | __le32 fl_cas_hash; /* UNUSED. 0 = none; 1 = sha256 */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 47 | |
| 48 | /* pg -> disk layout */ |
Sage Weil | 6c0f3af | 2010-11-16 11:14:34 -0800 | [diff] [blame] | 49 | __le32 fl_object_stripe_unit; /* UNUSED. for per-object parity, if any */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 50 | |
| 51 | /* object -> pg layout */ |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 52 | __le32 fl_unused; /* unused; used to be preferred primary for pg (-1 for none) */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 53 | __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */ |
| 54 | } __attribute__ ((packed)); |
| 55 | |
Yan, Zheng | 30c156d | 2016-02-14 11:24:31 +0800 | [diff] [blame] | 56 | struct ceph_string; |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 57 | /* |
| 58 | * ceph_file_layout - describe data layout for a file/inode |
| 59 | */ |
| 60 | struct ceph_file_layout { |
| 61 | /* file -> object mapping */ |
| 62 | u32 stripe_unit; /* stripe unit, in bytes */ |
| 63 | u32 stripe_count; /* over this many objects */ |
| 64 | u32 object_size; /* until objects are this big */ |
| 65 | s64 pool_id; /* rados pool id */ |
Yan, Zheng | 30c156d | 2016-02-14 11:24:31 +0800 | [diff] [blame] | 66 | struct ceph_string __rcu *pool_ns; /* rados pool namespace */ |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 67 | }; |
Ilya Dryomov | e822146 | 2014-01-27 17:40:18 +0200 | [diff] [blame] | 68 | |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 69 | extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout); |
| 70 | extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl, |
| 71 | struct ceph_file_layout_legacy *legacy); |
| 72 | extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl, |
| 73 | struct ceph_file_layout_legacy *legacy); |
Ilya Dryomov | e822146 | 2014-01-27 17:40:18 +0200 | [diff] [blame] | 74 | |
Sage Weil | 752727a | 2009-10-09 16:38:45 -0700 | [diff] [blame] | 75 | #define CEPH_MIN_STRIPE_UNIT 65536 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 76 | |
Sage Weil | 6c0f3af | 2010-11-16 11:14:34 -0800 | [diff] [blame] | 77 | struct ceph_dir_layout { |
| 78 | __u8 dl_dir_hash; /* see ceph_hash.h for ids */ |
| 79 | __u8 dl_unused1; |
| 80 | __u16 dl_unused2; |
| 81 | __u32 dl_unused3; |
| 82 | } __attribute__ ((packed)); |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 83 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 84 | /* crypto algorithms */ |
| 85 | #define CEPH_CRYPTO_NONE 0x0 |
| 86 | #define CEPH_CRYPTO_AES 0x1 |
| 87 | |
Sage Weil | cbbfe49 | 2010-08-02 15:48:23 -0700 | [diff] [blame] | 88 | #define CEPH_AES_IV "cephsageyudagreg" |
| 89 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 90 | /* security/authentication protocols */ |
| 91 | #define CEPH_AUTH_UNKNOWN 0x0 |
| 92 | #define CEPH_AUTH_NONE 0x1 |
| 93 | #define CEPH_AUTH_CEPHX 0x2 |
| 94 | |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 95 | #define CEPH_AUTH_UID_DEFAULT ((__u64) -1) |
| 96 | |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 97 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 98 | /********************************************* |
| 99 | * message layer |
| 100 | */ |
| 101 | |
| 102 | /* |
| 103 | * message types |
| 104 | */ |
| 105 | |
| 106 | /* misc */ |
| 107 | #define CEPH_MSG_SHUTDOWN 1 |
| 108 | #define CEPH_MSG_PING 2 |
| 109 | |
| 110 | /* client <-> monitor */ |
| 111 | #define CEPH_MSG_MON_MAP 4 |
| 112 | #define CEPH_MSG_MON_GET_MAP 5 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 113 | #define CEPH_MSG_STATFS 13 |
| 114 | #define CEPH_MSG_STATFS_REPLY 14 |
| 115 | #define CEPH_MSG_MON_SUBSCRIBE 15 |
| 116 | #define CEPH_MSG_MON_SUBSCRIBE_ACK 16 |
Sage Weil | 4e7a5dc | 2009-11-18 16:19:57 -0800 | [diff] [blame] | 117 | #define CEPH_MSG_AUTH 17 |
| 118 | #define CEPH_MSG_AUTH_REPLY 18 |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 119 | #define CEPH_MSG_MON_GET_VERSION 19 |
| 120 | #define CEPH_MSG_MON_GET_VERSION_REPLY 20 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 121 | |
| 122 | /* client <-> mds */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 123 | #define CEPH_MSG_MDS_MAP 21 |
Yan, Zheng | 0cabbd9 | 2016-04-07 11:34:43 +0800 | [diff] [blame] | 124 | #define CEPH_MSG_FS_MAP_USER 103 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 125 | |
| 126 | #define CEPH_MSG_CLIENT_SESSION 22 |
| 127 | #define CEPH_MSG_CLIENT_RECONNECT 23 |
| 128 | |
| 129 | #define CEPH_MSG_CLIENT_REQUEST 24 |
| 130 | #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25 |
| 131 | #define CEPH_MSG_CLIENT_REPLY 26 |
| 132 | #define CEPH_MSG_CLIENT_CAPS 0x310 |
| 133 | #define CEPH_MSG_CLIENT_LEASE 0x311 |
| 134 | #define CEPH_MSG_CLIENT_SNAP 0x312 |
| 135 | #define CEPH_MSG_CLIENT_CAPRELEASE 0x313 |
| 136 | |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 137 | /* pool ops */ |
| 138 | #define CEPH_MSG_POOLOP_REPLY 48 |
| 139 | #define CEPH_MSG_POOLOP 49 |
| 140 | |
Douglas Fuller | 6305a3b | 2015-07-22 20:59:52 -0400 | [diff] [blame] | 141 | /* mon commands */ |
| 142 | #define CEPH_MSG_MON_COMMAND 50 |
| 143 | #define CEPH_MSG_MON_COMMAND_ACK 51 |
Sage Weil | ca9d93a | 2010-05-12 14:48:20 -0700 | [diff] [blame] | 144 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 145 | /* osd */ |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 146 | #define CEPH_MSG_OSD_MAP 41 |
| 147 | #define CEPH_MSG_OSD_OP 42 |
| 148 | #define CEPH_MSG_OSD_OPREPLY 43 |
| 149 | #define CEPH_MSG_WATCH_NOTIFY 44 |
| 150 | |
| 151 | |
| 152 | /* watch-notify operations */ |
| 153 | enum { |
Ilya Dryomov | 922dab6 | 2016-05-26 01:15:02 +0200 | [diff] [blame] | 154 | CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */ |
| 155 | CEPH_WATCH_EVENT_NOTIFY_COMPLETE = 2, /* notifier notified when done */ |
| 156 | CEPH_WATCH_EVENT_DISCONNECT = 3, /* we were disconnected */ |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 157 | }; |
| 158 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 159 | |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 160 | struct ceph_mon_request_header { |
| 161 | __le64 have_version; |
| 162 | __le16 session_mon; |
| 163 | __le64 session_mon_tid; |
| 164 | } __attribute__ ((packed)); |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 165 | |
| 166 | struct ceph_mon_statfs { |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 167 | struct ceph_mon_request_header monhdr; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 168 | struct ceph_fsid fsid; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 169 | } __attribute__ ((packed)); |
| 170 | |
| 171 | struct ceph_statfs { |
| 172 | __le64 kb, kb_used, kb_avail; |
| 173 | __le64 num_objects; |
| 174 | } __attribute__ ((packed)); |
| 175 | |
| 176 | struct ceph_mon_statfs_reply { |
| 177 | struct ceph_fsid fsid; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 178 | __le64 version; |
| 179 | struct ceph_statfs st; |
| 180 | } __attribute__ ((packed)); |
| 181 | |
Douglas Fuller | 6305a3b | 2015-07-22 20:59:52 -0400 | [diff] [blame] | 182 | struct ceph_mon_command { |
| 183 | struct ceph_mon_request_header monhdr; |
| 184 | struct ceph_fsid fsid; |
| 185 | __le32 num_strs; /* always 1 */ |
| 186 | __le32 str_len; |
| 187 | char str[]; |
| 188 | } __attribute__ ((packed)); |
| 189 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 190 | struct ceph_osd_getmap { |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 191 | struct ceph_mon_request_header monhdr; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 192 | struct ceph_fsid fsid; |
| 193 | __le32 start; |
| 194 | } __attribute__ ((packed)); |
| 195 | |
| 196 | struct ceph_mds_getmap { |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 197 | struct ceph_mon_request_header monhdr; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 198 | struct ceph_fsid fsid; |
| 199 | } __attribute__ ((packed)); |
| 200 | |
| 201 | struct ceph_client_mount { |
Sage Weil | 13e38c8 | 2009-10-09 16:36:34 -0700 | [diff] [blame] | 202 | struct ceph_mon_request_header monhdr; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 203 | } __attribute__ ((packed)); |
| 204 | |
Yehuda Sadeh | 483fac7 | 2011-01-20 16:36:06 -0800 | [diff] [blame] | 205 | #define CEPH_SUBSCRIBE_ONETIME 1 /* i want only 1 update after have */ |
| 206 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 207 | struct ceph_mon_subscribe_item { |
Ilya Dryomov | 82dcaba | 2016-01-19 16:19:06 +0100 | [diff] [blame] | 208 | __le64 start; |
| 209 | __u8 flags; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 210 | } __attribute__ ((packed)); |
| 211 | |
Sage Weil | 07bd10f | 2009-10-14 17:26:40 -0700 | [diff] [blame] | 212 | struct ceph_mon_subscribe_ack { |
| 213 | __le32 duration; /* seconds */ |
| 214 | struct ceph_fsid fsid; |
| 215 | } __attribute__ ((packed)); |
| 216 | |
Ilya Dryomov | 737cc81e | 2016-05-26 00:05:01 +0200 | [diff] [blame] | 217 | #define CEPH_FS_CLUSTER_ID_NONE -1 |
| 218 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 219 | /* |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 220 | * mdsmap flags |
| 221 | */ |
| 222 | #define CEPH_MDSMAP_DOWN (1<<0) /* cluster deliberately down */ |
| 223 | |
| 224 | /* |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 225 | * mds states |
| 226 | * > 0 -> in |
| 227 | * <= 0 -> out |
| 228 | */ |
| 229 | #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */ |
| 230 | #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees. |
| 231 | empty log. */ |
| 232 | #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */ |
| 233 | #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */ |
| 234 | #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */ |
| 235 | #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */ |
| 236 | #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */ |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 237 | #define CEPH_MDS_STATE_REPLAYONCE -9 /* up, replaying an active node's journal */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 238 | |
| 239 | #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */ |
| 240 | #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed |
| 241 | operations (import, rename, etc.) */ |
| 242 | #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */ |
| 243 | #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */ |
| 244 | #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */ |
| 245 | #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */ |
| 246 | #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */ |
| 247 | |
| 248 | extern const char *ceph_mds_state_name(int s); |
| 249 | |
| 250 | |
| 251 | /* |
| 252 | * metadata lock types. |
| 253 | * - these are bitmasks.. we can compose them |
| 254 | * - they also define the lock ordering by the MDS |
| 255 | * - a few of these are internal to the mds |
| 256 | */ |
Sage Weil | dd1c905 | 2010-05-25 16:45:25 -0700 | [diff] [blame] | 257 | #define CEPH_LOCK_DVERSION 1 |
| 258 | #define CEPH_LOCK_DN 2 |
| 259 | #define CEPH_LOCK_ISNAP 16 |
| 260 | #define CEPH_LOCK_IVERSION 32 /* mds internal */ |
| 261 | #define CEPH_LOCK_IFILE 64 |
| 262 | #define CEPH_LOCK_IAUTH 128 |
| 263 | #define CEPH_LOCK_ILINK 256 |
| 264 | #define CEPH_LOCK_IDFT 512 /* dir frag tree */ |
| 265 | #define CEPH_LOCK_INEST 1024 /* mds internal */ |
| 266 | #define CEPH_LOCK_IXATTR 2048 |
Sage Weil | f0b18d9 | 2010-07-07 08:39:03 -0700 | [diff] [blame] | 267 | #define CEPH_LOCK_IFLOCK 4096 /* advisory file locks */ |
Sage Weil | dd1c905 | 2010-05-25 16:45:25 -0700 | [diff] [blame] | 268 | #define CEPH_LOCK_INO 8192 /* immutable inode bits; not a lock */ |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 269 | #define CEPH_LOCK_IPOLICY 16384 /* policy lock on dirs. MDS internal */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 270 | |
| 271 | /* client_session ops */ |
| 272 | enum { |
| 273 | CEPH_SESSION_REQUEST_OPEN, |
| 274 | CEPH_SESSION_OPEN, |
| 275 | CEPH_SESSION_REQUEST_CLOSE, |
| 276 | CEPH_SESSION_CLOSE, |
| 277 | CEPH_SESSION_REQUEST_RENEWCAPS, |
| 278 | CEPH_SESSION_RENEWCAPS, |
| 279 | CEPH_SESSION_STALE, |
| 280 | CEPH_SESSION_RECALL_STATE, |
Yan, Zheng | 186e4f7 | 2013-11-22 14:48:37 +0800 | [diff] [blame] | 281 | CEPH_SESSION_FLUSHMSG, |
| 282 | CEPH_SESSION_FLUSHMSG_ACK, |
Yan, Zheng | 03f4fcb | 2015-01-05 11:04:04 +0800 | [diff] [blame] | 283 | CEPH_SESSION_FORCE_RO, |
Yan, Zheng | fcff415 | 2016-09-14 16:39:51 +0800 | [diff] [blame] | 284 | CEPH_SESSION_REJECT, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 285 | }; |
| 286 | |
| 287 | extern const char *ceph_session_op_name(int op); |
| 288 | |
| 289 | struct ceph_mds_session_head { |
| 290 | __le32 op; |
| 291 | __le64 seq; |
| 292 | struct ceph_timespec stamp; |
| 293 | __le32 max_caps, max_leases; |
| 294 | } __attribute__ ((packed)); |
| 295 | |
| 296 | /* client_request */ |
| 297 | /* |
| 298 | * metadata ops. |
| 299 | * & 0x001000 -> write op |
| 300 | * & 0x010000 -> follow symlink (e.g. stat(), not lstat()). |
| 301 | & & 0x100000 -> use weird ino/path trace |
| 302 | */ |
| 303 | #define CEPH_MDS_OP_WRITE 0x001000 |
| 304 | enum { |
| 305 | CEPH_MDS_OP_LOOKUP = 0x00100, |
| 306 | CEPH_MDS_OP_GETATTR = 0x00101, |
| 307 | CEPH_MDS_OP_LOOKUPHASH = 0x00102, |
| 308 | CEPH_MDS_OP_LOOKUPPARENT = 0x00103, |
Sage Weil | 3c454cf | 2011-04-06 09:31:40 -0700 | [diff] [blame] | 309 | CEPH_MDS_OP_LOOKUPINO = 0x00104, |
Yan, Zheng | 19913b4 | 2014-03-06 16:40:32 +0800 | [diff] [blame] | 310 | CEPH_MDS_OP_LOOKUPNAME = 0x00105, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 311 | |
| 312 | CEPH_MDS_OP_SETXATTR = 0x01105, |
| 313 | CEPH_MDS_OP_RMXATTR = 0x01106, |
| 314 | CEPH_MDS_OP_SETLAYOUT = 0x01107, |
| 315 | CEPH_MDS_OP_SETATTR = 0x01108, |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 316 | CEPH_MDS_OP_SETFILELOCK= 0x01109, |
| 317 | CEPH_MDS_OP_GETFILELOCK= 0x00110, |
Greg Farnum | 571dba5 | 2010-09-24 14:56:40 -0700 | [diff] [blame] | 318 | CEPH_MDS_OP_SETDIRLAYOUT=0x0110a, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 319 | |
| 320 | CEPH_MDS_OP_MKNOD = 0x01201, |
| 321 | CEPH_MDS_OP_LINK = 0x01202, |
| 322 | CEPH_MDS_OP_UNLINK = 0x01203, |
| 323 | CEPH_MDS_OP_RENAME = 0x01204, |
| 324 | CEPH_MDS_OP_MKDIR = 0x01220, |
| 325 | CEPH_MDS_OP_RMDIR = 0x01221, |
| 326 | CEPH_MDS_OP_SYMLINK = 0x01222, |
| 327 | |
Sage Weil | 3ea25f9 | 2010-01-25 11:18:17 -0800 | [diff] [blame] | 328 | CEPH_MDS_OP_CREATE = 0x01301, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 329 | CEPH_MDS_OP_OPEN = 0x00302, |
| 330 | CEPH_MDS_OP_READDIR = 0x00305, |
| 331 | |
| 332 | CEPH_MDS_OP_LOOKUPSNAP = 0x00400, |
| 333 | CEPH_MDS_OP_MKSNAP = 0x01400, |
| 334 | CEPH_MDS_OP_RMSNAP = 0x01401, |
| 335 | CEPH_MDS_OP_LSSNAP = 0x00402, |
Yan, Zheng | 0ea611a | 2015-04-07 15:36:32 +0800 | [diff] [blame] | 336 | CEPH_MDS_OP_RENAMESNAP = 0x01403, |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | extern const char *ceph_mds_op_name(int op); |
| 340 | |
| 341 | |
| 342 | #define CEPH_SETATTR_MODE 1 |
| 343 | #define CEPH_SETATTR_UID 2 |
| 344 | #define CEPH_SETATTR_GID 4 |
| 345 | #define CEPH_SETATTR_MTIME 8 |
| 346 | #define CEPH_SETATTR_ATIME 16 |
| 347 | #define CEPH_SETATTR_SIZE 32 |
| 348 | #define CEPH_SETATTR_CTIME 64 |
| 349 | |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 350 | /* |
| 351 | * Ceph setxattr request flags. |
| 352 | */ |
Yan, Zheng | bcdfeb2 | 2014-02-11 13:04:19 +0800 | [diff] [blame] | 353 | #define CEPH_XATTR_CREATE (1 << 0) |
| 354 | #define CEPH_XATTR_REPLACE (1 << 1) |
| 355 | #define CEPH_XATTR_REMOVE (1 << 31) |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 356 | |
Yan, Zheng | 956d39d | 2016-04-27 17:48:30 +0800 | [diff] [blame] | 357 | /* |
| 358 | * readdir request flags; |
| 359 | */ |
| 360 | #define CEPH_READDIR_REPLY_BITFLAGS (1<<0) |
| 361 | |
| 362 | /* |
| 363 | * readdir reply flags. |
| 364 | */ |
| 365 | #define CEPH_READDIR_FRAG_END (1<<0) |
| 366 | #define CEPH_READDIR_FRAG_COMPLETE (1<<8) |
Yan, Zheng | f3c4ebe | 2016-04-29 11:27:30 +0800 | [diff] [blame] | 367 | #define CEPH_READDIR_HASH_ORDER (1<<9) |
Yan, Zheng | 956d39d | 2016-04-27 17:48:30 +0800 | [diff] [blame] | 368 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 369 | union ceph_mds_request_args { |
| 370 | struct { |
| 371 | __le32 mask; /* CEPH_CAP_* */ |
| 372 | } __attribute__ ((packed)) getattr; |
| 373 | struct { |
| 374 | __le32 mode; |
| 375 | __le32 uid; |
| 376 | __le32 gid; |
| 377 | struct ceph_timespec mtime; |
| 378 | struct ceph_timespec atime; |
| 379 | __le64 size, old_size; /* old_size needed by truncate */ |
| 380 | __le32 mask; /* CEPH_SETATTR_* */ |
| 381 | } __attribute__ ((packed)) setattr; |
| 382 | struct { |
| 383 | __le32 frag; /* which dir fragment */ |
| 384 | __le32 max_entries; /* how many dentries to grab */ |
Sage Weil | 23804d9 | 2010-05-14 13:06:30 -0700 | [diff] [blame] | 385 | __le32 max_bytes; |
Yan, Zheng | 956d39d | 2016-04-27 17:48:30 +0800 | [diff] [blame] | 386 | __le16 flags; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 387 | } __attribute__ ((packed)) readdir; |
| 388 | struct { |
| 389 | __le32 mode; |
| 390 | __le32 rdev; |
| 391 | } __attribute__ ((packed)) mknod; |
| 392 | struct { |
| 393 | __le32 mode; |
| 394 | } __attribute__ ((packed)) mkdir; |
| 395 | struct { |
| 396 | __le32 flags; |
| 397 | __le32 mode; |
| 398 | __le32 stripe_unit; /* layout for newly created file */ |
| 399 | __le32 stripe_count; /* ... */ |
| 400 | __le32 object_size; |
| 401 | __le32 file_replication; |
Yan, Zheng | 315f240 | 2016-03-07 10:34:50 +0800 | [diff] [blame] | 402 | __le32 mask; /* CEPH_CAP_* */ |
| 403 | __le32 old_size; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 404 | } __attribute__ ((packed)) open; |
| 405 | struct { |
| 406 | __le32 flags; |
| 407 | } __attribute__ ((packed)) setxattr; |
| 408 | struct { |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 409 | struct ceph_file_layout_legacy layout; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 410 | } __attribute__ ((packed)) setlayout; |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 411 | struct { |
| 412 | __u8 rule; /* currently fcntl or flock */ |
| 413 | __u8 type; /* shared, exclusive, remove*/ |
Yan, Zheng | eb13e83 | 2014-03-09 23:16:40 +0800 | [diff] [blame] | 414 | __le64 owner; /* owner of the lock */ |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 415 | __le64 pid; /* process id requesting the lock */ |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 416 | __le64 start; /* initial location to lock */ |
| 417 | __le64 length; /* num bytes to lock from start */ |
| 418 | __u8 wait; /* will caller wait for lock to become available? */ |
| 419 | } __attribute__ ((packed)) filelock_change; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 420 | } __attribute__ ((packed)); |
| 421 | |
| 422 | #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */ |
| 423 | #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */ |
| 424 | |
| 425 | struct ceph_mds_request_head { |
Sage Weil | 6df058c | 2009-12-22 11:24:33 -0800 | [diff] [blame] | 426 | __le64 oldest_client_tid; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 427 | __le32 mdsmap_epoch; /* on client */ |
| 428 | __le32 flags; /* CEPH_MDS_FLAG_* */ |
| 429 | __u8 num_retry, num_fwd; /* count retry, fwd attempts */ |
| 430 | __le16 num_releases; /* # include cap/lease release records */ |
| 431 | __le32 op; /* mds op code */ |
| 432 | __le32 caller_uid, caller_gid; |
| 433 | __le64 ino; /* use this ino for openc, mkdir, mknod, |
| 434 | etc. (if replaying) */ |
| 435 | union ceph_mds_request_args args; |
| 436 | } __attribute__ ((packed)); |
| 437 | |
| 438 | /* cap/lease release record */ |
| 439 | struct ceph_mds_request_release { |
| 440 | __le64 ino, cap_id; /* ino and unique cap id */ |
| 441 | __le32 caps, wanted; /* new issued, wanted */ |
| 442 | __le32 seq, issue_seq, mseq; |
| 443 | __le32 dname_seq; /* if releasing a dentry lease, a */ |
| 444 | __le32 dname_len; /* string follows. */ |
| 445 | } __attribute__ ((packed)); |
| 446 | |
| 447 | /* client reply */ |
| 448 | struct ceph_mds_reply_head { |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 449 | __le32 op; |
| 450 | __le32 result; |
| 451 | __le32 mdsmap_epoch; |
| 452 | __u8 safe; /* true if committed to disk */ |
| 453 | __u8 is_dentry, is_target; /* true if dentry, target inode records |
| 454 | are included with reply */ |
| 455 | } __attribute__ ((packed)); |
| 456 | |
| 457 | /* one for each node split */ |
| 458 | struct ceph_frag_tree_split { |
| 459 | __le32 frag; /* this frag splits... */ |
| 460 | __le32 by; /* ...by this many bits */ |
| 461 | } __attribute__ ((packed)); |
| 462 | |
| 463 | struct ceph_frag_tree_head { |
| 464 | __le32 nsplits; /* num ceph_frag_tree_split records */ |
| 465 | struct ceph_frag_tree_split splits[]; |
| 466 | } __attribute__ ((packed)); |
| 467 | |
| 468 | /* capability issue, for bundling with mds reply */ |
| 469 | struct ceph_mds_reply_cap { |
| 470 | __le32 caps, wanted; /* caps issued, wanted */ |
| 471 | __le64 cap_id; |
| 472 | __le32 seq, mseq; |
| 473 | __le64 realm; /* snap realm */ |
| 474 | __u8 flags; /* CEPH_CAP_FLAG_* */ |
| 475 | } __attribute__ ((packed)); |
| 476 | |
Yan, Zheng | 4ee6a91 | 2013-11-24 14:43:46 +0800 | [diff] [blame] | 477 | #define CEPH_CAP_FLAG_AUTH (1 << 0) /* cap is issued by auth mds */ |
| 478 | #define CEPH_CAP_FLAG_RELEASE (1 << 1) /* release the cap */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 479 | |
| 480 | /* inode record, for bundling with mds reply */ |
| 481 | struct ceph_mds_reply_inode { |
| 482 | __le64 ino; |
| 483 | __le64 snapid; |
| 484 | __le32 rdev; |
| 485 | __le64 version; /* inode version */ |
| 486 | __le64 xattr_version; /* version for xattr blob */ |
| 487 | struct ceph_mds_reply_cap cap; /* caps issued for this inode */ |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 488 | struct ceph_file_layout_legacy layout; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 489 | struct ceph_timespec ctime, mtime, atime; |
| 490 | __le32 time_warp_seq; |
| 491 | __le64 size, max_size, truncate_size; |
| 492 | __le32 truncate_seq; |
| 493 | __le32 mode, uid, gid; |
| 494 | __le32 nlink; |
| 495 | __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */ |
| 496 | struct ceph_timespec rctime; |
| 497 | struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */ |
| 498 | } __attribute__ ((packed)); |
Sage Weil | 6c0f3af | 2010-11-16 11:14:34 -0800 | [diff] [blame] | 499 | /* followed by frag array, symlink string, dir layout, xattr blob */ |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 500 | |
| 501 | /* reply_lease follows dname, and reply_inode */ |
| 502 | struct ceph_mds_reply_lease { |
| 503 | __le16 mask; /* lease type(s) */ |
| 504 | __le32 duration_ms; /* lease duration */ |
| 505 | __le32 seq; |
| 506 | } __attribute__ ((packed)); |
| 507 | |
| 508 | struct ceph_mds_reply_dirfrag { |
| 509 | __le32 frag; /* fragment */ |
| 510 | __le32 auth; /* auth mds, if this is a delegation point */ |
| 511 | __le32 ndist; /* number of mds' this is replicated on */ |
| 512 | __le32 dist[]; |
| 513 | } __attribute__ ((packed)); |
| 514 | |
Yan, Zheng | 9280be2 | 2014-10-14 10:33:35 +0800 | [diff] [blame] | 515 | #define CEPH_LOCK_FCNTL 1 |
| 516 | #define CEPH_LOCK_FLOCK 2 |
| 517 | #define CEPH_LOCK_FCNTL_INTR 3 |
| 518 | #define CEPH_LOCK_FLOCK_INTR 4 |
| 519 | |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 520 | |
| 521 | #define CEPH_LOCK_SHARED 1 |
| 522 | #define CEPH_LOCK_EXCL 2 |
| 523 | #define CEPH_LOCK_UNLOCK 4 |
| 524 | |
| 525 | struct ceph_filelock { |
| 526 | __le64 start;/* file offset to start lock at */ |
| 527 | __le64 length; /* num bytes to lock; 0 for all following start */ |
| 528 | __le64 client; /* which client holds the lock */ |
Yan, Zheng | eb13e83 | 2014-03-09 23:16:40 +0800 | [diff] [blame] | 529 | __le64 owner; /* owner the lock */ |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 530 | __le64 pid; /* process id holding the lock on the client */ |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 531 | __u8 type; /* shared lock, exclusive lock, or unlock */ |
| 532 | } __attribute__ ((packed)); |
| 533 | |
| 534 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 535 | /* file access modes */ |
| 536 | #define CEPH_FILE_MODE_PIN 0 |
| 537 | #define CEPH_FILE_MODE_RD 1 |
| 538 | #define CEPH_FILE_MODE_WR 2 |
| 539 | #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */ |
| 540 | #define CEPH_FILE_MODE_LAZY 4 /* lazy io */ |
Yan, Zheng | 774a6a1 | 2016-06-06 16:01:39 +0800 | [diff] [blame] | 541 | #define CEPH_FILE_MODE_BITS 4 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 542 | |
| 543 | int ceph_flags_to_mode(int flags); |
| 544 | |
Yan, Zheng | 31c542a | 2014-11-14 21:41:55 +0800 | [diff] [blame] | 545 | #define CEPH_INLINE_NONE ((__u64)-1) |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 546 | |
| 547 | /* capability bits */ |
| 548 | #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */ |
| 549 | |
| 550 | /* generic cap bits */ |
| 551 | #define CEPH_CAP_GSHARED 1 /* client can reads */ |
| 552 | #define CEPH_CAP_GEXCL 2 /* client can read and update */ |
| 553 | #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */ |
| 554 | #define CEPH_CAP_GRD 8 /* (file) client can read */ |
| 555 | #define CEPH_CAP_GWR 16 /* (file) client can write */ |
| 556 | #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */ |
| 557 | #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */ |
| 558 | #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */ |
| 559 | |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 560 | #define CEPH_CAP_SIMPLE_BITS 2 |
| 561 | #define CEPH_CAP_FILE_BITS 8 |
| 562 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 563 | /* per-lock shift */ |
| 564 | #define CEPH_CAP_SAUTH 2 |
| 565 | #define CEPH_CAP_SLINK 4 |
| 566 | #define CEPH_CAP_SXATTR 6 |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 567 | #define CEPH_CAP_SFILE 8 |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 568 | #define CEPH_CAP_SFLOCK 20 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 569 | |
Alex Elder | dd6f5e1 | 2013-02-15 11:42:30 -0600 | [diff] [blame] | 570 | #define CEPH_CAP_BITS 22 |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 571 | |
| 572 | /* composed values */ |
| 573 | #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH) |
| 574 | #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH) |
| 575 | #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK) |
| 576 | #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK) |
| 577 | #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR) |
| 578 | #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR) |
| 579 | #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE) |
| 580 | #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE) |
| 581 | #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE) |
| 582 | #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE) |
| 583 | #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE) |
| 584 | #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE) |
| 585 | #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE) |
| 586 | #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE) |
| 587 | #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE) |
Greg Farnum | fbaad97 | 2010-08-02 15:30:08 -0700 | [diff] [blame] | 588 | #define CEPH_CAP_FLOCK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFLOCK) |
| 589 | #define CEPH_CAP_FLOCK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFLOCK) |
| 590 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 591 | |
| 592 | /* cap masks (for getattr) */ |
| 593 | #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN |
| 594 | #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */ |
| 595 | #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN |
| 596 | #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED |
| 597 | #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED |
| 598 | #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED |
| 599 | #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED |
| 600 | #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED |
| 601 | #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED |
| 602 | #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED |
| 603 | #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */ |
| 604 | #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED |
| 605 | #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \ |
| 606 | CEPH_CAP_AUTH_SHARED | \ |
| 607 | CEPH_CAP_LINK_SHARED | \ |
| 608 | CEPH_CAP_FILE_SHARED | \ |
| 609 | CEPH_CAP_XATTR_SHARED) |
Yan, Zheng | 01deead | 2014-11-14 21:56:29 +0800 | [diff] [blame] | 610 | #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \ |
| 611 | CEPH_CAP_FILE_RD) |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 612 | |
| 613 | #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \ |
| 614 | CEPH_CAP_LINK_SHARED | \ |
| 615 | CEPH_CAP_XATTR_SHARED | \ |
| 616 | CEPH_CAP_FILE_SHARED) |
| 617 | #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \ |
| 618 | CEPH_CAP_FILE_CACHE) |
| 619 | |
| 620 | #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \ |
| 621 | CEPH_CAP_LINK_EXCL | \ |
| 622 | CEPH_CAP_XATTR_EXCL | \ |
| 623 | CEPH_CAP_FILE_EXCL) |
Yan, Zheng | f98a128 | 2014-04-17 08:55:50 +0800 | [diff] [blame] | 624 | #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \ |
| 625 | CEPH_CAP_FILE_SHARED) |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 626 | #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \ |
| 627 | CEPH_CAP_FILE_EXCL) |
| 628 | #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR) |
| 629 | #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \ |
Sage Weil | 84d9509 | 2010-05-25 16:46:24 -0700 | [diff] [blame] | 630 | CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \ |
| 631 | CEPH_CAP_PIN) |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 632 | |
| 633 | #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \ |
| 634 | CEPH_LOCK_IXATTR) |
| 635 | |
| 636 | int ceph_caps_for_mode(int mode); |
| 637 | |
| 638 | enum { |
| 639 | CEPH_CAP_OP_GRANT, /* mds->client grant */ |
| 640 | CEPH_CAP_OP_REVOKE, /* mds->client revoke */ |
| 641 | CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */ |
| 642 | CEPH_CAP_OP_EXPORT, /* mds has exported the cap */ |
| 643 | CEPH_CAP_OP_IMPORT, /* mds has imported the cap */ |
| 644 | CEPH_CAP_OP_UPDATE, /* client->mds update */ |
| 645 | CEPH_CAP_OP_DROP, /* client->mds drop cap bits */ |
| 646 | CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */ |
| 647 | CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */ |
| 648 | CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */ |
| 649 | CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */ |
| 650 | CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */ |
| 651 | CEPH_CAP_OP_RENEW, /* client->mds renewal request */ |
| 652 | }; |
| 653 | |
| 654 | extern const char *ceph_cap_op_name(int op); |
| 655 | |
Jeff Layton | 1e4ef0c | 2016-11-10 07:42:06 -0500 | [diff] [blame] | 656 | /* flags field in client cap messages (version >= 10) */ |
| 657 | #define CEPH_CLIENT_CAPS_SYNC (0x1) |
| 658 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 659 | /* |
| 660 | * caps message, used for capability callbacks, acks, requests, etc. |
| 661 | */ |
| 662 | struct ceph_mds_caps { |
| 663 | __le32 op; /* CEPH_CAP_OP_* */ |
| 664 | __le64 ino, realm; |
| 665 | __le64 cap_id; |
| 666 | __le32 seq, issue_seq; |
| 667 | __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */ |
| 668 | __le32 migrate_seq; |
| 669 | __le64 snap_follows; |
| 670 | __le32 snap_trace_len; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 671 | |
| 672 | /* authlock */ |
| 673 | __le32 uid, gid, mode; |
| 674 | |
| 675 | /* linklock */ |
| 676 | __le32 nlink; |
| 677 | |
| 678 | /* xattrlock */ |
| 679 | __le32 xattr_len; |
| 680 | __le64 xattr_version; |
| 681 | |
| 682 | /* filelock */ |
| 683 | __le64 size, max_size, truncate_size; |
| 684 | __le32 truncate_seq; |
| 685 | struct ceph_timespec mtime, atime, ctime; |
Yan, Zheng | 7627151 | 2016-02-03 21:24:49 +0800 | [diff] [blame] | 686 | struct ceph_file_layout_legacy layout; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 687 | __le32 time_warp_seq; |
| 688 | } __attribute__ ((packed)); |
| 689 | |
Yan, Zheng | 4ee6a91 | 2013-11-24 14:43:46 +0800 | [diff] [blame] | 690 | struct ceph_mds_cap_peer { |
| 691 | __le64 cap_id; |
| 692 | __le32 seq; |
| 693 | __le32 mseq; |
| 694 | __le32 mds; |
| 695 | __u8 flags; |
| 696 | } __attribute__ ((packed)); |
| 697 | |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 698 | /* cap release msg head */ |
| 699 | struct ceph_mds_cap_release { |
| 700 | __le32 num; /* number of cap_items that follow */ |
| 701 | } __attribute__ ((packed)); |
| 702 | |
| 703 | struct ceph_mds_cap_item { |
| 704 | __le64 ino; |
| 705 | __le64 cap_id; |
| 706 | __le32 migrate_seq, seq; |
| 707 | } __attribute__ ((packed)); |
| 708 | |
| 709 | #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */ |
| 710 | #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */ |
| 711 | #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */ |
| 712 | #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */ |
| 713 | |
| 714 | extern const char *ceph_lease_op_name(int o); |
| 715 | |
| 716 | /* lease msg header */ |
| 717 | struct ceph_mds_lease { |
| 718 | __u8 action; /* CEPH_MDS_LEASE_* */ |
| 719 | __le16 mask; /* which lease */ |
| 720 | __le64 ino; |
| 721 | __le64 first, last; /* snap range */ |
| 722 | __le32 seq; |
| 723 | __le32 duration_ms; /* duration of renewal */ |
| 724 | } __attribute__ ((packed)); |
| 725 | /* followed by a __le32+string for dname */ |
| 726 | |
| 727 | /* client reconnect */ |
| 728 | struct ceph_mds_cap_reconnect { |
| 729 | __le64 cap_id; |
| 730 | __le32 wanted; |
| 731 | __le32 issued; |
Sage Weil | 20cb34a | 2010-05-12 15:21:32 -0700 | [diff] [blame] | 732 | __le64 snaprealm; |
| 733 | __le64 pathbase; /* base ino for our path to this ino */ |
| 734 | __le32 flock_len; /* size of flock state blob, if any */ |
| 735 | } __attribute__ ((packed)); |
| 736 | /* followed by flock blob */ |
| 737 | |
| 738 | struct ceph_mds_cap_reconnect_v1 { |
| 739 | __le64 cap_id; |
| 740 | __le32 wanted; |
| 741 | __le32 issued; |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 742 | __le64 size; |
| 743 | struct ceph_timespec mtime, atime; |
| 744 | __le64 snaprealm; |
| 745 | __le64 pathbase; /* base ino for our path to this ino */ |
| 746 | } __attribute__ ((packed)); |
Sage Weil | 0dee3c2 | 2009-10-06 11:31:06 -0700 | [diff] [blame] | 747 | |
| 748 | struct ceph_mds_snaprealm_reconnect { |
| 749 | __le64 ino; /* snap realm base */ |
| 750 | __le64 seq; /* snap seq for this snap realm */ |
| 751 | __le64 parent; /* parent realm */ |
| 752 | } __attribute__ ((packed)); |
| 753 | |
| 754 | /* |
| 755 | * snaps |
| 756 | */ |
| 757 | enum { |
| 758 | CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */ |
| 759 | CEPH_SNAP_OP_CREATE, |
| 760 | CEPH_SNAP_OP_DESTROY, |
| 761 | CEPH_SNAP_OP_SPLIT, |
| 762 | }; |
| 763 | |
| 764 | extern const char *ceph_snap_op_name(int o); |
| 765 | |
| 766 | /* snap msg header */ |
| 767 | struct ceph_mds_snap_head { |
| 768 | __le32 op; /* CEPH_SNAP_OP_* */ |
| 769 | __le64 split; /* ino to split off, if any */ |
| 770 | __le32 num_split_inos; /* # inos belonging to new child realm */ |
| 771 | __le32 num_split_realms; /* # child realms udner new child realm */ |
| 772 | __le32 trace_len; /* size of snap trace blob */ |
| 773 | } __attribute__ ((packed)); |
| 774 | /* followed by split ino list, then split realms, then the trace blob */ |
| 775 | |
| 776 | /* |
| 777 | * encode info about a snaprealm, as viewed by a client |
| 778 | */ |
| 779 | struct ceph_mds_snap_realm { |
| 780 | __le64 ino; /* ino */ |
| 781 | __le64 created; /* snap: when created */ |
| 782 | __le64 parent; /* ino: parent realm */ |
| 783 | __le64 parent_since; /* snap: same parent since */ |
| 784 | __le64 seq; /* snap: version */ |
| 785 | __le32 num_snaps; |
| 786 | __le32 num_prior_parent_snaps; |
| 787 | } __attribute__ ((packed)); |
| 788 | /* followed by my snap list, then prior parent snap list */ |
| 789 | |
| 790 | #endif |