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