forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/fs/nfs/nfs4_fs.h
....@@ -42,7 +42,10 @@
4242 NFS4CLNT_LEASE_MOVED,
4343 NFS4CLNT_DELEGATION_EXPIRED,
4444 NFS4CLNT_RUN_MANAGER,
45
- NFS4CLNT_DELEGRETURN_RUNNING,
45
+ NFS4CLNT_RECALL_RUNNING,
46
+ NFS4CLNT_RECALL_ANY_LAYOUT_READ,
47
+ NFS4CLNT_RECALL_ANY_LAYOUT_RW,
48
+ NFS4CLNT_DELEGRETURN_DELAYED,
4649 };
4750
4851 #define NFS4_RENEW_TIMEOUT 0x01
....@@ -62,10 +65,11 @@
6265 void (*free_lock_state)(struct nfs_server *,
6366 struct nfs4_lock_state *);
6467 int (*test_and_free_expired)(struct nfs_server *,
65
- nfs4_stateid *, struct rpc_cred *);
68
+ nfs4_stateid *, const struct cred *);
6669 struct nfs_seqid *
6770 (*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
68
- int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *);
71
+ void (*session_trunk)(struct rpc_clnt *clnt,
72
+ struct rpc_xprt *xprt, void *data);
6973 const struct rpc_call_ops *call_sync_ops;
7074 const struct nfs4_state_recovery_ops *reboot_recovery_ops;
7175 const struct nfs4_state_recovery_ops *nograce_recovery_ops;
....@@ -107,14 +111,14 @@
107111 unsigned long so_expires;
108112 struct rb_node so_server_node;
109113
110
- struct rpc_cred *so_cred; /* Associated cred */
114
+ const struct cred *so_cred; /* Associated cred */
111115
112116 spinlock_t so_lock;
113117 atomic_t so_count;
114118 unsigned long so_flags;
115119 struct list_head so_states;
116120 struct nfs_seqid_counter so_seqid;
117
- seqcount_t so_reclaim_seqcount;
121
+ seqcount_spinlock_t so_reclaim_seqcount;
118122 struct mutex so_delegreturn_mutex;
119123 };
120124
....@@ -165,9 +169,9 @@
165169 NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */
166170 NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */
167171 NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */
168
-#ifdef CONFIG_NFS_V4_2
169172 NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/
170
-#endif /* CONFIG_NFS_V4_2 */
173
+ NFS_CLNT_SRC_SSC_COPY_STATE, /* src server open state on client*/
174
+ NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */
171175 };
172176
173177 struct nfs4_state {
....@@ -190,9 +194,10 @@
190194 unsigned int n_wronly; /* Number of write-only references */
191195 unsigned int n_rdwr; /* Number of read/write references */
192196 fmode_t state; /* State on the server (R,W, or RW) */
193
- atomic_t count;
197
+ refcount_t count;
194198
195199 wait_queue_head_t waitq;
200
+ struct rcu_head rcu_head;
196201 };
197202
198203
....@@ -205,6 +210,7 @@
205210 unsigned char delay : 1,
206211 recovering : 1,
207212 retry : 1;
213
+ bool interruptible;
208214 };
209215
210216 struct nfs4_state_recovery_ops {
....@@ -212,10 +218,10 @@
212218 int state_flag_bit;
213219 int (*recover_open)(struct nfs4_state_owner *, struct nfs4_state *);
214220 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 *);
221
+ int (*establish_clid)(struct nfs_client *, const struct cred *);
222
+ int (*reclaim_complete)(struct nfs_client *, const struct cred *);
217223 int (*detect_trunking)(struct nfs_client *, struct nfs_client **,
218
- struct rpc_cred *);
224
+ const struct cred *);
219225 };
220226
221227 struct nfs4_opendata {
....@@ -245,19 +251,19 @@
245251
246252 struct nfs4_add_xprt_data {
247253 struct nfs_client *clp;
248
- struct rpc_cred *cred;
254
+ const struct cred *cred;
249255 };
250256
251257 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 *);
258
+ int (*sched_state_renewal)(struct nfs_client *, const struct cred *, unsigned);
259
+ const struct cred * (*get_state_renewal_cred)(struct nfs_client *);
260
+ int (*renew_lease)(struct nfs_client *, const struct cred *);
255261 };
256262
257263 struct nfs4_mig_recovery_ops {
258264 int (*get_locations)(struct inode *, struct nfs4_fs_locations *,
259
- struct page *, struct rpc_cred *);
260
- int (*fsid_present)(struct inode *, struct rpc_cred *);
265
+ struct page *, const struct cred *);
266
+ int (*fsid_present)(struct inode *, const struct cred *);
261267 };
262268
263269 extern const struct dentry_operations nfs4_dentry_operations;
....@@ -266,18 +272,17 @@
266272 int nfs_atomic_open(struct inode *, struct dentry *, struct file *,
267273 unsigned, umode_t);
268274
269
-/* super.c */
275
+/* fs_context.c */
270276 extern struct file_system_type nfs4_fs_type;
271277
272278 /* nfs4namespace.c */
273279 struct rpc_clnt *nfs4_negotiate_security(struct rpc_clnt *, struct inode *,
274280 const struct qstr *);
275
-struct vfsmount *nfs4_submount(struct nfs_server *, struct dentry *,
276
- struct nfs_fh *, struct nfs_fattr *);
281
+int nfs4_submount(struct fs_context *, struct nfs_server *);
277282 int nfs4_replace_transport(struct nfs_server *server,
278283 const struct nfs4_fs_locations *locations);
279284 size_t nfs_parse_server_name(char *string, size_t len, struct sockaddr *sa,
280
- size_t salen, struct net *net);
285
+ size_t salen, struct net *net, int port);
281286 /* nfs4proc.c */
282287 extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception *);
283288 extern int nfs4_async_handle_error(struct rpc_task *task,
....@@ -287,36 +292,52 @@
287292 struct rpc_message *, struct nfs4_sequence_args *,
288293 struct nfs4_sequence_res *, int);
289294 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 *);
295
+extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, const struct cred *, struct nfs4_setclientid_res *);
296
+extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, const struct cred *);
292297 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);
298
+extern int nfs4_proc_bind_conn_to_session(struct nfs_client *, const struct cred *cred);
299
+extern int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred);
295300 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 *);
301
+extern int nfs4_init_clientid(struct nfs_client *, const struct cred *);
302
+extern int nfs41_init_clientid(struct nfs_client *, const struct cred *);
298303 extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait);
299304 extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
300305 extern int nfs4_proc_fs_locations(struct rpc_clnt *, struct inode *, const struct qstr *,
301306 struct nfs4_fs_locations *, struct page *);
302307 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 *);
308
+ struct page *page, const struct cred *);
309
+extern int nfs4_proc_fsid_present(struct inode *, const struct cred *);
310
+extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *,
311
+ struct dentry *,
312
+ struct nfs_fh *,
313
+ struct nfs_fattr *);
307314 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
308315 extern const struct xattr_handler *nfs4_xattr_handlers[];
309316 extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
310317 const struct nfs_open_context *ctx,
311318 const struct nfs_lock_context *l_ctx,
312319 fmode_t fmode);
320
+extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
321
+ struct nfs_fattr *fattr, struct nfs4_label *label,
322
+ struct inode *inode);
323
+extern int update_open_stateid(struct nfs4_state *state,
324
+ const nfs4_stateid *open_stateid,
325
+ const nfs4_stateid *deleg_stateid,
326
+ fmode_t fmode);
327
+
328
+extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
329
+ struct nfs_fsinfo *fsinfo);
330
+extern void nfs4_update_changeattr(struct inode *dir,
331
+ struct nfs4_change_info *cinfo,
332
+ unsigned long timestamp,
333
+ unsigned long cache_validity);
334
+extern int nfs4_buf_to_pages_noslab(const void *buf, size_t buflen,
335
+ struct page **pages);
313336
314337 #if defined(CONFIG_NFS_V4_1)
315338 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);
339
+extern int nfs4_proc_create_session(struct nfs_client *, const struct cred *);
340
+extern int nfs4_proc_destroy_session(struct nfs4_session *, const struct cred *);
320341 extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
321342 bool sync);
322343 extern int nfs4_detect_session_trunking(struct nfs_client *clp,
....@@ -339,7 +360,6 @@
339360 _nfs4_state_protect(struct nfs_client *clp, unsigned long sp4_mode,
340361 struct rpc_clnt **clntp, struct rpc_message *msg)
341362 {
342
- struct rpc_cred *newcred = NULL;
343363 rpc_authflavor_t flavor;
344364
345365 if (sp4_mode == NFS_SP4_MACH_CRED_CLEANUP ||
....@@ -354,13 +374,7 @@
354374 return false;
355375 }
356376 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;
377
+ msg->rpc_cred = rpc_machine_cred();
364378
365379 flavor = clp->cl_rpcclient->cl_auth->au_flavor;
366380 WARN_ON_ONCE(flavor != RPC_AUTH_GSS_KRB5I &&
....@@ -445,31 +459,33 @@
445459 extern void nfs4_renewd_prepare_shutdown(struct nfs_server *);
446460 extern void nfs4_kill_renewd(struct nfs_client *);
447461 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);
462
+extern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease);
451463
452464
453465 /* 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);
466
+extern const nfs4_stateid current_stateid;
467
+
468
+const struct cred *nfs4_get_clid_cred(struct nfs_client *clp);
469
+const struct cred *nfs4_get_machine_cred(struct nfs_client *clp);
470
+const struct cred *nfs4_get_renew_cred(struct nfs_client *clp);
457471 int nfs4_discover_server_trunking(struct nfs_client *clp,
458472 struct nfs_client **);
459473 int nfs40_discover_server_trunking(struct nfs_client *clp,
460
- struct nfs_client **, struct rpc_cred *);
474
+ struct nfs_client **, const struct cred *);
461475 #if defined(CONFIG_NFS_V4_1)
462476 int nfs41_discover_server_trunking(struct nfs_client *clp,
463
- struct nfs_client **, struct rpc_cred *);
477
+ struct nfs_client **, const struct cred *);
464478 extern void nfs4_schedule_session_recovery(struct nfs4_session *, int);
465479 extern void nfs41_notify_server(struct nfs_client *);
480
+bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1,
481
+ struct nfs41_server_owner *o2);
466482 #else
467483 static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err)
468484 {
469485 }
470486 #endif /* CONFIG_NFS_V4_1 */
471487
472
-extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, struct rpc_cred *, gfp_t);
488
+extern struct nfs4_state_owner *nfs4_get_state_owner(struct nfs_server *, const struct cred *, gfp_t);
473489 extern void nfs4_put_state_owner(struct nfs4_state_owner *);
474490 extern void nfs4_purge_state_owners(struct nfs_server *, struct list_head *);
475491 extern void nfs4_free_state_owners(struct list_head *head);
....@@ -496,9 +512,7 @@
496512 extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
497513 extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t,
498514 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);
515
+ const struct cred **);
502516 extern bool nfs4_copy_open_stateid(nfs4_stateid *dst,
503517 struct nfs4_state *state);
504518
....@@ -523,7 +537,6 @@
523537 /* nfs4super.c */
524538 struct nfs_mount_info;
525539 extern struct nfs_subversion nfs_v4;
526
-struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct nfs_subversion *);
527540 extern bool nfs4_disable_idmapping;
528541 extern unsigned short max_session_slots;
529542 extern unsigned short max_session_cb_slots;
....@@ -532,6 +545,9 @@
532545
533546 #define NFS4_CLIENT_ID_UNIQ_LEN (64)
534547 extern char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN];
548
+
549
+extern int nfs4_try_get_tree(struct fs_context *);
550
+extern int nfs4_get_referral_tree(struct fs_context *);
535551
536552 /* nfs4sysctl.c */
537553 #ifdef CONFIG_SYSCTL
....@@ -550,6 +566,12 @@
550566
551567 /* nfs4xdr.c */
552568 extern const struct rpc_procinfo nfs4_procedures[];
569
+
570
+#ifdef CONFIG_NFS_V4_2
571
+extern const u32 nfs42_maxsetxattr_overhead;
572
+extern const u32 nfs42_maxgetxattr_overhead;
573
+extern const u32 nfs42_maxlistxattrs_overhead;
574
+#endif
553575
554576 struct nfs4_mount_data;
555577
....@@ -580,6 +602,29 @@
580602 return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0;
581603 }
582604
605
+static inline bool nfs4_stateid_is_next(const nfs4_stateid *s1, const nfs4_stateid *s2)
606
+{
607
+ u32 seq1 = be32_to_cpu(s1->seqid);
608
+ u32 seq2 = be32_to_cpu(s2->seqid);
609
+
610
+ return seq2 == seq1 + 1U || (seq2 == 1U && seq1 == 0xffffffffU);
611
+}
612
+
613
+static inline bool nfs4_stateid_match_or_older(const nfs4_stateid *dst, const nfs4_stateid *src)
614
+{
615
+ return nfs4_stateid_match_other(dst, src) &&
616
+ !(src->seqid && nfs4_stateid_is_newer(dst, src));
617
+}
618
+
619
+static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1)
620
+{
621
+ u32 seqid = be32_to_cpu(s1->seqid);
622
+
623
+ if (++seqid == 0)
624
+ ++seqid;
625
+ s1->seqid = cpu_to_be32(seqid);
626
+}
627
+
583628 static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state)
584629 {
585630 return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0;
....@@ -592,12 +637,34 @@
592637 nfs4_stateid_match_other(&state->open_stateid, stateid);
593638 }
594639
640
+/* nfs42xattr.c */
641
+#ifdef CONFIG_NFS_V4_2
642
+extern int __init nfs4_xattr_cache_init(void);
643
+extern void nfs4_xattr_cache_exit(void);
644
+extern void nfs4_xattr_cache_add(struct inode *inode, const char *name,
645
+ const char *buf, struct page **pages,
646
+ ssize_t buflen);
647
+extern void nfs4_xattr_cache_remove(struct inode *inode, const char *name);
648
+extern ssize_t nfs4_xattr_cache_get(struct inode *inode, const char *name,
649
+ char *buf, ssize_t buflen);
650
+extern void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
651
+ ssize_t buflen);
652
+extern ssize_t nfs4_xattr_cache_list(struct inode *inode, char *buf,
653
+ ssize_t buflen);
654
+extern void nfs4_xattr_cache_zap(struct inode *inode);
595655 #else
656
+static inline void nfs4_xattr_cache_zap(struct inode *inode)
657
+{
658
+}
659
+#endif /* CONFIG_NFS_V4_2 */
660
+
661
+#else /* CONFIG_NFS_V4 */
596662
597663 #define nfs4_close_state(a, b) do { } while (0)
598664 #define nfs4_close_sync(a, b) do { } while (0)
599665 #define nfs4_state_protect(a, b, c, d) do { } while (0)
600666 #define nfs4_state_protect_write(a, b, c, d) do { } while (0)
601667
668
+
602669 #endif /* CONFIG_NFS_V4 */
603670 #endif /* __LINUX_FS_NFS_NFS4_FS.H */