ceph_fs.h 20 KB

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