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