xref: /linux-6.15/include/linux/ceph/ceph_fs.h (revision 2f0805d7)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
23d14c5d2SYehuda Sadeh /*
33d14c5d2SYehuda Sadeh  * ceph_fs.h - Ceph constants and data types to share between kernel and
43d14c5d2SYehuda Sadeh  * user space.
53d14c5d2SYehuda Sadeh  *
63d14c5d2SYehuda Sadeh  * Most types in this file are defined as little-endian, and are
73d14c5d2SYehuda Sadeh  * primarily intended to describe data structures that pass over the
83d14c5d2SYehuda Sadeh  * wire or that are stored on disk.
93d14c5d2SYehuda Sadeh  *
103d14c5d2SYehuda Sadeh  * LGPL2
113d14c5d2SYehuda Sadeh  */
123d14c5d2SYehuda Sadeh 
133d14c5d2SYehuda Sadeh #ifndef CEPH_FS_H
143d14c5d2SYehuda Sadeh #define CEPH_FS_H
153d14c5d2SYehuda Sadeh 
16a1ce3928SDavid Howells #include <linux/ceph/msgr.h>
17a1ce3928SDavid Howells #include <linux/ceph/rados.h>
183d14c5d2SYehuda Sadeh 
193d14c5d2SYehuda Sadeh /*
203d14c5d2SYehuda Sadeh  * subprotocol versions.  when specific messages types or high-level
213d14c5d2SYehuda Sadeh  * protocols change, bump the affected components.  we keep rev
223d14c5d2SYehuda Sadeh  * internal cluster protocols separately from the public,
233d14c5d2SYehuda Sadeh  * client-facing protocol.
243d14c5d2SYehuda Sadeh  */
253d14c5d2SYehuda Sadeh #define CEPH_OSDC_PROTOCOL   24 /* server/client */
263d14c5d2SYehuda Sadeh #define CEPH_MDSC_PROTOCOL   32 /* server/client */
273d14c5d2SYehuda Sadeh #define CEPH_MONC_PROTOCOL   15 /* server/client */
283d14c5d2SYehuda Sadeh 
293d14c5d2SYehuda Sadeh 
303d14c5d2SYehuda Sadeh #define CEPH_INO_ROOT   1
313d14c5d2SYehuda Sadeh #define CEPH_INO_CEPH   2            /* hidden .ceph dir */
325ed91587SXiubo Li #define CEPH_INO_GLOBAL_SNAPREALM  3 /* global dummy snaprealm */
333d14c5d2SYehuda Sadeh 
343d14c5d2SYehuda Sadeh /* arbitrary limit on max # of monitors (cluster of 3 is typical) */
353d14c5d2SYehuda Sadeh #define CEPH_MAX_MON   31
363d14c5d2SYehuda Sadeh 
373d14c5d2SYehuda Sadeh /*
387627151eSYan, Zheng  * legacy ceph_file_layoute
393d14c5d2SYehuda Sadeh  */
407627151eSYan, Zheng struct ceph_file_layout_legacy {
413d14c5d2SYehuda Sadeh 	/* file -> object mapping */
423d14c5d2SYehuda Sadeh 	__le32 fl_stripe_unit;     /* stripe unit, in bytes.  must be multiple
433d14c5d2SYehuda Sadeh 				      of page size. */
443d14c5d2SYehuda Sadeh 	__le32 fl_stripe_count;    /* over this many objects */
453d14c5d2SYehuda Sadeh 	__le32 fl_object_size;     /* until objects are this big, then move to
463d14c5d2SYehuda Sadeh 				      new objects */
476c0f3af7SSage Weil 	__le32 fl_cas_hash;        /* UNUSED.  0 = none; 1 = sha256 */
483d14c5d2SYehuda Sadeh 
493d14c5d2SYehuda Sadeh 	/* pg -> disk layout */
506c0f3af7SSage Weil 	__le32 fl_object_stripe_unit;  /* UNUSED.  for per-object parity, if any */
513d14c5d2SYehuda Sadeh 
523d14c5d2SYehuda Sadeh 	/* object -> pg layout */
53dd6f5e10SAlex Elder 	__le32 fl_unused;       /* unused; used to be preferred primary for pg (-1 for none) */
543d14c5d2SYehuda Sadeh 	__le32 fl_pg_pool;      /* namespace, crush ruleset, rep level */
553d14c5d2SYehuda Sadeh } __attribute__ ((packed));
563d14c5d2SYehuda Sadeh 
5730c156d9SYan, Zheng struct ceph_string;
587627151eSYan, Zheng /*
597627151eSYan, Zheng  * ceph_file_layout - describe data layout for a file/inode
607627151eSYan, Zheng  */
617627151eSYan, Zheng struct ceph_file_layout {
627627151eSYan, Zheng 	/* file -> object mapping */
637627151eSYan, Zheng 	u32 stripe_unit;   /* stripe unit, in bytes */
647627151eSYan, Zheng 	u32 stripe_count;  /* over this many objects */
657627151eSYan, Zheng 	u32 object_size;   /* until objects are this big */
667627151eSYan, Zheng 	s64 pool_id;        /* rados pool id */
6730c156d9SYan, Zheng 	struct ceph_string __rcu *pool_ns; /* rados pool namespace */
687627151eSYan, Zheng };
69e8221464SIlya Dryomov 
707627151eSYan, Zheng extern int ceph_file_layout_is_valid(const struct ceph_file_layout *layout);
717627151eSYan, Zheng extern void ceph_file_layout_from_legacy(struct ceph_file_layout *fl,
727627151eSYan, Zheng 				struct ceph_file_layout_legacy *legacy);
737627151eSYan, Zheng extern void ceph_file_layout_to_legacy(struct ceph_file_layout *fl,
747627151eSYan, Zheng 				struct ceph_file_layout_legacy *legacy);
75e8221464SIlya Dryomov 
763d14c5d2SYehuda Sadeh #define CEPH_MIN_STRIPE_UNIT 65536
773d14c5d2SYehuda Sadeh 
786c0f3af7SSage Weil struct ceph_dir_layout {
796c0f3af7SSage Weil 	__u8   dl_dir_hash;   /* see ceph_hash.h for ids */
806c0f3af7SSage Weil 	__u8   dl_unused1;
816c0f3af7SSage Weil 	__u16  dl_unused2;
826c0f3af7SSage Weil 	__u32  dl_unused3;
836c0f3af7SSage Weil } __attribute__ ((packed));
843d14c5d2SYehuda Sadeh 
853d14c5d2SYehuda Sadeh /* crypto algorithms */
863d14c5d2SYehuda Sadeh #define CEPH_CRYPTO_NONE 0x0
873d14c5d2SYehuda Sadeh #define CEPH_CRYPTO_AES  0x1
883d14c5d2SYehuda Sadeh 
893d14c5d2SYehuda Sadeh #define CEPH_AES_IV "cephsageyudagreg"
903d14c5d2SYehuda Sadeh 
913d14c5d2SYehuda Sadeh /* security/authentication protocols */
923d14c5d2SYehuda Sadeh #define CEPH_AUTH_UNKNOWN	0x0
933d14c5d2SYehuda Sadeh #define CEPH_AUTH_NONE	 	0x1
943d14c5d2SYehuda Sadeh #define CEPH_AUTH_CEPHX	 	0x2
953d14c5d2SYehuda Sadeh 
96cd1a677cSIlya Dryomov #define CEPH_AUTH_MODE_NONE		0
97cd1a677cSIlya Dryomov #define CEPH_AUTH_MODE_AUTHORIZER	1
98cd1a677cSIlya Dryomov #define CEPH_AUTH_MODE_MON		10
99cd1a677cSIlya Dryomov 
10000498b99SIlya Dryomov /* msgr2 protocol modes */
10100498b99SIlya Dryomov #define CEPH_CON_MODE_UNKNOWN	0x0
10200498b99SIlya Dryomov #define CEPH_CON_MODE_CRC	0x1
10300498b99SIlya Dryomov #define CEPH_CON_MODE_SECURE	0x2
10400498b99SIlya Dryomov 
1053d14c5d2SYehuda Sadeh #define CEPH_AUTH_UID_DEFAULT ((__u64) -1)
1063d14c5d2SYehuda Sadeh 
10759711f9eSIlya Dryomov const char *ceph_auth_proto_name(int proto);
10800498b99SIlya Dryomov const char *ceph_con_mode_name(int mode);
1093d14c5d2SYehuda Sadeh 
1103d14c5d2SYehuda Sadeh /*********************************************
1113d14c5d2SYehuda Sadeh  * message layer
1123d14c5d2SYehuda Sadeh  */
1133d14c5d2SYehuda Sadeh 
1143d14c5d2SYehuda Sadeh /*
1153d14c5d2SYehuda Sadeh  * message types
1163d14c5d2SYehuda Sadeh  */
1173d14c5d2SYehuda Sadeh 
1183d14c5d2SYehuda Sadeh /* misc */
1193d14c5d2SYehuda Sadeh #define CEPH_MSG_SHUTDOWN               1
1203d14c5d2SYehuda Sadeh #define CEPH_MSG_PING                   2
1213d14c5d2SYehuda Sadeh 
1223d14c5d2SYehuda Sadeh /* client <-> monitor */
1233d14c5d2SYehuda Sadeh #define CEPH_MSG_MON_MAP                4
1243d14c5d2SYehuda Sadeh #define CEPH_MSG_MON_GET_MAP            5
1253d14c5d2SYehuda Sadeh #define CEPH_MSG_STATFS                 13
1263d14c5d2SYehuda Sadeh #define CEPH_MSG_STATFS_REPLY           14
1273d14c5d2SYehuda Sadeh #define CEPH_MSG_MON_SUBSCRIBE          15
1283d14c5d2SYehuda Sadeh #define CEPH_MSG_MON_SUBSCRIBE_ACK      16
1293d14c5d2SYehuda Sadeh #define CEPH_MSG_AUTH			17
1303d14c5d2SYehuda Sadeh #define CEPH_MSG_AUTH_REPLY		18
131dd6f5e10SAlex Elder #define CEPH_MSG_MON_GET_VERSION        19
132dd6f5e10SAlex Elder #define CEPH_MSG_MON_GET_VERSION_REPLY  20
1333d14c5d2SYehuda Sadeh 
1343d14c5d2SYehuda Sadeh /* client <-> mds */
1353d14c5d2SYehuda Sadeh #define CEPH_MSG_MDS_MAP                21
1360cabbd94SYan, Zheng #define CEPH_MSG_FS_MAP_USER            103
1373d14c5d2SYehuda Sadeh 
1383d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_SESSION         22
1393d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_RECONNECT       23
1403d14c5d2SYehuda Sadeh 
1413d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_REQUEST         24
1423d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_REQUEST_FORWARD 25
1433d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_REPLY           26
14418f473b3SXiubo Li #define CEPH_MSG_CLIENT_METRICS         29
1453d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_CAPS            0x310
1463d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_LEASE           0x311
1473d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_SNAP            0x312
1483d14c5d2SYehuda Sadeh #define CEPH_MSG_CLIENT_CAPRELEASE      0x313
149fb18a575SLuis Henriques #define CEPH_MSG_CLIENT_QUOTA           0x314
1503d14c5d2SYehuda Sadeh 
1513d14c5d2SYehuda Sadeh /* pool ops */
1523d14c5d2SYehuda Sadeh #define CEPH_MSG_POOLOP_REPLY           48
1533d14c5d2SYehuda Sadeh #define CEPH_MSG_POOLOP                 49
1543d14c5d2SYehuda Sadeh 
1556305a3b4SDouglas Fuller /* mon commands */
1566305a3b4SDouglas Fuller #define CEPH_MSG_MON_COMMAND            50
1576305a3b4SDouglas Fuller #define CEPH_MSG_MON_COMMAND_ACK        51
1583d14c5d2SYehuda Sadeh 
1593d14c5d2SYehuda Sadeh /* osd */
1603d14c5d2SYehuda Sadeh #define CEPH_MSG_OSD_MAP                41
1613d14c5d2SYehuda Sadeh #define CEPH_MSG_OSD_OP                 42
1623d14c5d2SYehuda Sadeh #define CEPH_MSG_OSD_OPREPLY            43
163483fac71SYehuda Sadeh #define CEPH_MSG_WATCH_NOTIFY           44
164a02a946dSIlya Dryomov #define CEPH_MSG_OSD_BACKOFF            61
165483fac71SYehuda Sadeh 
166483fac71SYehuda Sadeh 
167483fac71SYehuda Sadeh /* watch-notify operations */
168483fac71SYehuda Sadeh enum {
169922dab61SIlya Dryomov 	CEPH_WATCH_EVENT_NOTIFY		  = 1, /* notifying watcher */
170922dab61SIlya Dryomov 	CEPH_WATCH_EVENT_NOTIFY_COMPLETE  = 2, /* notifier notified when done */
171922dab61SIlya Dryomov 	CEPH_WATCH_EVENT_DISCONNECT       = 3, /* we were disconnected */
172483fac71SYehuda Sadeh };
173483fac71SYehuda Sadeh 
1743d14c5d2SYehuda Sadeh 
1753d14c5d2SYehuda Sadeh struct ceph_mon_request_header {
1763d14c5d2SYehuda Sadeh 	__le64 have_version;
1773d14c5d2SYehuda Sadeh 	__le16 session_mon;
1783d14c5d2SYehuda Sadeh 	__le64 session_mon_tid;
1793d14c5d2SYehuda Sadeh } __attribute__ ((packed));
1803d14c5d2SYehuda Sadeh 
1813d14c5d2SYehuda Sadeh struct ceph_mon_statfs {
1823d14c5d2SYehuda Sadeh 	struct ceph_mon_request_header monhdr;
1833d14c5d2SYehuda Sadeh 	struct ceph_fsid fsid;
18406d74376SDouglas Fuller 	__u8 contains_data_pool;
18506d74376SDouglas Fuller 	__le64 data_pool;
1863d14c5d2SYehuda Sadeh } __attribute__ ((packed));
1873d14c5d2SYehuda Sadeh 
1883d14c5d2SYehuda Sadeh struct ceph_statfs {
1893d14c5d2SYehuda Sadeh 	__le64 kb, kb_used, kb_avail;
1903d14c5d2SYehuda Sadeh 	__le64 num_objects;
1913d14c5d2SYehuda Sadeh } __attribute__ ((packed));
1923d14c5d2SYehuda Sadeh 
1933d14c5d2SYehuda Sadeh struct ceph_mon_statfs_reply {
1943d14c5d2SYehuda Sadeh 	struct ceph_fsid fsid;
1953d14c5d2SYehuda Sadeh 	__le64 version;
1963d14c5d2SYehuda Sadeh 	struct ceph_statfs st;
1973d14c5d2SYehuda Sadeh } __attribute__ ((packed));
1983d14c5d2SYehuda Sadeh 
1996305a3b4SDouglas Fuller struct ceph_mon_command {
2006305a3b4SDouglas Fuller 	struct ceph_mon_request_header monhdr;
2016305a3b4SDouglas Fuller 	struct ceph_fsid fsid;
2026305a3b4SDouglas Fuller 	__le32 num_strs;         /* always 1 */
2036305a3b4SDouglas Fuller 	__le32 str_len;
2046305a3b4SDouglas Fuller 	char str[];
2056305a3b4SDouglas Fuller } __attribute__ ((packed));
2066305a3b4SDouglas Fuller 
2073d14c5d2SYehuda Sadeh struct ceph_osd_getmap {
2083d14c5d2SYehuda Sadeh 	struct ceph_mon_request_header monhdr;
2093d14c5d2SYehuda Sadeh 	struct ceph_fsid fsid;
2103d14c5d2SYehuda Sadeh 	__le32 start;
2113d14c5d2SYehuda Sadeh } __attribute__ ((packed));
2123d14c5d2SYehuda Sadeh 
2133d14c5d2SYehuda Sadeh struct ceph_mds_getmap {
2143d14c5d2SYehuda Sadeh 	struct ceph_mon_request_header monhdr;
2153d14c5d2SYehuda Sadeh 	struct ceph_fsid fsid;
2163d14c5d2SYehuda Sadeh } __attribute__ ((packed));
2173d14c5d2SYehuda Sadeh 
2183d14c5d2SYehuda Sadeh struct ceph_client_mount {
2193d14c5d2SYehuda Sadeh 	struct ceph_mon_request_header monhdr;
2203d14c5d2SYehuda Sadeh } __attribute__ ((packed));
2213d14c5d2SYehuda Sadeh 
222483fac71SYehuda Sadeh #define CEPH_SUBSCRIBE_ONETIME    1  /* i want only 1 update after have */
223483fac71SYehuda Sadeh 
2243d14c5d2SYehuda Sadeh struct ceph_mon_subscribe_item {
22582dcabadSIlya Dryomov 	__le64 start;
22682dcabadSIlya Dryomov 	__u8 flags;
2273d14c5d2SYehuda Sadeh } __attribute__ ((packed));
2283d14c5d2SYehuda Sadeh 
2293d14c5d2SYehuda Sadeh struct ceph_mon_subscribe_ack {
2303d14c5d2SYehuda Sadeh 	__le32 duration;         /* seconds */
2313d14c5d2SYehuda Sadeh 	struct ceph_fsid fsid;
2323d14c5d2SYehuda Sadeh } __attribute__ ((packed));
2333d14c5d2SYehuda Sadeh 
234737cc81eSIlya Dryomov #define CEPH_FS_CLUSTER_ID_NONE  -1
235737cc81eSIlya Dryomov 
2363d14c5d2SYehuda Sadeh /*
237dd6f5e10SAlex Elder  * mdsmap flags
238dd6f5e10SAlex Elder  */
239dd6f5e10SAlex Elder #define CEPH_MDSMAP_DOWN    (1<<0)  /* cluster deliberately down */
240dd6f5e10SAlex Elder 
241dd6f5e10SAlex Elder /*
2423d14c5d2SYehuda Sadeh  * mds states
2433d14c5d2SYehuda Sadeh  *   > 0 -> in
2443d14c5d2SYehuda Sadeh  *  <= 0 -> out
2453d14c5d2SYehuda Sadeh  */
2463d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_DNE          0  /* down, does not exist. */
2473d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_STOPPED     -1  /* down, once existed, but no subtrees.
2483d14c5d2SYehuda Sadeh 					  empty log. */
2493d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_BOOT        -4  /* up, boot announcement. */
2503d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_STANDBY     -5  /* up, idle.  waiting for assignment. */
2513d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_CREATING    -6  /* up, creating MDS instance. */
2523d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_STARTING    -7  /* up, starting previously stopped mds */
2533d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_STANDBY_REPLAY -8 /* up, tailing active node's journal */
254dd6f5e10SAlex Elder #define CEPH_MDS_STATE_REPLAYONCE   -9 /* up, replaying an active node's journal */
2553d14c5d2SYehuda Sadeh 
2563d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_REPLAY       8  /* up, replaying journal. */
2573d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_RESOLVE      9  /* up, disambiguating distributed
2583d14c5d2SYehuda Sadeh 					  operations (import, rename, etc.) */
2593d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_RECONNECT    10 /* up, reconnect to clients */
2603d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_REJOIN       11 /* up, rejoining distributed cache */
2613d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_CLIENTREPLAY 12 /* up, replaying client operations */
2623d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_ACTIVE       13 /* up, active */
2633d14c5d2SYehuda Sadeh #define CEPH_MDS_STATE_STOPPING     14 /* up, but exporting metadata */
2643d14c5d2SYehuda Sadeh 
2653d14c5d2SYehuda Sadeh extern const char *ceph_mds_state_name(int s);
2663d14c5d2SYehuda Sadeh 
2673d14c5d2SYehuda Sadeh 
2683d14c5d2SYehuda Sadeh /*
2693d14c5d2SYehuda Sadeh  * metadata lock types.
2703d14c5d2SYehuda Sadeh  *  - these are bitmasks.. we can compose them
2713d14c5d2SYehuda Sadeh  *  - they also define the lock ordering by the MDS
2723d14c5d2SYehuda Sadeh  *  - a few of these are internal to the mds
2733d14c5d2SYehuda Sadeh  */
2743d14c5d2SYehuda Sadeh #define CEPH_LOCK_DVERSION    1
2753d14c5d2SYehuda Sadeh #define CEPH_LOCK_DN          2
2763d14c5d2SYehuda Sadeh #define CEPH_LOCK_ISNAP       16
2773d14c5d2SYehuda Sadeh #define CEPH_LOCK_IVERSION    32    /* mds internal */
2783d14c5d2SYehuda Sadeh #define CEPH_LOCK_IFILE       64
2793d14c5d2SYehuda Sadeh #define CEPH_LOCK_IAUTH       128
2803d14c5d2SYehuda Sadeh #define CEPH_LOCK_ILINK       256
2813d14c5d2SYehuda Sadeh #define CEPH_LOCK_IDFT        512   /* dir frag tree */
2823d14c5d2SYehuda Sadeh #define CEPH_LOCK_INEST       1024  /* mds internal */
2833d14c5d2SYehuda Sadeh #define CEPH_LOCK_IXATTR      2048
2843d14c5d2SYehuda Sadeh #define CEPH_LOCK_IFLOCK      4096  /* advisory file locks */
2853d14c5d2SYehuda Sadeh #define CEPH_LOCK_INO         8192  /* immutable inode bits; not a lock */
286dd6f5e10SAlex Elder #define CEPH_LOCK_IPOLICY     16384 /* policy lock on dirs. MDS internal */
2873d14c5d2SYehuda Sadeh 
2883d14c5d2SYehuda Sadeh /* client_session ops */
2893d14c5d2SYehuda Sadeh enum {
2903d14c5d2SYehuda Sadeh 	CEPH_SESSION_REQUEST_OPEN,
2913d14c5d2SYehuda Sadeh 	CEPH_SESSION_OPEN,
2923d14c5d2SYehuda Sadeh 	CEPH_SESSION_REQUEST_CLOSE,
2933d14c5d2SYehuda Sadeh 	CEPH_SESSION_CLOSE,
2943d14c5d2SYehuda Sadeh 	CEPH_SESSION_REQUEST_RENEWCAPS,
2953d14c5d2SYehuda Sadeh 	CEPH_SESSION_RENEWCAPS,
2963d14c5d2SYehuda Sadeh 	CEPH_SESSION_STALE,
2973d14c5d2SYehuda Sadeh 	CEPH_SESSION_RECALL_STATE,
298186e4f7aSYan, Zheng 	CEPH_SESSION_FLUSHMSG,
299186e4f7aSYan, Zheng 	CEPH_SESSION_FLUSHMSG_ACK,
30003f4fcb0SYan, Zheng 	CEPH_SESSION_FORCE_RO,
301fcff415cSYan, Zheng 	CEPH_SESSION_REJECT,
302d095559cSXiubo Li 	CEPH_SESSION_REQUEST_FLUSH_MDLOG,
3033d14c5d2SYehuda Sadeh };
3043d14c5d2SYehuda Sadeh 
305e1c9788cSKotresh HR #define CEPH_SESSION_BLOCKLISTED	(1 << 0)  /* session blocklisted */
306e1c9788cSKotresh HR 
3073d14c5d2SYehuda Sadeh extern const char *ceph_session_op_name(int op);
3083d14c5d2SYehuda Sadeh 
3093d14c5d2SYehuda Sadeh struct ceph_mds_session_head {
3103d14c5d2SYehuda Sadeh 	__le32 op;
3113d14c5d2SYehuda Sadeh 	__le64 seq;
3123d14c5d2SYehuda Sadeh 	struct ceph_timespec stamp;
3133d14c5d2SYehuda Sadeh 	__le32 max_caps, max_leases;
3143d14c5d2SYehuda Sadeh } __attribute__ ((packed));
3153d14c5d2SYehuda Sadeh 
3163d14c5d2SYehuda Sadeh /* client_request */
3173d14c5d2SYehuda Sadeh /*
3183d14c5d2SYehuda Sadeh  * metadata ops.
3193d14c5d2SYehuda Sadeh  *  & 0x001000 -> write op
3203d14c5d2SYehuda Sadeh  *  & 0x010000 -> follow symlink (e.g. stat(), not lstat()).
3213d14c5d2SYehuda Sadeh  &  & 0x100000 -> use weird ino/path trace
3223d14c5d2SYehuda Sadeh  */
3233d14c5d2SYehuda Sadeh #define CEPH_MDS_OP_WRITE        0x001000
3243d14c5d2SYehuda Sadeh enum {
3253d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LOOKUP     = 0x00100,
3263d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_GETATTR    = 0x00101,
3273d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LOOKUPHASH = 0x00102,
3283d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
3293c454cf2SSage Weil 	CEPH_MDS_OP_LOOKUPINO  = 0x00104,
33019913b4eSYan, Zheng 	CEPH_MDS_OP_LOOKUPNAME = 0x00105,
3316ddf5f16SMilind Changire 	CEPH_MDS_OP_GETVXATTR  = 0x00106,
3323d14c5d2SYehuda Sadeh 
3333d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_SETXATTR   = 0x01105,
3343d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_RMXATTR    = 0x01106,
3353d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_SETLAYOUT  = 0x01107,
3363d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_SETATTR    = 0x01108,
3373d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_SETFILELOCK= 0x01109,
3383d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_GETFILELOCK= 0x00110,
339571dba52SGreg Farnum 	CEPH_MDS_OP_SETDIRLAYOUT=0x0110a,
3403d14c5d2SYehuda Sadeh 
3413d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_MKNOD      = 0x01201,
3423d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LINK       = 0x01202,
3433d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_UNLINK     = 0x01203,
3443d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_RENAME     = 0x01204,
3453d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_MKDIR      = 0x01220,
3463d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_RMDIR      = 0x01221,
3473d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_SYMLINK    = 0x01222,
3483d14c5d2SYehuda Sadeh 
3493d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_CREATE     = 0x01301,
3503d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_OPEN       = 0x00302,
3513d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_READDIR    = 0x00305,
3523d14c5d2SYehuda Sadeh 
3533d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LOOKUPSNAP = 0x00400,
3543d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_MKSNAP     = 0x01400,
3553d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_RMSNAP     = 0x01401,
3563d14c5d2SYehuda Sadeh 	CEPH_MDS_OP_LSSNAP     = 0x00402,
3570ea611a3SYan, Zheng 	CEPH_MDS_OP_RENAMESNAP = 0x01403,
3583d14c5d2SYehuda Sadeh };
3593d14c5d2SYehuda Sadeh 
3605ccd8530SChristian Brauner #define IS_CEPH_MDS_OP_NEWINODE(op) (op == CEPH_MDS_OP_CREATE     || \
3615ccd8530SChristian Brauner 				     op == CEPH_MDS_OP_MKNOD      || \
3625ccd8530SChristian Brauner 				     op == CEPH_MDS_OP_MKDIR      || \
3635ccd8530SChristian Brauner 				     op == CEPH_MDS_OP_SYMLINK)
3645ccd8530SChristian Brauner 
3653d14c5d2SYehuda Sadeh extern const char *ceph_mds_op_name(int op);
3663d14c5d2SYehuda Sadeh 
3672d332d5bSJeff Layton #define CEPH_SETATTR_MODE              (1 << 0)
3682d332d5bSJeff Layton #define CEPH_SETATTR_UID               (1 << 1)
3692d332d5bSJeff Layton #define CEPH_SETATTR_GID               (1 << 2)
3702d332d5bSJeff Layton #define CEPH_SETATTR_MTIME             (1 << 3)
3712d332d5bSJeff Layton #define CEPH_SETATTR_ATIME             (1 << 4)
3722d332d5bSJeff Layton #define CEPH_SETATTR_SIZE              (1 << 5)
3732d332d5bSJeff Layton #define CEPH_SETATTR_CTIME             (1 << 6)
3742d332d5bSJeff Layton #define CEPH_SETATTR_MTIME_NOW         (1 << 7)
3752d332d5bSJeff Layton #define CEPH_SETATTR_ATIME_NOW         (1 << 8)
3762d332d5bSJeff Layton #define CEPH_SETATTR_BTIME             (1 << 9)
3772d332d5bSJeff Layton #define CEPH_SETATTR_KILL_SGUID        (1 << 10)
3782d332d5bSJeff Layton #define CEPH_SETATTR_FSCRYPT_AUTH      (1 << 11)
3792d332d5bSJeff Layton #define CEPH_SETATTR_FSCRYPT_FILE      (1 << 12)
3803d14c5d2SYehuda Sadeh 
381dd6f5e10SAlex Elder /*
382dd6f5e10SAlex Elder  * Ceph setxattr request flags.
383dd6f5e10SAlex Elder  */
384bcdfeb2eSYan, Zheng #define CEPH_XATTR_CREATE  (1 << 0)
385bcdfeb2eSYan, Zheng #define CEPH_XATTR_REPLACE (1 << 1)
386bcdfeb2eSYan, Zheng #define CEPH_XATTR_REMOVE  (1 << 31)
387dd6f5e10SAlex Elder 
388956d39d6SYan, Zheng /*
389956d39d6SYan, Zheng  * readdir request flags;
390956d39d6SYan, Zheng  */
391956d39d6SYan, Zheng #define CEPH_READDIR_REPLY_BITFLAGS	(1<<0)
392956d39d6SYan, Zheng 
393956d39d6SYan, Zheng /*
394956d39d6SYan, Zheng  * readdir reply flags.
395956d39d6SYan, Zheng  */
396956d39d6SYan, Zheng #define CEPH_READDIR_FRAG_END		(1<<0)
397956d39d6SYan, Zheng #define CEPH_READDIR_FRAG_COMPLETE	(1<<8)
398f3c4ebe6SYan, Zheng #define CEPH_READDIR_HASH_ORDER		(1<<9)
39979162547SYan, Zheng #define CEPH_READDIR_OFFSET_HASH	(1<<10)
400956d39d6SYan, Zheng 
401f775ff7dSAlexander Graf /*
402f775ff7dSAlexander Graf  * open request flags
403f775ff7dSAlexander Graf  */
404f775ff7dSAlexander Graf #define CEPH_O_RDONLY		00000000
405f775ff7dSAlexander Graf #define CEPH_O_WRONLY		00000001
406f775ff7dSAlexander Graf #define CEPH_O_RDWR		00000002
407f775ff7dSAlexander Graf #define CEPH_O_CREAT		00000100
408f775ff7dSAlexander Graf #define CEPH_O_EXCL		00000200
409f775ff7dSAlexander Graf #define CEPH_O_TRUNC		00001000
410f775ff7dSAlexander Graf #define CEPH_O_DIRECTORY	00200000
411f775ff7dSAlexander Graf #define CEPH_O_NOFOLLOW		00400000
412f775ff7dSAlexander Graf 
4133d14c5d2SYehuda Sadeh union ceph_mds_request_args {
4143d14c5d2SYehuda Sadeh 	struct {
4153d14c5d2SYehuda Sadeh 		__le32 mask;                 /* CEPH_CAP_* */
4163d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) getattr;
4173d14c5d2SYehuda Sadeh 	struct {
4183d14c5d2SYehuda Sadeh 		__le32 mode;
4193d14c5d2SYehuda Sadeh 		__le32 uid;
4203d14c5d2SYehuda Sadeh 		__le32 gid;
4213d14c5d2SYehuda Sadeh 		struct ceph_timespec mtime;
4223d14c5d2SYehuda Sadeh 		struct ceph_timespec atime;
4233d14c5d2SYehuda Sadeh 		__le64 size, old_size;       /* old_size needed by truncate */
4243d14c5d2SYehuda Sadeh 		__le32 mask;                 /* CEPH_SETATTR_* */
4253d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) setattr;
4263d14c5d2SYehuda Sadeh 	struct {
4273d14c5d2SYehuda Sadeh 		__le32 frag;                 /* which dir fragment */
4283d14c5d2SYehuda Sadeh 		__le32 max_entries;          /* how many dentries to grab */
4293d14c5d2SYehuda Sadeh 		__le32 max_bytes;
430956d39d6SYan, Zheng 		__le16 flags;
43179162547SYan, Zheng 		__le32 offset_hash;
4323d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) readdir;
4333d14c5d2SYehuda Sadeh 	struct {
4343d14c5d2SYehuda Sadeh 		__le32 mode;
4353d14c5d2SYehuda Sadeh 		__le32 rdev;
4363d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) mknod;
4373d14c5d2SYehuda Sadeh 	struct {
4383d14c5d2SYehuda Sadeh 		__le32 mode;
4393d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) mkdir;
4403d14c5d2SYehuda Sadeh 	struct {
4413d14c5d2SYehuda Sadeh 		__le32 flags;
4423d14c5d2SYehuda Sadeh 		__le32 mode;
4433d14c5d2SYehuda Sadeh 		__le32 stripe_unit;          /* layout for newly created file */
4443d14c5d2SYehuda Sadeh 		__le32 stripe_count;         /* ... */
4453d14c5d2SYehuda Sadeh 		__le32 object_size;
446b53aca4bSXiubo Li 		__le32 pool;
447315f2408SYan, Zheng 		__le32 mask;                 /* CEPH_CAP_* */
448b53aca4bSXiubo Li 		__le64 old_size;
4493d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) open;
4503d14c5d2SYehuda Sadeh 	struct {
4513d14c5d2SYehuda Sadeh 		__le32 flags;
452968cd14eSXiubo Li 		__le32 osdmap_epoch; /* used for setting file/dir layouts */
4533d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) setxattr;
4543d14c5d2SYehuda Sadeh 	struct {
4557627151eSYan, Zheng 		struct ceph_file_layout_legacy layout;
4563d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) setlayout;
4573d14c5d2SYehuda Sadeh 	struct {
4583d14c5d2SYehuda Sadeh 		__u8 rule; /* currently fcntl or flock */
4593d14c5d2SYehuda Sadeh 		__u8 type; /* shared, exclusive, remove*/
460eb13e832SYan, Zheng 		__le64 owner; /* owner of the lock */
4613d14c5d2SYehuda Sadeh 		__le64 pid; /* process id requesting the lock */
4623d14c5d2SYehuda Sadeh 		__le64 start; /* initial location to lock */
4633d14c5d2SYehuda Sadeh 		__le64 length; /* num bytes to lock from start */
4643d14c5d2SYehuda Sadeh 		__u8 wait; /* will caller wait for lock to become available? */
4653d14c5d2SYehuda Sadeh 	} __attribute__ ((packed)) filelock_change;
466570df4e9SYan, Zheng 	struct {
467570df4e9SYan, Zheng 		__le32 mask;                 /* CEPH_CAP_* */
468570df4e9SYan, Zheng 		__le64 snapid;
469570df4e9SYan, Zheng 		__le64 parent;
470570df4e9SYan, Zheng 		__le32 hash;
471570df4e9SYan, Zheng 	} __attribute__ ((packed)) lookupino;
4723d14c5d2SYehuda Sadeh } __attribute__ ((packed));
4733d14c5d2SYehuda Sadeh 
4744f1ddb1eSJeff Layton union ceph_mds_request_args_ext {
4754f1ddb1eSJeff Layton 	union ceph_mds_request_args old;
4764f1ddb1eSJeff Layton 	struct {
4774f1ddb1eSJeff Layton 		__le32 mode;
4784f1ddb1eSJeff Layton 		__le32 uid;
4794f1ddb1eSJeff Layton 		__le32 gid;
4804f1ddb1eSJeff Layton 		struct ceph_timespec mtime;
4814f1ddb1eSJeff Layton 		struct ceph_timespec atime;
4824f1ddb1eSJeff Layton 		__le64 size, old_size;       /* old_size needed by truncate */
4834f1ddb1eSJeff Layton 		__le32 mask;                 /* CEPH_SETATTR_* */
4844f1ddb1eSJeff Layton 		struct ceph_timespec btime;
4854f1ddb1eSJeff Layton 	} __attribute__ ((packed)) setattr_ext;
4864f1ddb1eSJeff Layton };
4874f1ddb1eSJeff Layton 
4883d14c5d2SYehuda Sadeh #define CEPH_MDS_FLAG_REPLAY		1 /* this is a replayed op */
4893d14c5d2SYehuda Sadeh #define CEPH_MDS_FLAG_WANT_DENTRY	2 /* want dentry in reply */
4903bb48b41SJeff Layton #define CEPH_MDS_FLAG_ASYNC		4 /* request is asynchronous */
4913d14c5d2SYehuda Sadeh 
492ce0d5bd3SXiubo Li struct ceph_mds_request_head_legacy {
4933d14c5d2SYehuda Sadeh 	__le64 oldest_client_tid;
4943d14c5d2SYehuda Sadeh 	__le32 mdsmap_epoch;           /* on client */
4953d14c5d2SYehuda Sadeh 	__le32 flags;                  /* CEPH_MDS_FLAG_* */
4963d14c5d2SYehuda Sadeh 	__u8 num_retry, num_fwd;       /* count retry, fwd attempts */
4973d14c5d2SYehuda Sadeh 	__le16 num_releases;           /* # include cap/lease release records */
4983d14c5d2SYehuda Sadeh 	__le32 op;                     /* mds op code */
4993d14c5d2SYehuda Sadeh 	__le32 caller_uid, caller_gid;
5003d14c5d2SYehuda Sadeh 	__le64 ino;                    /* use this ino for openc, mkdir, mknod,
5013d14c5d2SYehuda Sadeh 					  etc. (if replaying) */
5023d14c5d2SYehuda Sadeh 	union ceph_mds_request_args args;
5033d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5043d14c5d2SYehuda Sadeh 
5055ccd8530SChristian Brauner #define CEPH_MDS_REQUEST_HEAD_VERSION  3
5064f1ddb1eSJeff Layton 
507ce0d5bd3SXiubo Li struct ceph_mds_request_head {
508ce0d5bd3SXiubo Li 	__le16 version;                /* struct version */
509ce0d5bd3SXiubo Li 	__le64 oldest_client_tid;
510ce0d5bd3SXiubo Li 	__le32 mdsmap_epoch;           /* on client */
511ce0d5bd3SXiubo Li 	__le32 flags;                  /* CEPH_MDS_FLAG_* */
512ce0d5bd3SXiubo Li 	__u8 num_retry, num_fwd;       /* legacy count retry and fwd attempts */
513ce0d5bd3SXiubo Li 	__le16 num_releases;           /* # include cap/lease release records */
514ce0d5bd3SXiubo Li 	__le32 op;                     /* mds op code */
515ce0d5bd3SXiubo Li 	__le32 caller_uid, caller_gid;
516ce0d5bd3SXiubo Li 	__le64 ino;                    /* use this ino for openc, mkdir, mknod,
517ce0d5bd3SXiubo Li 					  etc. (if replaying) */
518ce0d5bd3SXiubo Li 	union ceph_mds_request_args_ext args;
519ce0d5bd3SXiubo Li 
520ce0d5bd3SXiubo Li 	__le32 ext_num_retry;          /* new count retry attempts */
521ce0d5bd3SXiubo Li 	__le32 ext_num_fwd;            /* new count fwd attempts */
5225ccd8530SChristian Brauner 
5235ccd8530SChristian Brauner 	__le32 struct_len;             /* to store size of struct ceph_mds_request_head */
5245ccd8530SChristian Brauner 	__le32 owner_uid, owner_gid;   /* used for OPs which create inodes */
525ce0d5bd3SXiubo Li } __attribute__ ((packed));
526ce0d5bd3SXiubo Li 
5273d14c5d2SYehuda Sadeh /* cap/lease release record */
5283d14c5d2SYehuda Sadeh struct ceph_mds_request_release {
5293d14c5d2SYehuda Sadeh 	__le64 ino, cap_id;            /* ino and unique cap id */
5303d14c5d2SYehuda Sadeh 	__le32 caps, wanted;           /* new issued, wanted */
5313d14c5d2SYehuda Sadeh 	__le32 seq, issue_seq, mseq;
5323d14c5d2SYehuda Sadeh 	__le32 dname_seq;              /* if releasing a dentry lease, a */
5333d14c5d2SYehuda Sadeh 	__le32 dname_len;              /* string follows. */
5343d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5353d14c5d2SYehuda Sadeh 
5363d14c5d2SYehuda Sadeh /* client reply */
5373d14c5d2SYehuda Sadeh struct ceph_mds_reply_head {
5383d14c5d2SYehuda Sadeh 	__le32 op;
5393d14c5d2SYehuda Sadeh 	__le32 result;
5403d14c5d2SYehuda Sadeh 	__le32 mdsmap_epoch;
5413d14c5d2SYehuda Sadeh 	__u8 safe;                     /* true if committed to disk */
5423d14c5d2SYehuda Sadeh 	__u8 is_dentry, is_target;     /* true if dentry, target inode records
5433d14c5d2SYehuda Sadeh 					  are included with reply */
5443d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5453d14c5d2SYehuda Sadeh 
5463d14c5d2SYehuda Sadeh /* one for each node split */
5473d14c5d2SYehuda Sadeh struct ceph_frag_tree_split {
5483d14c5d2SYehuda Sadeh 	__le32 frag;                   /* this frag splits... */
5493d14c5d2SYehuda Sadeh 	__le32 by;                     /* ...by this many bits */
5503d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5513d14c5d2SYehuda Sadeh 
5523d14c5d2SYehuda Sadeh struct ceph_frag_tree_head {
5533d14c5d2SYehuda Sadeh 	__le32 nsplits;                /* num ceph_frag_tree_split records */
5543d14c5d2SYehuda Sadeh 	struct ceph_frag_tree_split splits[];
5553d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5563d14c5d2SYehuda Sadeh 
5573d14c5d2SYehuda Sadeh /* capability issue, for bundling with mds reply */
5583d14c5d2SYehuda Sadeh struct ceph_mds_reply_cap {
5593d14c5d2SYehuda Sadeh 	__le32 caps, wanted;           /* caps issued, wanted */
5603d14c5d2SYehuda Sadeh 	__le64 cap_id;
5613d14c5d2SYehuda Sadeh 	__le32 seq, mseq;
5623d14c5d2SYehuda Sadeh 	__le64 realm;                  /* snap realm */
5633d14c5d2SYehuda Sadeh 	__u8 flags;                    /* CEPH_CAP_FLAG_* */
5643d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5653d14c5d2SYehuda Sadeh 
5664ee6a914SYan, Zheng #define CEPH_CAP_FLAG_AUTH	(1 << 0)  /* cap is issued by auth mds */
5674ee6a914SYan, Zheng #define CEPH_CAP_FLAG_RELEASE	(1 << 1)  /* release the cap */
5683d14c5d2SYehuda Sadeh 
5693d14c5d2SYehuda Sadeh /* inode record, for bundling with mds reply */
5703d14c5d2SYehuda Sadeh struct ceph_mds_reply_inode {
5713d14c5d2SYehuda Sadeh 	__le64 ino;
5723d14c5d2SYehuda Sadeh 	__le64 snapid;
5733d14c5d2SYehuda Sadeh 	__le32 rdev;
5743d14c5d2SYehuda Sadeh 	__le64 version;                /* inode version */
5753d14c5d2SYehuda Sadeh 	__le64 xattr_version;          /* version for xattr blob */
5763d14c5d2SYehuda Sadeh 	struct ceph_mds_reply_cap cap; /* caps issued for this inode */
5777627151eSYan, Zheng 	struct ceph_file_layout_legacy layout;
5783d14c5d2SYehuda Sadeh 	struct ceph_timespec ctime, mtime, atime;
5793d14c5d2SYehuda Sadeh 	__le32 time_warp_seq;
5803d14c5d2SYehuda Sadeh 	__le64 size, max_size, truncate_size;
5813d14c5d2SYehuda Sadeh 	__le32 truncate_seq;
5823d14c5d2SYehuda Sadeh 	__le32 mode, uid, gid;
5833d14c5d2SYehuda Sadeh 	__le32 nlink;
5843d14c5d2SYehuda Sadeh 	__le64 files, subdirs, rbytes, rfiles, rsubdirs;  /* dir stats */
5853d14c5d2SYehuda Sadeh 	struct ceph_timespec rctime;
5863d14c5d2SYehuda Sadeh 	struct ceph_frag_tree_head fragtree;  /* (must be at end of struct) */
5873d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5886c0f3af7SSage Weil /* followed by frag array, symlink string, dir layout, xattr blob */
5893d14c5d2SYehuda Sadeh 
5903d14c5d2SYehuda Sadeh /* reply_lease follows dname, and reply_inode */
5913d14c5d2SYehuda Sadeh struct ceph_mds_reply_lease {
5923d14c5d2SYehuda Sadeh 	__le16 mask;            /* lease type(s) */
5933d14c5d2SYehuda Sadeh 	__le32 duration_ms;     /* lease duration */
5943d14c5d2SYehuda Sadeh 	__le32 seq;
5953d14c5d2SYehuda Sadeh } __attribute__ ((packed));
5963d14c5d2SYehuda Sadeh 
597f5e17aedSJeff Layton #define CEPH_LEASE_VALID        (1 | 2) /* old and new bit values */
598f5e17aedSJeff Layton #define CEPH_LEASE_PRIMARY_LINK 4       /* primary linkage */
599f5e17aedSJeff Layton 
6003d14c5d2SYehuda Sadeh struct ceph_mds_reply_dirfrag {
6013d14c5d2SYehuda Sadeh 	__le32 frag;            /* fragment */
6023d14c5d2SYehuda Sadeh 	__le32 auth;            /* auth mds, if this is a delegation point */
6033d14c5d2SYehuda Sadeh 	__le32 ndist;           /* number of mds' this is replicated on */
6043d14c5d2SYehuda Sadeh 	__le32 dist[];
6053d14c5d2SYehuda Sadeh } __attribute__ ((packed));
6063d14c5d2SYehuda Sadeh 
6073d14c5d2SYehuda Sadeh #define CEPH_LOCK_FCNTL		1
6083d14c5d2SYehuda Sadeh #define CEPH_LOCK_FLOCK		2
6099280be24SYan, Zheng #define CEPH_LOCK_FCNTL_INTR    3
6109280be24SYan, Zheng #define CEPH_LOCK_FLOCK_INTR    4
6119280be24SYan, Zheng 
6123d14c5d2SYehuda Sadeh 
6133d14c5d2SYehuda Sadeh #define CEPH_LOCK_SHARED   1
6143d14c5d2SYehuda Sadeh #define CEPH_LOCK_EXCL     2
6153d14c5d2SYehuda Sadeh #define CEPH_LOCK_UNLOCK   4
6163d14c5d2SYehuda Sadeh 
6173d14c5d2SYehuda Sadeh struct ceph_filelock {
6183d14c5d2SYehuda Sadeh 	__le64 start;/* file offset to start lock at */
6193d14c5d2SYehuda Sadeh 	__le64 length; /* num bytes to lock; 0 for all following start */
6203d14c5d2SYehuda Sadeh 	__le64 client; /* which client holds the lock */
621eb13e832SYan, Zheng 	__le64 owner; /* owner the lock */
6223d14c5d2SYehuda Sadeh 	__le64 pid; /* process id holding the lock on the client */
6233d14c5d2SYehuda Sadeh 	__u8 type; /* shared lock, exclusive lock, or unlock */
6243d14c5d2SYehuda Sadeh } __attribute__ ((packed));
6253d14c5d2SYehuda Sadeh 
6263d14c5d2SYehuda Sadeh 
6273d14c5d2SYehuda Sadeh /* file access modes */
6283d14c5d2SYehuda Sadeh #define CEPH_FILE_MODE_PIN        0
6293d14c5d2SYehuda Sadeh #define CEPH_FILE_MODE_RD         1
6303d14c5d2SYehuda Sadeh #define CEPH_FILE_MODE_WR         2
6313d14c5d2SYehuda Sadeh #define CEPH_FILE_MODE_RDWR       3  /* RD | WR */
6323d14c5d2SYehuda Sadeh #define CEPH_FILE_MODE_LAZY       4  /* lazy io */
633774a6a11SYan, Zheng #define CEPH_FILE_MODE_BITS       4
634719a2514SYan, Zheng #define CEPH_FILE_MODE_MASK       ((1 << CEPH_FILE_MODE_BITS) - 1)
6353d14c5d2SYehuda Sadeh 
6363d14c5d2SYehuda Sadeh int ceph_flags_to_mode(int flags);
6373d14c5d2SYehuda Sadeh 
63831c542a1SYan, Zheng #define CEPH_INLINE_NONE	((__u64)-1)
6393d14c5d2SYehuda Sadeh 
6403d14c5d2SYehuda Sadeh /* capability bits */
6413d14c5d2SYehuda Sadeh #define CEPH_CAP_PIN         1  /* no specific capabilities beyond the pin */
6423d14c5d2SYehuda Sadeh 
6433d14c5d2SYehuda Sadeh /* generic cap bits */
6443d14c5d2SYehuda Sadeh #define CEPH_CAP_GSHARED     1  /* client can reads */
6453d14c5d2SYehuda Sadeh #define CEPH_CAP_GEXCL       2  /* client can read and update */
6463d14c5d2SYehuda Sadeh #define CEPH_CAP_GCACHE      4  /* (file) client can cache reads */
6473d14c5d2SYehuda Sadeh #define CEPH_CAP_GRD         8  /* (file) client can read */
6483d14c5d2SYehuda Sadeh #define CEPH_CAP_GWR        16  /* (file) client can write */
6493d14c5d2SYehuda Sadeh #define CEPH_CAP_GBUFFER    32  /* (file) client can buffer writes */
6503d14c5d2SYehuda Sadeh #define CEPH_CAP_GWREXTEND  64  /* (file) client can extend EOF */
6513d14c5d2SYehuda Sadeh #define CEPH_CAP_GLAZYIO   128  /* (file) client can perform lazy io */
6523d14c5d2SYehuda Sadeh 
653dd6f5e10SAlex Elder #define CEPH_CAP_SIMPLE_BITS  2
654dd6f5e10SAlex Elder #define CEPH_CAP_FILE_BITS    8
655dd6f5e10SAlex Elder 
6563d14c5d2SYehuda Sadeh /* per-lock shift */
6573d14c5d2SYehuda Sadeh #define CEPH_CAP_SAUTH      2
6583d14c5d2SYehuda Sadeh #define CEPH_CAP_SLINK      4
6593d14c5d2SYehuda Sadeh #define CEPH_CAP_SXATTR     6
6603d14c5d2SYehuda Sadeh #define CEPH_CAP_SFILE      8
6613d14c5d2SYehuda Sadeh #define CEPH_CAP_SFLOCK    20
6623d14c5d2SYehuda Sadeh 
6633d14c5d2SYehuda Sadeh #define CEPH_CAP_BITS      22
6643d14c5d2SYehuda Sadeh 
6653d14c5d2SYehuda Sadeh /* composed values */
6663d14c5d2SYehuda Sadeh #define CEPH_CAP_AUTH_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SAUTH)
6673d14c5d2SYehuda Sadeh #define CEPH_CAP_AUTH_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SAUTH)
6683d14c5d2SYehuda Sadeh #define CEPH_CAP_LINK_SHARED  (CEPH_CAP_GSHARED  << CEPH_CAP_SLINK)
6693d14c5d2SYehuda Sadeh #define CEPH_CAP_LINK_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SLINK)
6703d14c5d2SYehuda Sadeh #define CEPH_CAP_XATTR_SHARED (CEPH_CAP_GSHARED  << CEPH_CAP_SXATTR)
6713d14c5d2SYehuda Sadeh #define CEPH_CAP_XATTR_EXCL    (CEPH_CAP_GEXCL     << CEPH_CAP_SXATTR)
6723d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE(x)    (x << CEPH_CAP_SFILE)
6733d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_SHARED   (CEPH_CAP_GSHARED   << CEPH_CAP_SFILE)
6743d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_EXCL     (CEPH_CAP_GEXCL     << CEPH_CAP_SFILE)
6753d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_CACHE    (CEPH_CAP_GCACHE    << CEPH_CAP_SFILE)
6763d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_RD       (CEPH_CAP_GRD       << CEPH_CAP_SFILE)
6773d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_WR       (CEPH_CAP_GWR       << CEPH_CAP_SFILE)
6783d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_BUFFER   (CEPH_CAP_GBUFFER   << CEPH_CAP_SFILE)
6793d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_WREXTEND (CEPH_CAP_GWREXTEND << CEPH_CAP_SFILE)
6803d14c5d2SYehuda Sadeh #define CEPH_CAP_FILE_LAZYIO   (CEPH_CAP_GLAZYIO   << CEPH_CAP_SFILE)
6813d14c5d2SYehuda Sadeh #define CEPH_CAP_FLOCK_SHARED  (CEPH_CAP_GSHARED   << CEPH_CAP_SFLOCK)
6823d14c5d2SYehuda Sadeh #define CEPH_CAP_FLOCK_EXCL    (CEPH_CAP_GEXCL     << CEPH_CAP_SFLOCK)
6833d14c5d2SYehuda Sadeh 
6843d14c5d2SYehuda Sadeh 
6853d14c5d2SYehuda Sadeh /* cap masks (for getattr) */
6863d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_INODE    CEPH_CAP_PIN
6873d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_TYPE     CEPH_CAP_PIN  /* mode >> 12 */
6883d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_SYMLINK  CEPH_CAP_PIN
6893d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_UID      CEPH_CAP_AUTH_SHARED
6903d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_GID      CEPH_CAP_AUTH_SHARED
6913d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_MODE     CEPH_CAP_AUTH_SHARED
6923d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_NLINK    CEPH_CAP_LINK_SHARED
6933d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_LAYOUT   CEPH_CAP_FILE_SHARED
6943d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_MTIME    CEPH_CAP_FILE_SHARED
6953d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_SIZE     CEPH_CAP_FILE_SHARED
6963d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_ATIME    CEPH_CAP_FILE_SHARED  /* fixme */
6973d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_XATTR    CEPH_CAP_XATTR_SHARED
6983d14c5d2SYehuda Sadeh #define CEPH_STAT_CAP_INODE_ALL (CEPH_CAP_PIN |			\
6993d14c5d2SYehuda Sadeh 				 CEPH_CAP_AUTH_SHARED |	\
7003d14c5d2SYehuda Sadeh 				 CEPH_CAP_LINK_SHARED |	\
7013d14c5d2SYehuda Sadeh 				 CEPH_CAP_FILE_SHARED |	\
7023d14c5d2SYehuda Sadeh 				 CEPH_CAP_XATTR_SHARED)
70301deead0SYan, Zheng #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
70401deead0SYan, Zheng 				   CEPH_CAP_FILE_RD)
70549a9f4f6SYan, Zheng #define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
7063d14c5d2SYehuda Sadeh 
7073d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED |			\
7083d14c5d2SYehuda Sadeh 			      CEPH_CAP_LINK_SHARED |			\
7093d14c5d2SYehuda Sadeh 			      CEPH_CAP_XATTR_SHARED |			\
7103d14c5d2SYehuda Sadeh 			      CEPH_CAP_FILE_SHARED)
7113d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY_RD   (CEPH_CAP_ANY_SHARED | CEPH_CAP_FILE_RD |	\
7123d14c5d2SYehuda Sadeh 			   CEPH_CAP_FILE_CACHE)
7133d14c5d2SYehuda Sadeh 
7143d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY_EXCL (CEPH_CAP_AUTH_EXCL |		\
7153d14c5d2SYehuda Sadeh 			   CEPH_CAP_LINK_EXCL |		\
7163d14c5d2SYehuda Sadeh 			   CEPH_CAP_XATTR_EXCL |	\
7173d14c5d2SYehuda Sadeh 			   CEPH_CAP_FILE_EXCL)
718f98a128aSYan, Zheng #define CEPH_CAP_ANY_FILE_RD (CEPH_CAP_FILE_RD | CEPH_CAP_FILE_CACHE | \
719f98a128aSYan, Zheng 			      CEPH_CAP_FILE_SHARED)
7203d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY_FILE_WR (CEPH_CAP_FILE_WR | CEPH_CAP_FILE_BUFFER |	\
7213d14c5d2SYehuda Sadeh 			      CEPH_CAP_FILE_EXCL)
7223d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY_WR   (CEPH_CAP_ANY_EXCL | CEPH_CAP_ANY_FILE_WR)
7233d14c5d2SYehuda Sadeh #define CEPH_CAP_ANY      (CEPH_CAP_ANY_RD | CEPH_CAP_ANY_EXCL | \
7243d14c5d2SYehuda Sadeh 			   CEPH_CAP_ANY_FILE_WR | CEPH_CAP_FILE_LAZYIO | \
7253d14c5d2SYehuda Sadeh 			   CEPH_CAP_PIN)
7269a8d03caSJeff Layton #define CEPH_CAP_ALL_FILE (CEPH_CAP_PIN | CEPH_CAP_ANY_SHARED | \
7279a8d03caSJeff Layton 			   CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL | \
7289a8d03caSJeff Layton 			   CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)
7293d14c5d2SYehuda Sadeh 
7303d14c5d2SYehuda Sadeh #define CEPH_CAP_LOCKS (CEPH_LOCK_IFILE | CEPH_LOCK_IAUTH | CEPH_LOCK_ILINK | \
7313d14c5d2SYehuda Sadeh 			CEPH_LOCK_IXATTR)
7323d14c5d2SYehuda Sadeh 
733a25949b9SJeff Layton /* cap masks async dir operations */
734a25949b9SJeff Layton #define CEPH_CAP_DIR_CREATE	CEPH_CAP_FILE_CACHE
735a25949b9SJeff Layton #define CEPH_CAP_DIR_UNLINK	CEPH_CAP_FILE_RD
736a25949b9SJeff Layton #define CEPH_CAP_ANY_DIR_OPS	(CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_RD | \
737a25949b9SJeff Layton 				 CEPH_CAP_FILE_WREXTEND | CEPH_CAP_FILE_LAZYIO)
738a25949b9SJeff Layton 
7393d14c5d2SYehuda Sadeh int ceph_caps_for_mode(int mode);
7403d14c5d2SYehuda Sadeh 
7413d14c5d2SYehuda Sadeh enum {
7423d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_GRANT,         /* mds->client grant */
7433d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_REVOKE,        /* mds->client revoke */
7443d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_TRUNC,         /* mds->client trunc notify */
7453d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_EXPORT,        /* mds has exported the cap */
7463d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_IMPORT,        /* mds has imported the cap */
7473d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_UPDATE,        /* client->mds update */
7483d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_DROP,          /* client->mds drop cap bits */
7493d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_FLUSH,         /* client->mds cap writeback */
7503d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_FLUSH_ACK,     /* mds->client flushed */
7513d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_FLUSHSNAP,     /* client->mds flush snapped metadata */
7523d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_FLUSHSNAP_ACK, /* mds->client flushed snapped metadata */
7533d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_RELEASE,       /* client->mds release (clean) cap */
7543d14c5d2SYehuda Sadeh 	CEPH_CAP_OP_RENEW,         /* client->mds renewal request */
7553d14c5d2SYehuda Sadeh };
7563d14c5d2SYehuda Sadeh 
7573d14c5d2SYehuda Sadeh extern const char *ceph_cap_op_name(int op);
7583d14c5d2SYehuda Sadeh 
7591e4ef0c6SJeff Layton /* flags field in client cap messages (version >= 10) */
76095569713SYan, Zheng #define CEPH_CLIENT_CAPS_SYNC			(1<<0)
76195569713SYan, Zheng #define CEPH_CLIENT_CAPS_NO_CAPSNAP		(1<<1)
76249ada6e8SYan, Zheng #define CEPH_CLIENT_CAPS_PENDING_CAPSNAP	(1<<2)
7631e4ef0c6SJeff Layton 
7643d14c5d2SYehuda Sadeh /*
7653d14c5d2SYehuda Sadeh  * caps message, used for capability callbacks, acks, requests, etc.
7663d14c5d2SYehuda Sadeh  */
7673d14c5d2SYehuda Sadeh struct ceph_mds_caps {
7683d14c5d2SYehuda Sadeh 	__le32 op;                  /* CEPH_CAP_OP_* */
7693d14c5d2SYehuda Sadeh 	__le64 ino, realm;
7703d14c5d2SYehuda Sadeh 	__le64 cap_id;
7713d14c5d2SYehuda Sadeh 	__le32 seq, issue_seq;
7723d14c5d2SYehuda Sadeh 	__le32 caps, wanted, dirty; /* latest issued/wanted/dirty */
7733d14c5d2SYehuda Sadeh 	__le32 migrate_seq;
7743d14c5d2SYehuda Sadeh 	__le64 snap_follows;
7753d14c5d2SYehuda Sadeh 	__le32 snap_trace_len;
7763d14c5d2SYehuda Sadeh 
7773d14c5d2SYehuda Sadeh 	/* authlock */
7783d14c5d2SYehuda Sadeh 	__le32 uid, gid, mode;
7793d14c5d2SYehuda Sadeh 
7803d14c5d2SYehuda Sadeh 	/* linklock */
7813d14c5d2SYehuda Sadeh 	__le32 nlink;
7823d14c5d2SYehuda Sadeh 
7833d14c5d2SYehuda Sadeh 	/* xattrlock */
7843d14c5d2SYehuda Sadeh 	__le32 xattr_len;
7853d14c5d2SYehuda Sadeh 	__le64 xattr_version;
7863d14c5d2SYehuda Sadeh 
7871b7587d6SXiubo Li 	/* a union of non-export and export bodies. */
7883d14c5d2SYehuda Sadeh 	__le64 size, max_size, truncate_size;
7893d14c5d2SYehuda Sadeh 	__le32 truncate_seq;
7903d14c5d2SYehuda Sadeh 	struct ceph_timespec mtime, atime, ctime;
7917627151eSYan, Zheng 	struct ceph_file_layout_legacy layout;
7923d14c5d2SYehuda Sadeh 	__le32 time_warp_seq;
7933d14c5d2SYehuda Sadeh } __attribute__ ((packed));
7943d14c5d2SYehuda Sadeh 
7954ee6a914SYan, Zheng struct ceph_mds_cap_peer {
7964ee6a914SYan, Zheng 	__le64 cap_id;
797*8b41ac43SPatrick Donnelly 	__le32 issue_seq;
7984ee6a914SYan, Zheng 	__le32 mseq;
7994ee6a914SYan, Zheng 	__le32 mds;
8004ee6a914SYan, Zheng 	__u8   flags;
8014ee6a914SYan, Zheng } __attribute__ ((packed));
8024ee6a914SYan, Zheng 
8033d14c5d2SYehuda Sadeh /* cap release msg head */
8043d14c5d2SYehuda Sadeh struct ceph_mds_cap_release {
8053d14c5d2SYehuda Sadeh 	__le32 num;                /* number of cap_items that follow */
8063d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8073d14c5d2SYehuda Sadeh 
8083d14c5d2SYehuda Sadeh struct ceph_mds_cap_item {
8093d14c5d2SYehuda Sadeh 	__le64 ino;
8103d14c5d2SYehuda Sadeh 	__le64 cap_id;
81150f42c48SPatrick Donnelly 	__le32 migrate_seq, issue_seq;
8123d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8133d14c5d2SYehuda Sadeh 
8143d14c5d2SYehuda Sadeh #define CEPH_MDS_LEASE_REVOKE           1  /*    mds  -> client */
8153d14c5d2SYehuda Sadeh #define CEPH_MDS_LEASE_RELEASE          2  /* client  -> mds    */
8163d14c5d2SYehuda Sadeh #define CEPH_MDS_LEASE_RENEW            3  /* client <-> mds    */
8173d14c5d2SYehuda Sadeh #define CEPH_MDS_LEASE_REVOKE_ACK       4  /* client  -> mds    */
8183d14c5d2SYehuda Sadeh 
8193d14c5d2SYehuda Sadeh extern const char *ceph_lease_op_name(int o);
8203d14c5d2SYehuda Sadeh 
8213d14c5d2SYehuda Sadeh /* lease msg header */
8223d14c5d2SYehuda Sadeh struct ceph_mds_lease {
8233d14c5d2SYehuda Sadeh 	__u8 action;            /* CEPH_MDS_LEASE_* */
8243d14c5d2SYehuda Sadeh 	__le16 mask;            /* which lease */
8253d14c5d2SYehuda Sadeh 	__le64 ino;
8263d14c5d2SYehuda Sadeh 	__le64 first, last;     /* snap range */
8273d14c5d2SYehuda Sadeh 	__le32 seq;
8283d14c5d2SYehuda Sadeh 	__le32 duration_ms;     /* duration of renewal */
8293d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8303d14c5d2SYehuda Sadeh /* followed by a __le32+string for dname */
8313d14c5d2SYehuda Sadeh 
8323d14c5d2SYehuda Sadeh /* client reconnect */
8333d14c5d2SYehuda Sadeh struct ceph_mds_cap_reconnect {
8343d14c5d2SYehuda Sadeh 	__le64 cap_id;
8353d14c5d2SYehuda Sadeh 	__le32 wanted;
8363d14c5d2SYehuda Sadeh 	__le32 issued;
8373d14c5d2SYehuda Sadeh 	__le64 snaprealm;
8383d14c5d2SYehuda Sadeh 	__le64 pathbase;        /* base ino for our path to this ino */
8393d14c5d2SYehuda Sadeh 	__le32 flock_len;       /* size of flock state blob, if any */
8403d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8413d14c5d2SYehuda Sadeh /* followed by flock blob */
8423d14c5d2SYehuda Sadeh 
8433d14c5d2SYehuda Sadeh struct ceph_mds_cap_reconnect_v1 {
8443d14c5d2SYehuda Sadeh 	__le64 cap_id;
8453d14c5d2SYehuda Sadeh 	__le32 wanted;
8463d14c5d2SYehuda Sadeh 	__le32 issued;
8473d14c5d2SYehuda Sadeh 	__le64 size;
8483d14c5d2SYehuda Sadeh 	struct ceph_timespec mtime, atime;
8493d14c5d2SYehuda Sadeh 	__le64 snaprealm;
8503d14c5d2SYehuda Sadeh 	__le64 pathbase;        /* base ino for our path to this ino */
8513d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8523d14c5d2SYehuda Sadeh 
8533d14c5d2SYehuda Sadeh struct ceph_mds_snaprealm_reconnect {
8543d14c5d2SYehuda Sadeh 	__le64 ino;     /* snap realm base */
8553d14c5d2SYehuda Sadeh 	__le64 seq;     /* snap seq for this snap realm */
8563d14c5d2SYehuda Sadeh 	__le64 parent;  /* parent realm */
8573d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8583d14c5d2SYehuda Sadeh 
8593d14c5d2SYehuda Sadeh /*
8603d14c5d2SYehuda Sadeh  * snaps
8613d14c5d2SYehuda Sadeh  */
8623d14c5d2SYehuda Sadeh enum {
8633d14c5d2SYehuda Sadeh 	CEPH_SNAP_OP_UPDATE,  /* CREATE or DESTROY */
8643d14c5d2SYehuda Sadeh 	CEPH_SNAP_OP_CREATE,
8653d14c5d2SYehuda Sadeh 	CEPH_SNAP_OP_DESTROY,
8663d14c5d2SYehuda Sadeh 	CEPH_SNAP_OP_SPLIT,
8673d14c5d2SYehuda Sadeh };
8683d14c5d2SYehuda Sadeh 
8693d14c5d2SYehuda Sadeh extern const char *ceph_snap_op_name(int o);
8703d14c5d2SYehuda Sadeh 
8713d14c5d2SYehuda Sadeh /* snap msg header */
8723d14c5d2SYehuda Sadeh struct ceph_mds_snap_head {
8733d14c5d2SYehuda Sadeh 	__le32 op;                /* CEPH_SNAP_OP_* */
8743d14c5d2SYehuda Sadeh 	__le64 split;             /* ino to split off, if any */
8753d14c5d2SYehuda Sadeh 	__le32 num_split_inos;    /* # inos belonging to new child realm */
8763d14c5d2SYehuda Sadeh 	__le32 num_split_realms;  /* # child realms udner new child realm */
8773d14c5d2SYehuda Sadeh 	__le32 trace_len;         /* size of snap trace blob */
8783d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8793d14c5d2SYehuda Sadeh /* followed by split ino list, then split realms, then the trace blob */
8803d14c5d2SYehuda Sadeh 
8813d14c5d2SYehuda Sadeh /*
8823d14c5d2SYehuda Sadeh  * encode info about a snaprealm, as viewed by a client
8833d14c5d2SYehuda Sadeh  */
8843d14c5d2SYehuda Sadeh struct ceph_mds_snap_realm {
8853d14c5d2SYehuda Sadeh 	__le64 ino;           /* ino */
8863d14c5d2SYehuda Sadeh 	__le64 created;       /* snap: when created */
8873d14c5d2SYehuda Sadeh 	__le64 parent;        /* ino: parent realm */
8883d14c5d2SYehuda Sadeh 	__le64 parent_since;  /* snap: same parent since */
8893d14c5d2SYehuda Sadeh 	__le64 seq;           /* snap: version */
8903d14c5d2SYehuda Sadeh 	__le32 num_snaps;
8913d14c5d2SYehuda Sadeh 	__le32 num_prior_parent_snaps;
8923d14c5d2SYehuda Sadeh } __attribute__ ((packed));
8933d14c5d2SYehuda Sadeh /* followed by my snap list, then prior parent snap list */
8943d14c5d2SYehuda Sadeh 
895fb18a575SLuis Henriques /*
896fb18a575SLuis Henriques  * quotas
897fb18a575SLuis Henriques  */
898fb18a575SLuis Henriques struct ceph_mds_quota {
899fb18a575SLuis Henriques 	__le64 ino;		/* ino */
900fb18a575SLuis Henriques 	struct ceph_timespec rctime;
901fb18a575SLuis Henriques 	__le64 rbytes;		/* dir stats */
902fb18a575SLuis Henriques 	__le64 rfiles;
903fb18a575SLuis Henriques 	__le64 rsubdirs;
904fb18a575SLuis Henriques 	__u8 struct_v;		/* compat */
905fb18a575SLuis Henriques 	__u8 struct_compat;
906fb18a575SLuis Henriques 	__le32 struct_len;
907fb18a575SLuis Henriques 	__le64 max_bytes;	/* quota max. bytes */
908fb18a575SLuis Henriques 	__le64 max_files;	/* quota max. files */
909fb18a575SLuis Henriques } __attribute__ ((packed));
910fb18a575SLuis Henriques 
9113d14c5d2SYehuda Sadeh #endif
912