ceph_fs.h 20 KB

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