ceph_fs.h 20 KB

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