hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/nfs/nfs4_fs.h
....@@ -42,7 +42,11 @@
4242 NFS4CLNT_LEASE_MOVED,
4343 NFS4CLNT_DELEGATION_EXPIRED,
4444 NFS4CLNT_RUN_MANAGER,
45
- NFS4CLNT_DELEGRETURN_RUNNING,
45
+ NFS4CLNT_MANAGER_AVAILABLE,
46
+ NFS4CLNT_RECALL_RUNNING,
47
+ NFS4CLNT_RECALL_ANY_LAYOUT_READ,
48
+ NFS4CLNT_RECALL_ANY_LAYOUT_RW,
49
+ NFS4CLNT_DELEGRETURN_DELAYED,
4650 };
4751
4852 #define NFS4_RENEW_TIMEOUT 0x01
....@@ -62,10 +66,11 @@
6266 void (*free_lock_state)(struct nfs_server *,
6367 struct nfs4_lock_state *);
6468 int (*test_and_free_expired)(struct nfs_server *,
65
- nfs4_stateid *, struct rpc_cred *);
69
+ nfs4_stateid *, const struct cred *);
6670 struct nfs_seqid *
6771 (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
68
- int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *);
72
+ void (*session_trunk)(struct rpc_clnt *clnt,
73
+ struct rpc_xprt *xprt, void *data);
6974 const struct rpc_call_ops *call_sync_ops;
7075 const struct nfs4_state_recovery_ops *reboot_recovery_ops;
7176 const struct nfs4_state_recovery_ops *nograce_recovery_ops;
....@@ -107,14 +112,14 @@
107112 unsigned long so_expires;
108113 struct rb_node so_server_node;
109114
110
- struct rpc_cred *so_cred; /* Associated cred */
115
+ const struct cred *so_cred; /* Associated cred */
111116
112117 spinlock_t so_lock;
113118 atomic_t so_count;
114119 unsigned long so_flags;
115120 struct list_head so_states;
116121 struct nfs_seqid_counter so_seqid;
117
- seqcount_t so_reclaim_seqcount;
122
+ seqcount_spinlock_t so_reclaim_seqcount;
118123 struct mutex so_delegreturn_mutex;
119124 };
120125
....@@ -165,9 +170,9 @@
165170 NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */
166171 NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */
167172 NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */
168
-#ifdef CONFIG_NFS_V4_2
169173 NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/
170
-#endif /* CONFIG_NFS_V4_2 */
174
+ NFS_CLNT_SRC_SSC_COPY_STATE, /* src server open state on client*/
175
+ NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */
171176 };
172177
173178 struct nfs4_state {
....@@ -190,9 +195,10 @@
190195 unsigned int n_wronly; /* Number of write-only references */
191196 unsigned int n_rdwr; /* Number of read/write references */
192197 fmode_t state; /* State on the server (R,W, or RW) */
193
- atomic_t count;
198
+ refcount_t count;
194199
195200 wait_queue_head_t waitq;
201
+ struct rcu_head rcu_head;
196202 };
197203
198204
....@@ -205,6 +211,7 @@
205211 unsigned char delay : 1,
206212 recovering : 1,
207213 retry : 1;
214
+ bool interruptible;
208215 };
209216
210217 struct nfs4_state_recovery_ops {
....@@ -212,10 +219,10 @@
212219 int state_flag_bit;
213220 int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
214221 int (*recover_lock)(struct nfs4_state *, struct file_lock *);
215
- int (*establish_clid)(struct nfs_client *, struct rpc_cred *);
216
- int (*reclaim_complete)(struct nfs_client *, struct rpc_cred *);
222
+ int (*establish_clid)(struct nfs_client *, const struct cred *);
223
+ int (*reclaim_complete)(struct nfs_client *, const struct cred *);
217224 int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
218
- struct rpc_cred *);
225
+ const struct cred *);
219226 };
220227
221228 struct nfs4_opendata {
....@@ -245,19 +252,19 @@
245252
246253 struct nfs4_add_xprt_data {
247254 struct nfs_client *clp;
248
- struct rpc_cred *cred;
255
+ const struct cred *cred;
249256 };
250257
251258 struct nfs4_state_maintenance_ops {
252
- int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned);
253
- struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
254
- int (*renew_lease)(struct nfs_client *, struct rpc_cred *);
259
+ int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned);
260
+ const struct cred * (*get_state_renewal_cred)(struct nfs_client *);
261
+ int (*renew_lease)(struct nfs_client *, const struct cred *);
255262 };
256263
257264 struct nfs4_mig_recovery_ops {
258265 int (*get_locations)(struct inode *, struct nfs4_fs_locations *,
259
- struct page *, struct rpc_cred *);
260
- int (*fsid_present)(struct inode *, struct rpc_cred *);
266
+ struct page *, const struct cred *);
267
+ int (*fsid_present)(struct inode *, const struct cred *);
261268 };
262269
263270 extern const struct dentry_operations nfs4_dentry_operations;
....@@ -266,18 +273,17 @@
266273 int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
267274 unsigned, umode_t);
268275
269
-/* super.c */
276
+/* fs_context.c */
270277 extern struct file_system_type nfs4_fs_type;
271278
272279 /* nfs4namespace.c */
273280 struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
274281 const struct qstr *);
275
-struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
276
- struct nfs_fh *, struct nfs_fattr *);
282
+int nfs4_submount(struct fs_context *, struct nfs_server *);
277283 int nfs4_replace_transport(struct nfs_server *server,
278284 const struct nfs4_fs_locations *locations);
279285 size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
280
- size_t salen, struct net *net);
286
+ size_t salen, struct net *net, int port);
281287 /* nfs4proc.c */
282288 extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
283289 extern int nfs4_async_handle_error(struct rpc_task *task,
....@@ -287,36 +293,52 @@
287293 struct rpc_message *, struct nfs4_sequence_args *,
288294 struct nfs4_sequence_res *, int);
289295 extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
290
-extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
291
-extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
296
+extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
297
+extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
292298 extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
293
-extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, struct rpc_cred *cred);
294
-extern int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred);
299
+extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred);
300
+extern int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred);
295301 extern int nfs4_destroy_clientid(struct nfs_client *clp);
296
-extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
297
-extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
302
+extern int nfs4_init_clientid(struct nfs_client *, const struct cred *);
303
+extern int nfs41_init_clientid(struct nfs_client *, const struct cred *);
298304 extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
299305 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
300306 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
301307 struct nfs4_fs_locations *, struct page *);
302308 extern int nfs4_proc_get_locations(struct inode *, struct nfs4_fs_locations *,
303
- struct page *page, struct rpc_cred *);
304
-extern int nfs4_proc_fsid_present(struct inode *, struct rpc_cred *);
305
-extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *, const struct qstr *,
306
- struct nfs_fh *, struct nfs_fattr *);
309
+ struct page *page, const struct cred *);
310
+extern int nfs4_proc_fsid_present(struct inode *, const struct cred *);
311
+extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *,
312
+ struct dentry *,
313
+ struct nfs_fh *,
314
+ struct nfs_fattr *);
307315 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
308316 extern const struct xattr_handler *nfs4_xattr_handlers[];
309317 extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
310318 const struct nfs_open_context *ctx,
311319 const struct nfs_lock_context *l_ctx,
312320 fmode_t fmode);
321
+extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
322
+ struct nfs_fattr *fattr, struct nfs4_label *label,
323
+ struct inode *inode);
324
+extern int update_open_stateid(struct nfs4_state *state,
325
+ const nfs4_stateid *open_stateid,
326
+ const nfs4_stateid *deleg_stateid,
327
+ fmode_t fmode);
328
+
329
+extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
330
+ struct nfs_fsinfo *fsinfo);
331
+extern void nfs4_update_changeattr(struct inode *dir,
332
+ struct nfs4_change_info *cinfo,
333
+ unsigned long timestamp,
334
+ unsigned long cache_validity);
335
+extern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
336
+ struct page **pages);
313337
314338 #if defined(CONFIG_NFS_V4_1)
315339 extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
316
-extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
317
-extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
318
-extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
319
- struct nfs_fsinfo *fsinfo);
340
+extern int nfs4_proc_create_session(struct nfs_client *, const struct cred *);
341
+extern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *);
320342 extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
321343 bool sync);
322344 extern int nfs4_detect_session_trunking(struct nfs_client *clp,
....@@ -339,7 +361,6 @@
339361 _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
340362 struct rpc_clnt **clntp, struct rpc_message *msg)
341363 {
342
- struct rpc_cred *newcred = NULL;
343364 rpc_authflavor_t flavor;
344365
345366 if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP ||
....@@ -354,13 +375,7 @@
354375 return false;
355376 }
356377 if (test_bit(sp4_mode, &clp->cl_sp4_flags)) {
357
- spin_lock(&clp->cl_lock);
358
- if (clp->cl_machine_cred != NULL)
359
- /* don't call get_rpccred on the machine cred -
360
- * a reference will be held for life of clp */
361
- newcred = clp->cl_machine_cred;
362
- spin_unlock(&clp->cl_lock);
363
- msg->rpc_cred = newcred;
378
+ msg->rpc_cred = rpc_machine_cred();
364379
365380 flavor = clp->cl_rpcclient->cl_auth->au_flavor;
366381 WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I &&
....@@ -445,31 +460,33 @@
445460 extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
446461 extern void nfs4_kill_renewd(struct nfs_client *);
447462 extern void nfs4_renew_state(struct work_struct *);
448
-extern void nfs4_set_lease_period(struct nfs_client *clp,
449
- unsigned long lease,
450
- unsigned long lastrenewed);
463
+extern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease);
451464
452465
453466 /* nfs4state.c */
454
-struct rpc_cred *nfs4_get_clid_cred(struct nfs_client *clp);
455
-struct rpc_cred *nfs4_get_machine_cred_locked(struct nfs_client *clp);
456
-struct rpc_cred *nfs4_get_renew_cred_locked(struct nfs_client *clp);
467
+extern const nfs4_stateid current_stateid;
468
+
469
+const struct cred *nfs4_get_clid_cred(struct nfs_client *clp);
470
+const struct cred *nfs4_get_machine_cred(struct nfs_client *clp);
471
+const struct cred *nfs4_get_renew_cred(struct nfs_client *clp);
457472 int nfs4_discover_server_trunking(struct nfs_client *clp,
458473 struct nfs_client **);
459474 int nfs40_discover_server_trunking(struct nfs_client *clp,
460
- struct nfs_client **, struct rpc_cred *);
475
+ struct nfs_client **, const struct cred *);
461476 #if defined(CONFIG_NFS_V4_1)
462477 int nfs41_discover_server_trunking(struct nfs_client *clp,
463
- struct nfs_client **, struct rpc_cred *);
478
+ struct nfs_client **, const struct cred *);
464479 extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
465480 extern void nfs41_notify_server(struct nfs_client *);
481
+bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1,
482
+ struct nfs41_server_owner *o2);
466483 #else
467484 static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
468485 {
469486 }
470487 #endif /* CONFIG_NFS_V4_1 */
471488
472
-extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *, gfp_t);
489
+extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t);
473490 extern void nfs4_put_state_owner(struct nfs4_state_owner *);
474491 extern void nfs4_purge_state_owners(struct nfs_server *, struct list_head *);
475492 extern void nfs4_free_state_owners(struct list_head *head);
....@@ -496,9 +513,7 @@
496513 extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
497514 extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
498515 const struct nfs_lock_context *, nfs4_stateid *,
499
- struct rpc_cred **);
500
-extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst,
501
- struct nfs4_state *state);
516
+ const struct cred **);
502517 extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
503518 struct nfs4_state *state);
504519
....@@ -523,7 +538,6 @@
523538 /* nfs4super.c */
524539 struct nfs_mount_info;
525540 extern struct nfs_subversion nfs_v4;
526
-struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct nfs_subversion *);
527541 extern bool nfs4_disable_idmapping;
528542 extern unsigned short max_session_slots;
529543 extern unsigned short max_session_cb_slots;
....@@ -532,6 +546,9 @@
532546
533547 #define NFS4_CLIENT_ID_UNIQ_LEN (64)
534548 extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
549
+
550
+extern int nfs4_try_get_tree(struct fs_context *);
551
+extern int nfs4_get_referral_tree(struct fs_context *);
535552
536553 /* nfs4sysctl.c */
537554 #ifdef CONFIG_SYSCTL
....@@ -550,6 +567,12 @@
550567
551568 /* nfs4xdr.c */
552569 extern const struct rpc_procinfo nfs4_procedures[];
570
+
571
+#ifdef CONFIG_NFS_V4_2
572
+extern const u32 nfs42_maxsetxattr_overhead;
573
+extern const u32 nfs42_maxgetxattr_overhead;
574
+extern const u32 nfs42_maxlistxattrs_overhead;
575
+#endif
553576
554577 struct nfs4_mount_data;
555578
....@@ -580,6 +603,29 @@
580603 return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
581604 }
582605
606
+static inline bool nfs4_stateid_is_next(const nfs4_stateid *s1, const nfs4_stateid *s2)
607
+{
608
+ u32 seq1 = be32_to_cpu(s1->seqid);
609
+ u32 seq2 = be32_to_cpu(s2->seqid);
610
+
611
+ return seq2 == seq1 + 1U || (seq2 == 1U && seq1 == 0xffffffffU);
612
+}
613
+
614
+static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src)
615
+{
616
+ return nfs4_stateid_match_other(dst, src) &&
617
+ !(src->seqid && nfs4_stateid_is_newer(dst, src));
618
+}
619
+
620
+static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1)
621
+{
622
+ u32 seqid = be32_to_cpu(s1->seqid);
623
+
624
+ if (++seqid == 0)
625
+ ++seqid;
626
+ s1->seqid = cpu_to_be32(seqid);
627
+}
628
+
583629 static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
584630 {
585631 return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
....@@ -592,12 +638,34 @@
592638 nfs4_stateid_match_other(&state->open_stateid, stateid);
593639 }
594640
641
+/* nfs42xattr.c */
642
+#ifdef CONFIG_NFS_V4_2
643
+extern int __init nfs4_xattr_cache_init(void);
644
+extern void nfs4_xattr_cache_exit(void);
645
+extern void nfs4_xattr_cache_add(struct inode *inode, const char *name,
646
+ const char *buf, struct page **pages,
647
+ ssize_t buflen);
648
+extern void nfs4_xattr_cache_remove(struct inode *inode, const char *name);
649
+extern ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name,
650
+ char *buf, ssize_t buflen);
651
+extern void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
652
+ ssize_t buflen);
653
+extern ssize_t nfs4_xattr_cache_list(struct inode *inode, char *buf,
654
+ ssize_t buflen);
655
+extern void nfs4_xattr_cache_zap(struct inode *inode);
595656 #else
657
+static inline void nfs4_xattr_cache_zap(struct inode *inode)
658
+{
659
+}
660
+#endif /* CONFIG_NFS_V4_2 */
661
+
662
+#else /* CONFIG_NFS_V4 */
596663
597664 #define nfs4_close_state(a, b) do { } while (0)
598665 #define nfs4_close_sync(a, b) do { } while (0)
599666 #define nfs4_state_protect(a, b, c, d) do { } while (0)
600667 #define nfs4_state_protect_write(a, b, c, d) do { } while (0)
601668
669
+
602670 #endif /* CONFIG_NFS_V4 */
603671 #endif /* __LINUX_FS_NFS_NFS4_FS.H */