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