ceph_fs.h 20 KB

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