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