Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #ifndef _FS_CEPH_MDS_CLIENT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #define _FS_CEPH_MDS_CLIENT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/completion.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/kref.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/rbtree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/refcount.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/utsname.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/ktime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/ceph/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/ceph/messenger.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/ceph/mdsmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/ceph/auth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include "metric.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "super.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) /* The first 8 bits are reserved for old ceph releases */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) enum ceph_feature_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	CEPHFS_FEATURE_MIMIC = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	CEPHFS_FEATURE_REPLY_ENCODING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	CEPHFS_FEATURE_RECLAIM_CLIENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	CEPHFS_FEATURE_LAZY_CAP_WANTED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	CEPHFS_FEATURE_MULTI_RECONNECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	CEPHFS_FEATURE_DELEG_INO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	CEPHFS_FEATURE_METRIC_COLLECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * This will always have the highest feature bit value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * as the last element of the array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define CEPHFS_FEATURES_CLIENT_SUPPORTED {	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	0, 1, 2, 3, 4, 5, 6, 7,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	CEPHFS_FEATURE_MIMIC,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	CEPHFS_FEATURE_REPLY_ENCODING,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	CEPHFS_FEATURE_LAZY_CAP_WANTED,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	CEPHFS_FEATURE_MULTI_RECONNECT,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	CEPHFS_FEATURE_DELEG_INO,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	CEPHFS_FEATURE_METRIC_COLLECT,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	CEPHFS_FEATURE_MAX,			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #define CEPHFS_FEATURES_CLIENT_REQUIRED {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54)  * Some lock dependencies:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * session->s_mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  *         mdsc->mutex
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  *         mdsc->snap_rwsem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *         ci->i_ceph_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  *                 mdsc->snap_flush_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  *                 mdsc->cap_delay_lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct ceph_fs_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) struct ceph_cap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * parsed info about a single inode.  pointers are into the encoded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  * on-wire structures within the mds reply message payload.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) struct ceph_mds_reply_info_in {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	struct ceph_mds_reply_inode *in;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct ceph_dir_layout dir_layout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	u32 symlink_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	char *symlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	u32 xattr_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	char *xattr_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u64 inline_version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	u32 inline_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	char *inline_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	u32 pool_ns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	char *pool_ns_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	u64 max_bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	u64 max_files;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	s32 dir_pin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct ceph_timespec btime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	struct ceph_timespec snap_btime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	u64 change_attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct ceph_mds_reply_dir_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	char                          *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	u32                           name_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct ceph_mds_reply_lease   *lease;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct ceph_mds_reply_info_in inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	loff_t			      offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  * parsed info about an mds reply, including information about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * either: 1) the target inode and/or its parent directory and dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * and directory contents (for readdir results), or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  * 2) the file range lock info (for fcntl F_GETLK results).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct ceph_mds_reply_info_parsed {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	struct ceph_mds_reply_head    *head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct ceph_mds_reply_info_in diri, targeti;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	struct ceph_mds_reply_dirfrag *dirfrag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	char                          *dname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	u32                           dname_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	struct ceph_mds_reply_lease   *dlease;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/* extra */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		/* for fcntl F_GETLK results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		struct ceph_filelock *filelock_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		/* for readdir results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 			struct ceph_mds_reply_dirfrag *dir_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 			size_t			      dir_buf_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			int                           dir_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			bool			      dir_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			bool			      dir_complete;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			bool			      hash_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			bool			      offset_hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			struct ceph_mds_reply_dir_entry  *dir_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		/* for create results */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 			bool has_create_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			u64 ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/* encoded blob describing snapshot contexts for certain
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	   operations (e.g., open) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	void *snapblob;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	int snapblob_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)  * cap releases are batched and sent to the MDS en masse.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)  * Account for per-message overhead of mds_cap_release header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)  * and __le32 for osd epoch barrier trailing field.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) #define CEPH_CAPS_PER_RELEASE ((PAGE_SIZE - sizeof(u32) -		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				sizeof(struct ceph_mds_cap_release)) /	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			        sizeof(struct ceph_mds_cap_item))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  * state associated with each MDS<->client session
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	CEPH_MDS_SESSION_NEW = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	CEPH_MDS_SESSION_OPENING = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	CEPH_MDS_SESSION_OPEN = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	CEPH_MDS_SESSION_HUNG = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	CEPH_MDS_SESSION_RESTARTING = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	CEPH_MDS_SESSION_RECONNECTING = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	CEPH_MDS_SESSION_CLOSING = 7,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	CEPH_MDS_SESSION_CLOSED = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	CEPH_MDS_SESSION_REJECTED = 9,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct ceph_mds_session {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	struct ceph_mds_client *s_mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	int               s_mds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	int               s_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	unsigned long     s_ttl;      /* time until mds kills us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	unsigned long	  s_features;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	u64               s_seq;      /* incoming msg seq # */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	struct mutex      s_mutex;    /* serialize session messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct ceph_connection s_con;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	struct ceph_auth_handshake s_auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	/* protected by s_gen_ttl_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	spinlock_t        s_gen_ttl_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	u32               s_cap_gen;  /* inc each time we get mds stale msg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	unsigned long     s_cap_ttl;  /* when session caps expire */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	/* protected by s_cap_lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	spinlock_t        s_cap_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	refcount_t        s_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	struct list_head  s_caps;     /* all caps issued by this session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	struct ceph_cap  *s_cap_iterator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	int               s_nr_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	int               s_num_cap_releases;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	int		  s_cap_reconnect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int		  s_readonly;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	struct list_head  s_cap_releases; /* waiting cap_release messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct work_struct s_cap_release_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	/* See ceph_inode_info->i_dirty_item. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	struct list_head  s_cap_dirty;	      /* inodes w/ dirty caps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	/* See ceph_inode_info->i_flushing_item. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	struct list_head  s_cap_flushing;     /* inodes w/ flushing caps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	unsigned long     s_renew_requested; /* last time we sent a renew req */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	u64               s_renew_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	struct list_head  s_waiting;  /* waiting requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	struct list_head  s_unsafe;   /* unsafe requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	struct xarray	  s_delegated_inos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * modes of choosing which MDS to send a request to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	USE_ANY_MDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	USE_RANDOM_MDS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	USE_AUTH_MDS,   /* prefer authoritative mds for this metadata item */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) struct ceph_mds_request;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) struct ceph_mds_client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * request completion callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) typedef void (*ceph_mds_request_callback_t) (struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 					     struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * wait for request completion callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) typedef int (*ceph_mds_request_wait_callback_t) (struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 						 struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)  * an in-flight mds request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) struct ceph_mds_request {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	u64 r_tid;                   /* transaction id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	struct rb_node r_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	struct ceph_mds_client *r_mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	struct kref       r_kref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	int r_op;                    /* mds op code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	/* operation on what? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	struct inode *r_inode;              /* arg1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	struct dentry *r_dentry;            /* arg1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	struct dentry *r_old_dentry;        /* arg2: rename from or link from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	struct inode *r_old_dentry_dir;     /* arg2: old dentry's parent dir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	char *r_path1, *r_path2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	struct ceph_vino r_ino1, r_ino2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	struct inode *r_parent;		    /* parent dir inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	struct inode *r_target_inode;       /* resulting inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) #define CEPH_MDS_R_DIRECT_IS_HASH	(1) /* r_direct_hash is valid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) #define CEPH_MDS_R_ABORTED		(2) /* call was aborted */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) #define CEPH_MDS_R_GOT_UNSAFE		(3) /* got an unsafe reply */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #define CEPH_MDS_R_GOT_SAFE		(4) /* got a safe reply */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) #define CEPH_MDS_R_GOT_RESULT		(5) /* got a result */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) #define CEPH_MDS_R_DID_PREPOPULATE	(6) /* prepopulated readdir */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) #define CEPH_MDS_R_PARENT_LOCKED	(7) /* is r_parent->i_rwsem wlocked? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) #define CEPH_MDS_R_ASYNC		(8) /* async request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	unsigned long	r_req_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct mutex r_fill_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	union ceph_mds_request_args r_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	int r_fmode;        /* file mode, if expecting cap */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	kuid_t r_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	kgid_t r_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	int r_request_release_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	struct timespec64 r_stamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/* for choosing which mds to send this request to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	int r_direct_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	u32 r_direct_hash;      /* choose dir frag based on this dentry hash */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	/* data payload is used for xattr ops */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	struct ceph_pagelist *r_pagelist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	/* what caps shall we drop? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	int r_inode_drop, r_inode_unless;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	int r_dentry_drop, r_dentry_unless;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	int r_old_dentry_drop, r_old_dentry_unless;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	struct inode *r_old_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	int r_old_inode_drop, r_old_inode_unless;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct ceph_msg  *r_request;  /* original request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	struct ceph_msg  *r_reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	struct ceph_mds_reply_info_parsed r_reply_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	int r_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	struct page *r_locked_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	int r_dir_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	int r_num_caps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	u32               r_readdir_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	unsigned long r_timeout;  /* optional.  jiffies, 0 is "wait forever" */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	unsigned long r_started;  /* start time to measure timeout against */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	unsigned long r_start_latency;  /* start time to measure latency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	unsigned long r_end_latency;    /* finish time to measure latency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	unsigned long r_request_started; /* start time for mds request only,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 					    used to measure lease durations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	/* link unsafe requests to parent directory, for fsync */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	struct inode	*r_unsafe_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	struct list_head r_unsafe_dir_item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	/* unsafe requests that modify the target inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	struct list_head r_unsafe_target_item;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	struct ceph_mds_session *r_session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	int               r_attempts;   /* resend attempts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	int               r_num_fwd;    /* number of forward attempts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	int               r_resend_mds; /* mds to resend to next, if any*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	u32               r_sent_on_mseq; /* cap mseq request was sent at*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	u64		  r_deleg_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	struct list_head  r_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	struct completion r_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	struct completion r_safe_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	ceph_mds_request_callback_t r_callback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	ceph_mds_request_wait_callback_t r_wait_for_completion;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	struct list_head  r_unsafe_item;  /* per-session unsafe list item */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	long long	  r_dir_release_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	long long	  r_dir_ordered_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	int		  r_readdir_cache_idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	struct ceph_cap_reservation r_caps_reservation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) struct ceph_pool_perm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	int perm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	s64 pool;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	size_t pool_ns_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	char pool_ns[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) struct ceph_snapid_map {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	struct list_head lru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	atomic_t ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	u64 snap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	dev_t dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	unsigned long last_used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362)  * node for list of quotarealm inodes that are not visible from the filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363)  * mountpoint, but required to handle, e.g. quotas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) struct ceph_quotarealm_inode {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	struct rb_node node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	u64 ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	unsigned long timeout; /* last time a lookup failed for this inode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) struct cap_wait {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	struct list_head	list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	u64			ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	pid_t			tgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	int			need;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	int			want;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)  * mds client state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) struct ceph_mds_client {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	struct ceph_fs_client  *fsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	struct mutex            mutex;         /* all nested structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	struct ceph_mdsmap      *mdsmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	struct completion       safe_umount_waiters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	wait_queue_head_t       session_close_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	struct list_head        waiting_for_map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	int 			mdsmap_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	struct ceph_mds_session **sessions;    /* NULL for mds if no session */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	atomic_t		num_sessions;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	int                     max_sessions;  /* len of sessions array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	int                     stopping;      /* true if shutting down */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	atomic64_t		quotarealms_count; /* # realms with quota */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	 * We keep a list of inodes we don't see in the mountpoint but that we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	 * need to track quota realms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	struct rb_root		quotarealms_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	struct mutex		quotarealms_inodes_mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	 * snap_rwsem will cover cap linkage into snaprealms, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	 * realm snap contexts.  (later, we can do per-realm snap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	 * contexts locks..)  the empty list contains realms with no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	 * references (implying they contain no inodes with caps) that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	 * should be destroyed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	u64			last_snap_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	struct rw_semaphore     snap_rwsem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	struct rb_root          snap_realms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	struct list_head        snap_empty;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	int			num_snap_realms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	spinlock_t              snap_empty_lock;  /* protect snap_empty */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	u64                    last_tid;      /* most recent mds request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	u64                    oldest_tid;    /* oldest incomplete mds request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 						 excluding setfilelock requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	struct rb_root         request_tree;  /* pending mds requests */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	struct delayed_work    delayed_work;  /* delayed work */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	unsigned long    last_renew_caps;  /* last time we renewed our caps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	struct list_head cap_delay_list;   /* caps with delayed release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	spinlock_t       cap_delay_lock;   /* protects cap_delay_list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	struct list_head snap_flush_list;  /* cap_snaps ready to flush */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	spinlock_t       snap_flush_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	u64               last_cap_flush_tid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	struct list_head  cap_flush_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 	struct list_head  cap_dirty_migrating; /* ...that are migration... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	int               num_cap_flushing; /* # caps we are flushing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	spinlock_t        cap_dirty_lock;   /* protects above items */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	wait_queue_head_t cap_flushing_wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	struct work_struct cap_reclaim_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	atomic_t	   cap_reclaim_pending;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	 * Cap reservations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	 * Maintain a global pool of preallocated struct ceph_caps, referenced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	 * by struct ceph_caps_reservations.  This ensures that we preallocate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	 * memory needed to successfully process an MDS response.  (If an MDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	 * sends us cap information and we fail to process it, we will have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	 * problems due to the client and MDS being out of sync.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	 * Reservations are 'owned' by a ceph_cap_reservation context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	spinlock_t	caps_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	struct		list_head caps_list; /* unused (reserved or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 						unreserved) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	struct		list_head cap_wait_list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	int		caps_total_count;    /* total caps allocated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	int		caps_use_count;      /* in use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 	int		caps_use_max;	     /* max used caps */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	int		caps_reserve_count;  /* unused, reserved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	int		caps_avail_count;    /* unused, unreserved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	int		caps_min_count;      /* keep at least this many
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 						(unreserved) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	spinlock_t	  dentry_list_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	struct list_head  dentry_leases;     /* fifo list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	struct list_head  dentry_dir_leases; /* lru list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	struct ceph_client_metric metric;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	spinlock_t		snapid_map_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	struct rb_root		snapid_map_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	struct list_head	snapid_map_lru;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	struct rw_semaphore     pool_perm_rwsem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	struct rb_root		pool_perm_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	char nodename[__NEW_UTS_LEN + 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) extern const char *ceph_mds_op_name(int op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) extern bool check_session_state(struct ceph_mds_session *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) void inc_session_sequence(struct ceph_mds_session *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) extern struct ceph_mds_session *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) __ceph_lookup_mds_session(struct ceph_mds_client *, int mds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) extern const char *ceph_session_state_name(int s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) extern struct ceph_mds_session *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) ceph_get_mds_session(struct ceph_mds_session *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) extern void ceph_put_mds_session(struct ceph_mds_session *s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 			     struct ceph_msg *msg, int mds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) extern int ceph_mdsc_init(struct ceph_fs_client *fsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) extern void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) extern void ceph_mdsc_destroy(struct ceph_fs_client *fsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) extern void ceph_mdsc_sync(struct ceph_mds_client *mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) extern void ceph_invalidate_dir_request(struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) extern int ceph_alloc_readdir_reply_buffer(struct ceph_mds_request *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 					   struct inode *dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) extern struct ceph_mds_request *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) ceph_mdsc_create_request(struct ceph_mds_client *mdsc, int op, int mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) extern int ceph_mdsc_submit_request(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 				    struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 				    struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) extern int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 				struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 				struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) extern void ceph_mdsc_release_dir_caps(struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) extern void ceph_mdsc_release_dir_caps_no_check(struct ceph_mds_request *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) static inline void ceph_mdsc_get_request(struct ceph_mds_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	kref_get(&req->r_kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) extern void ceph_mdsc_release_request(struct kref *kref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) static inline void ceph_mdsc_put_request(struct ceph_mds_request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	kref_put(&req->r_kref, ceph_mdsc_release_request);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) extern void __ceph_queue_cap_release(struct ceph_mds_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 				    struct ceph_cap *cap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) extern void ceph_flush_cap_releases(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 				    struct ceph_mds_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) extern void ceph_queue_cap_reclaim_work(struct ceph_mds_client *mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) extern void ceph_reclaim_caps_nr(struct ceph_mds_client *mdsc, int nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) extern int ceph_iterate_session_caps(struct ceph_mds_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 				     int (*cb)(struct inode *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 					       struct ceph_cap *, void *),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 				     void *arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) extern void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) static inline void ceph_mdsc_free_path(char *path, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 	if (!IS_ERR_OR_NULL(path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 		__putname(path - (PATH_MAX - 1 - len));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) extern char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 				  int stop_on_nosnap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 				     struct dentry *dentry, char action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 				     u32 seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) extern void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 				    struct ceph_msg *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) extern void ceph_mdsc_handle_fsmap(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 				   struct ceph_msg *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) extern struct ceph_mds_session *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) ceph_mdsc_open_export_target_session(struct ceph_mds_client *mdsc, int target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) extern void ceph_mdsc_open_export_target_sessions(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 					  struct ceph_mds_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) extern int ceph_trim_caps(struct ceph_mds_client *mdsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 			  struct ceph_mds_session *session,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			  int max_caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) static inline int ceph_wait_on_async_create(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	struct ceph_inode_info *ci = ceph_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	return wait_on_bit(&ci->i_ceph_flags, CEPH_ASYNC_CREATE_BIT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 			   TASK_INTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) extern u64 ceph_get_deleg_ino(struct ceph_mds_session *session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) extern int ceph_restore_deleg_ino(struct ceph_mds_session *session, u64 ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) #endif