ceph_fs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. #ifndef _FS_CEPH_CEPH_FS_H
  12. #define _FS_CEPH_CEPH_FS_H
  13. #include "msgr.h"
  14. #include "rados.h"
  15. /*
  16. * Ceph release version
  17. */
  18. #define CEPH_VERSION_MAJOR 0
  19. #define CEPH_VERSION_MINOR 16
  20. #define CEPH_VERSION_PATCH 1
  21. #define _CEPH_STRINGIFY(x) #x
  22. #define CEPH_STRINGIFY(x) _CEPH_STRINGIFY(x)
  23. #define CEPH_MAKE_VERSION(x, y, z) CEPH_STRINGIFY(x) "." CEPH_STRINGIFY(y) \
  24. "." CEPH_STRINGIFY(z)
  25. #define CEPH_VERSION CEPH_MAKE_VERSION(CEPH_VERSION_MAJOR, \
  26. CEPH_VERSION_MINOR, CEPH_VERSION_PATCH)
  27. /*
  28. * subprotocol versions. when specific messages types or high-level
  29. * protocols change, bump the affected components. we keep rev
  30. * internal cluster protocols separately from the public,
  31. * client-facing protocol.
  32. */
  33. #define CEPH_OSD_PROTOCOL 7 /* cluster internal */
  34. #define CEPH_MDS_PROTOCOL 9 /* cluster internal */
  35. #define CEPH_MON_PROTOCOL 5 /* cluster internal */
  36. #define CEPH_OSDC_PROTOCOL 20 /* server/client */
  37. #define CEPH_MDSC_PROTOCOL 29 /* server/client */
  38. #define CEPH_MONC_PROTOCOL 15 /* server/client */
  39. #define CEPH_INO_ROOT 1
  40. /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
  41. #define CEPH_MAX_MON 31
  42. unsigned int ceph_full_name_hash(const char *name, unsigned int len);
  43. /*
  44. * ceph_file_layout - describe data layout for a file/inode
  45. */
  46. struct ceph_file_layout {
  47. /* file -> object mapping */
  48. __le32 fl_stripe_unit; /* stripe unit, in bytes. must be multiple
  49. of page size. */
  50. __le32 fl_stripe_count; /* over this many objects */
  51. __le32 fl_object_size; /* until objects are this big, then move to
  52. new objects */
  53. __le32 fl_cas_hash; /* 0 = none; 1 = sha256 */
  54. /* pg -> disk layout */
  55. __le32 fl_object_stripe_unit; /* for per-object parity, if any */
  56. /* object -> pg layout */
  57. __le32 fl_pg_preferred; /* preferred primary for pg (-1 for none) */
  58. __le32 fl_pg_pool; /* namespace, crush ruleset, rep level */
  59. } __attribute__ ((packed));
  60. #define CEPH_MIN_STRIPE_UNIT 65536
  61. int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
  62. /*********************************************
  63. * message layer
  64. */
  65. /*
  66. * message types
  67. */
  68. /* misc */
  69. #define CEPH_MSG_SHUTDOWN 1
  70. #define CEPH_MSG_PING 2
  71. /* client <-> monitor */
  72. #define CEPH_MSG_MON_MAP 4
  73. #define CEPH_MSG_MON_GET_MAP 5
  74. #define CEPH_MSG_CLIENT_MOUNT 10
  75. #define CEPH_MSG_CLIENT_MOUNT_ACK 11
  76. #define CEPH_MSG_STATFS 13
  77. #define CEPH_MSG_STATFS_REPLY 14
  78. #define CEPH_MSG_MON_SUBSCRIBE 15
  79. #define CEPH_MSG_MON_SUBSCRIBE_ACK 16
  80. /* client <-> mds */
  81. #define CEPH_MSG_MDS_MAP 21
  82. #define CEPH_MSG_CLIENT_SESSION 22
  83. #define CEPH_MSG_CLIENT_RECONNECT 23
  84. #define CEPH_MSG_CLIENT_REQUEST 24
  85. #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
  86. #define CEPH_MSG_CLIENT_REPLY 26
  87. #define CEPH_MSG_CLIENT_CAPS 0x310
  88. #define CEPH_MSG_CLIENT_LEASE 0x311
  89. #define CEPH_MSG_CLIENT_SNAP 0x312
  90. #define CEPH_MSG_CLIENT_CAPRELEASE 0x313
  91. /* osd */
  92. #define CEPH_MSG_OSD_MAP 41
  93. #define CEPH_MSG_OSD_OP 42
  94. #define CEPH_MSG_OSD_OPREPLY 43
  95. struct ceph_mon_request_header {
  96. __le64 have_version;
  97. __le16 session_mon;
  98. __le64 session_mon_tid;
  99. } __attribute__ ((packed));
  100. struct ceph_mon_statfs {
  101. struct ceph_mon_request_header monhdr;
  102. struct ceph_fsid fsid;
  103. __le64 tid;
  104. } __attribute__ ((packed));
  105. struct ceph_statfs {
  106. __le64 kb, kb_used, kb_avail;
  107. __le64 num_objects;
  108. } __attribute__ ((packed));
  109. struct ceph_mon_statfs_reply {
  110. struct ceph_fsid fsid;
  111. __le64 tid;
  112. __le64 version;
  113. struct ceph_statfs st;
  114. } __attribute__ ((packed));
  115. struct ceph_osd_getmap {
  116. struct ceph_mon_request_header monhdr;
  117. struct ceph_fsid fsid;
  118. __le32 start;
  119. } __attribute__ ((packed));
  120. struct ceph_mds_getmap {
  121. struct ceph_mon_request_header monhdr;
  122. struct ceph_fsid fsid;
  123. } __attribute__ ((packed));
  124. struct ceph_client_mount {
  125. struct ceph_mon_request_header monhdr;
  126. } __attribute__ ((packed));
  127. struct ceph_mon_subscribe_item {
  128. __le64 have_version; __le64 have;
  129. __u8 onetime;
  130. } __attribute__ ((packed));
  131. struct ceph_mon_subscribe_ack {
  132. __le32 duration; /* seconds */
  133. struct ceph_fsid fsid;
  134. } __attribute__ ((packed));
  135. /*
  136. * mds states
  137. * > 0 -> in
  138. * <= 0 -> out
  139. */
  140. #define CEPH_MDS_STATE_DNE 0 /* down, does not exist. */
  141. #define CEPH_MDS_STATE_STOPPED -1 /* down, once existed, but no subtrees.
  142. empty log. */
  143. #define CEPH_MDS_STATE_BOOT -4 /* up, boot announcement. */
  144. #define CEPH_MDS_STATE_STANDBY -5 /* up, idle. waiting for assignment. */
  145. #define CEPH_MDS_STATE_CREATING -6 /* up, creating MDS instance. */
  146. #define CEPH_MDS_STATE_STARTING -7 /* up, starting previously stopped mds */
  147. #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
  148. #define CEPH_MDS_STATE_REPLAY 8 /* up, replaying journal. */
  149. #define CEPH_MDS_STATE_RESOLVE 9 /* up, disambiguating distributed
  150. operations (import, rename, etc.) */
  151. #define CEPH_MDS_STATE_RECONNECT 10 /* up, reconnect to clients */
  152. #define CEPH_MDS_STATE_REJOIN 11 /* up, rejoining distributed cache */
  153. #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
  154. #define CEPH_MDS_STATE_ACTIVE 13 /* up, active */
  155. #define CEPH_MDS_STATE_STOPPING 14 /* up, but exporting metadata */
  156. extern const char *ceph_mds_state_name(int s);
  157. /*
  158. * metadata lock types.
  159. * - these are bitmasks.. we can compose them
  160. * - they also define the lock ordering by the MDS
  161. * - a few of these are internal to the mds
  162. */
  163. #define CEPH_LOCK_DN 1
  164. #define CEPH_LOCK_ISNAP 2
  165. #define CEPH_LOCK_IVERSION 4 /* mds internal */
  166. #define CEPH_LOCK_IFILE 8 /* mds internal */
  167. #define CEPH_LOCK_IAUTH 32
  168. #define CEPH_LOCK_ILINK 64
  169. #define CEPH_LOCK_IDFT 128 /* dir frag tree */
  170. #define CEPH_LOCK_INEST 256 /* mds internal */
  171. #define CEPH_LOCK_IXATTR 512
  172. #define CEPH_LOCK_INO 2048 /* immutable inode bits; not a lock */
  173. /* client_session ops */
  174. enum {
  175. CEPH_SESSION_REQUEST_OPEN,
  176. CEPH_SESSION_OPEN,
  177. CEPH_SESSION_REQUEST_CLOSE,
  178. CEPH_SESSION_CLOSE,
  179. CEPH_SESSION_REQUEST_RENEWCAPS,
  180. CEPH_SESSION_RENEWCAPS,
  181. CEPH_SESSION_STALE,
  182. CEPH_SESSION_RECALL_STATE,
  183. };
  184. extern const char *ceph_session_op_name(int op);
  185. struct ceph_mds_session_head {
  186. __le32 op;
  187. __le64 seq;
  188. struct ceph_timespec stamp;
  189. __le32 max_caps, max_leases;
  190. } __attribute__ ((packed));
  191. /* client_request */
  192. /*
  193. * metadata ops.
  194. * & 0x001000 -> write op
  195. * & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
  196. & & 0x100000 -> use weird ino/path trace
  197. */
  198. #define CEPH_MDS_OP_WRITE 0x001000
  199. enum {
  200. CEPH_MDS_OP_LOOKUP = 0x00100,
  201. CEPH_MDS_OP_GETATTR = 0x00101,
  202. CEPH_MDS_OP_LOOKUPHASH = 0x00102,
  203. CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
  204. CEPH_MDS_OP_SETXATTR = 0x01105,
  205. CEPH_MDS_OP_RMXATTR = 0x01106,
  206. CEPH_MDS_OP_SETLAYOUT = 0x01107,
  207. CEPH_MDS_OP_SETATTR = 0x01108,
  208. CEPH_MDS_OP_MKNOD = 0x01201,
  209. CEPH_MDS_OP_LINK = 0x01202,
  210. CEPH_MDS_OP_UNLINK = 0x01203,
  211. CEPH_MDS_OP_RENAME = 0x01204,
  212. CEPH_MDS_OP_MKDIR = 0x01220,
  213. CEPH_MDS_OP_RMDIR = 0x01221,
  214. CEPH_MDS_OP_SYMLINK = 0x01222,
  215. CEPH_MDS_OP_CREATE = 0x00301,
  216. CEPH_MDS_OP_OPEN = 0x00302,
  217. CEPH_MDS_OP_READDIR = 0x00305,
  218. CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
  219. CEPH_MDS_OP_MKSNAP = 0x01400,
  220. CEPH_MDS_OP_RMSNAP = 0x01401,
  221. CEPH_MDS_OP_LSSNAP = 0x00402,
  222. };
  223. extern const char *ceph_mds_op_name(int op);
  224. #define CEPH_SETATTR_MODE 1
  225. #define CEPH_SETATTR_UID 2
  226. #define CEPH_SETATTR_GID 4
  227. #define CEPH_SETATTR_MTIME 8
  228. #define CEPH_SETATTR_ATIME 16
  229. #define CEPH_SETATTR_SIZE 32
  230. #define CEPH_SETATTR_CTIME 64
  231. union ceph_mds_request_args {
  232. struct {
  233. __le32 mask; /* CEPH_CAP_* */
  234. } __attribute__ ((packed)) getattr;
  235. struct {
  236. __le32 mode;
  237. __le32 uid;
  238. __le32 gid;
  239. struct ceph_timespec mtime;
  240. struct ceph_timespec atime;
  241. __le64 size, old_size; /* old_size needed by truncate */
  242. __le32 mask; /* CEPH_SETATTR_* */
  243. } __attribute__ ((packed)) setattr;
  244. struct {
  245. __le32 frag; /* which dir fragment */
  246. __le32 max_entries; /* how many dentries to grab */
  247. } __attribute__ ((packed)) readdir;
  248. struct {
  249. __le32 mode;
  250. __le32 rdev;
  251. } __attribute__ ((packed)) mknod;
  252. struct {
  253. __le32 mode;
  254. } __attribute__ ((packed)) mkdir;
  255. struct {
  256. __le32 flags;
  257. __le32 mode;
  258. __le32 stripe_unit; /* layout for newly created file */
  259. __le32 stripe_count; /* ... */
  260. __le32 object_size;
  261. __le32 file_replication;
  262. __le32 preferred;
  263. } __attribute__ ((packed)) open;
  264. struct {
  265. __le32 flags;
  266. } __attribute__ ((packed)) setxattr;
  267. struct {
  268. struct ceph_file_layout layout;
  269. } __attribute__ ((packed)) setlayout;
  270. } __attribute__ ((packed));
  271. #define CEPH_MDS_FLAG_REPLAY 1 /* this is a replayed op */
  272. #define CEPH_MDS_FLAG_WANT_DENTRY 2 /* want dentry in reply */
  273. struct ceph_mds_request_head {
  274. __le64 tid, oldest_client_tid;
  275. __le32 mdsmap_epoch; /* on client */
  276. __le32 flags; /* CEPH_MDS_FLAG_* */
  277. __u8 num_retry, num_fwd; /* count retry, fwd attempts */
  278. __le16 num_releases; /* # include cap/lease release records */
  279. __le32 op; /* mds op code */
  280. __le32 caller_uid, caller_gid;
  281. __le64 ino; /* use this ino for openc, mkdir, mknod,
  282. etc. (if replaying) */
  283. union ceph_mds_request_args args;
  284. } __attribute__ ((packed));
  285. /* cap/lease release record */
  286. struct ceph_mds_request_release {
  287. __le64 ino, cap_id; /* ino and unique cap id */
  288. __le32 caps, wanted; /* new issued, wanted */
  289. __le32 seq, issue_seq, mseq;
  290. __le32 dname_seq; /* if releasing a dentry lease, a */
  291. __le32 dname_len; /* string follows. */
  292. } __attribute__ ((packed));
  293. /* client reply */
  294. struct ceph_mds_reply_head {
  295. __le64 tid;
  296. __le32 op;
  297. __le32 result;
  298. __le32 mdsmap_epoch;
  299. __u8 safe; /* true if committed to disk */
  300. __u8 is_dentry, is_target; /* true if dentry, target inode records
  301. are included with reply */
  302. } __attribute__ ((packed));
  303. /* one for each node split */
  304. struct ceph_frag_tree_split {
  305. __le32 frag; /* this frag splits... */
  306. __le32 by; /* ...by this many bits */
  307. } __attribute__ ((packed));
  308. struct ceph_frag_tree_head {
  309. __le32 nsplits; /* num ceph_frag_tree_split records */
  310. struct ceph_frag_tree_split splits[];
  311. } __attribute__ ((packed));
  312. /* capability issue, for bundling with mds reply */
  313. struct ceph_mds_reply_cap {
  314. __le32 caps, wanted; /* caps issued, wanted */
  315. __le64 cap_id;
  316. __le32 seq, mseq;
  317. __le64 realm; /* snap realm */
  318. __u8 flags; /* CEPH_CAP_FLAG_* */
  319. } __attribute__ ((packed));
  320. #define CEPH_CAP_FLAG_AUTH 1 /* cap is issued by auth mds */
  321. /* inode record, for bundling with mds reply */
  322. struct ceph_mds_reply_inode {
  323. __le64 ino;
  324. __le64 snapid;
  325. __le32 rdev;
  326. __le64 version; /* inode version */
  327. __le64 xattr_version; /* version for xattr blob */
  328. struct ceph_mds_reply_cap cap; /* caps issued for this inode */
  329. struct ceph_file_layout layout;
  330. struct ceph_timespec ctime, mtime, atime;
  331. __le32 time_warp_seq;
  332. __le64 size, max_size, truncate_size;
  333. __le32 truncate_seq;
  334. __le32 mode, uid, gid;
  335. __le32 nlink;
  336. __le64 files, subdirs, rbytes, rfiles, rsubdirs; /* dir stats */
  337. struct ceph_timespec rctime;
  338. struct ceph_frag_tree_head fragtree; /* (must be at end of struct) */
  339. } __attribute__ ((packed));
  340. /* followed by frag array, then symlink string, then xattr blob */
  341. /* reply_lease follows dname, and reply_inode */
  342. struct ceph_mds_reply_lease {
  343. __le16 mask; /* lease type(s) */
  344. __le32 duration_ms; /* lease duration */
  345. __le32 seq;
  346. } __attribute__ ((packed));
  347. struct ceph_mds_reply_dirfrag {
  348. __le32 frag; /* fragment */
  349. __le32 auth; /* auth mds, if this is a delegation point */
  350. __le32 ndist; /* number of mds' this is replicated on */
  351. __le32 dist[];
  352. } __attribute__ ((packed));
  353. /* file access modes */
  354. #define CEPH_FILE_MODE_PIN 0
  355. #define CEPH_FILE_MODE_RD 1
  356. #define CEPH_FILE_MODE_WR 2
  357. #define CEPH_FILE_MODE_RDWR 3 /* RD | WR */
  358. #define CEPH_FILE_MODE_LAZY 4 /* lazy io */
  359. #define CEPH_FILE_MODE_NUM 8 /* bc these are bit fields.. mostly */
  360. int ceph_flags_to_mode(int flags);
  361. /* capability bits */
  362. #define CEPH_CAP_PIN 1 /* no specific capabilities beyond the pin */
  363. /* generic cap bits */
  364. #define CEPH_CAP_GSHARED 1 /* client can reads */
  365. #define CEPH_CAP_GEXCL 2 /* client can read and update */
  366. #define CEPH_CAP_GCACHE 4 /* (file) client can cache reads */
  367. #define CEPH_CAP_GRD 8 /* (file) client can read */
  368. #define CEPH_CAP_GWR 16 /* (file) client can write */
  369. #define CEPH_CAP_GBUFFER 32 /* (file) client can buffer writes */
  370. #define CEPH_CAP_GWREXTEND 64 /* (file) client can extend EOF */
  371. #define CEPH_CAP_GLAZYIO 128 /* (file) client can perform lazy io */
  372. /* per-lock shift */
  373. #define CEPH_CAP_SAUTH 2
  374. #define CEPH_CAP_SLINK 4
  375. #define CEPH_CAP_SXATTR 6
  376. #define CEPH_CAP_SFILE 8 /* goes at the end (uses >2 cap bits) */
  377. #define CEPH_CAP_BITS 16
  378. /* composed values */
  379. #define CEPH_CAP_AUTH_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SAUTH)
  380. #define CEPH_CAP_AUTH_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SAUTH)
  381. #define CEPH_CAP_LINK_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SLINK)
  382. #define CEPH_CAP_LINK_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SLINK)
  383. #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SXATTR)
  384. #define CEPH_CAP_XATTR_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SXATTR)
  385. #define CEPH_CAP_FILE(x) (x << CEPH_CAP_SFILE)
  386. #define CEPH_CAP_FILE_SHARED (CEPH_CAP_GSHARED << CEPH_CAP_SFILE)
  387. #define CEPH_CAP_FILE_EXCL (CEPH_CAP_GEXCL << CEPH_CAP_SFILE)
  388. #define CEPH_CAP_FILE_CACHE (CEPH_CAP_GCACHE << CEPH_CAP_SFILE)
  389. #define CEPH_CAP_FILE_RD (CEPH_CAP_GRD << CEPH_CAP_SFILE)
  390. #define CEPH_CAP_FILE_WR (CEPH_CAP_GWR << CEPH_CAP_SFILE)
  391. #define CEPH_CAP_FILE_BUFFER (CEPH_CAP_GBUFFER << CEPH_CAP_SFILE)
  392. #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
  393. #define CEPH_CAP_FILE_LAZYIO (CEPH_CAP_GLAZYIO << CEPH_CAP_SFILE)
  394. /* cap masks (for getattr) */
  395. #define CEPH_STAT_CAP_INODE CEPH_CAP_PIN
  396. #define CEPH_STAT_CAP_TYPE CEPH_CAP_PIN /* mode >> 12 */
  397. #define CEPH_STAT_CAP_SYMLINK CEPH_CAP_PIN
  398. #define CEPH_STAT_CAP_UID CEPH_CAP_AUTH_SHARED
  399. #define CEPH_STAT_CAP_GID CEPH_CAP_AUTH_SHARED
  400. #define CEPH_STAT_CAP_MODE CEPH_CAP_AUTH_SHARED
  401. #define CEPH_STAT_CAP_NLINK CEPH_CAP_LINK_SHARED
  402. #define CEPH_STAT_CAP_LAYOUT CEPH_CAP_FILE_SHARED
  403. #define CEPH_STAT_CAP_MTIME CEPH_CAP_FILE_SHARED
  404. #define CEPH_STAT_CAP_SIZE CEPH_CAP_FILE_SHARED
  405. #define CEPH_STAT_CAP_ATIME CEPH_CAP_FILE_SHARED /* fixme */
  406. #define CEPH_STAT_CAP_XATTR CEPH_CAP_XATTR_SHARED
  407. #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN | \
  408. CEPH_CAP_AUTH_SHARED | \
  409. CEPH_CAP_LINK_SHARED | \
  410. CEPH_CAP_FILE_SHARED | \
  411. CEPH_CAP_XATTR_SHARED)
  412. #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED | \
  413. CEPH_CAP_LINK_SHARED | \
  414. CEPH_CAP_XATTR_SHARED | \
  415. CEPH_CAP_FILE_SHARED)
  416. #define CEPH_CAP_ANY_RD (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD | \
  417. CEPH_CAP_FILE_CACHE)
  418. #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL | \
  419. CEPH_CAP_LINK_EXCL | \
  420. CEPH_CAP_XATTR_EXCL | \
  421. CEPH_CAP_FILE_EXCL)
  422. #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER | \
  423. CEPH_CAP_FILE_EXCL)
  424. #define CEPH_CAP_ANY_WR (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
  425. #define CEPH_CAP_ANY (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
  426. CEPH_CAP_ANY_FILE_WR | CEPH_CAP_PIN)
  427. #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
  428. CEPH_LOCK_IXATTR)
  429. int ceph_caps_for_mode(int mode);
  430. enum {
  431. CEPH_CAP_OP_GRANT, /* mds->client grant */
  432. CEPH_CAP_OP_REVOKE, /* mds->client revoke */
  433. CEPH_CAP_OP_TRUNC, /* mds->client trunc notify */
  434. CEPH_CAP_OP_EXPORT, /* mds has exported the cap */
  435. CEPH_CAP_OP_IMPORT, /* mds has imported the cap */
  436. CEPH_CAP_OP_UPDATE, /* client->mds update */
  437. CEPH_CAP_OP_DROP, /* client->mds drop cap bits */
  438. CEPH_CAP_OP_FLUSH, /* client->mds cap writeback */
  439. CEPH_CAP_OP_FLUSH_ACK, /* mds->client flushed */
  440. CEPH_CAP_OP_FLUSHSNAP, /* client->mds flush snapped metadata */
  441. CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
  442. CEPH_CAP_OP_RELEASE, /* client->mds release (clean) cap */
  443. CEPH_CAP_OP_RENEW, /* client->mds renewal request */
  444. };
  445. extern const char *ceph_cap_op_name(int op);
  446. /*
  447. * caps message, used for capability callbacks, acks, requests, etc.
  448. */
  449. struct ceph_mds_caps {
  450. __le32 op; /* CEPH_CAP_OP_* */
  451. __le64 ino, realm;
  452. __le64 cap_id;
  453. __le32 seq, issue_seq;
  454. __le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
  455. __le32 migrate_seq;
  456. __le64 snap_follows;
  457. __le32 snap_trace_len;
  458. __le64 client_tid; /* for FLUSH(SNAP) -> FLUSH(SNAP)_ACK */
  459. /* authlock */
  460. __le32 uid, gid, mode;
  461. /* linklock */
  462. __le32 nlink;
  463. /* xattrlock */
  464. __le32 xattr_len;
  465. __le64 xattr_version;
  466. /* filelock */
  467. __le64 size, max_size, truncate_size;
  468. __le32 truncate_seq;
  469. struct ceph_timespec mtime, atime, ctime;
  470. struct ceph_file_layout layout;
  471. __le32 time_warp_seq;
  472. } __attribute__ ((packed));
  473. /* cap release msg head */
  474. struct ceph_mds_cap_release {
  475. __le32 num; /* number of cap_items that follow */
  476. } __attribute__ ((packed));
  477. struct ceph_mds_cap_item {
  478. __le64 ino;
  479. __le64 cap_id;
  480. __le32 migrate_seq, seq;
  481. } __attribute__ ((packed));
  482. #define CEPH_MDS_LEASE_REVOKE 1 /* mds -> client */
  483. #define CEPH_MDS_LEASE_RELEASE 2 /* client -> mds */
  484. #define CEPH_MDS_LEASE_RENEW 3 /* client <-> mds */
  485. #define CEPH_MDS_LEASE_REVOKE_ACK 4 /* client -> mds */
  486. extern const char *ceph_lease_op_name(int o);
  487. /* lease msg header */
  488. struct ceph_mds_lease {
  489. __u8 action; /* CEPH_MDS_LEASE_* */
  490. __le16 mask; /* which lease */
  491. __le64 ino;
  492. __le64 first, last; /* snap range */
  493. __le32 seq;
  494. __le32 duration_ms; /* duration of renewal */
  495. } __attribute__ ((packed));
  496. /* followed by a __le32+string for dname */
  497. /* client reconnect */
  498. struct ceph_mds_cap_reconnect {
  499. __le64 cap_id;
  500. __le32 wanted;
  501. __le32 issued;
  502. __le64 size;
  503. struct ceph_timespec mtime, atime;
  504. __le64 snaprealm;
  505. __le64 pathbase; /* base ino for our path to this ino */
  506. } __attribute__ ((packed));
  507. /* followed by encoded string */
  508. struct ceph_mds_snaprealm_reconnect {
  509. __le64 ino; /* snap realm base */
  510. __le64 seq; /* snap seq for this snap realm */
  511. __le64 parent; /* parent realm */
  512. } __attribute__ ((packed));
  513. /*
  514. * snaps
  515. */
  516. enum {
  517. CEPH_SNAP_OP_UPDATE, /* CREATE or DESTROY */
  518. CEPH_SNAP_OP_CREATE,
  519. CEPH_SNAP_OP_DESTROY,
  520. CEPH_SNAP_OP_SPLIT,
  521. };
  522. extern const char *ceph_snap_op_name(int o);
  523. /* snap msg header */
  524. struct ceph_mds_snap_head {
  525. __le32 op; /* CEPH_SNAP_OP_* */
  526. __le64 split; /* ino to split off, if any */
  527. __le32 num_split_inos; /* # inos belonging to new child realm */
  528. __le32 num_split_realms; /* # child realms udner new child realm */
  529. __le32 trace_len; /* size of snap trace blob */
  530. } __attribute__ ((packed));
  531. /* followed by split ino list, then split realms, then the trace blob */
  532. /*
  533. * encode info about a snaprealm, as viewed by a client
  534. */
  535. struct ceph_mds_snap_realm {
  536. __le64 ino; /* ino */
  537. __le64 created; /* snap: when created */
  538. __le64 parent; /* ino: parent realm */
  539. __le64 parent_since; /* snap: same parent since */
  540. __le64 seq; /* snap: version */
  541. __le32 num_snaps;
  542. __le32 num_prior_parent_snaps;
  543. } __attribute__ ((packed));
  544. /* followed by my snap list, then prior parent snap list */
  545. #endif