ceph_fs.h 22 KB

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