mds_client.h 20 KB

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