hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/nfs_fs.h
....@@ -51,7 +51,7 @@
5151 struct nfs_access_entry {
5252 struct rb_node rb_node;
5353 struct list_head lru;
54
- struct rpc_cred * cred;
54
+ const struct cred * cred;
5555 __u32 mask;
5656 struct rcu_head rcu_head;
5757 };
....@@ -62,6 +62,7 @@
6262 struct nfs_open_context *open_context;
6363 fl_owner_t lockowner;
6464 atomic_t io_count;
65
+ struct rcu_head rcu_head;
6566 };
6667
6768 struct nfs4_state;
....@@ -69,12 +70,12 @@
6970 struct nfs_lock_context lock_context;
7071 fl_owner_t flock_owner;
7172 struct dentry *dentry;
72
- struct rpc_cred *cred;
73
+ const struct cred *cred;
74
+ struct rpc_cred *ll_cred; /* low-level cred - use to check for expiry */
7375 struct nfs4_state *state;
7476 fmode_t mode;
7577
7678 unsigned long flags;
77
-#define NFS_CONTEXT_ERROR_WRITE (0)
7879 #define NFS_CONTEXT_RESEND_WRITES (1)
7980 #define NFS_CONTEXT_BAD (2)
8081 #define NFS_CONTEXT_UNLOCK (3)
....@@ -83,11 +84,12 @@
8384
8485 struct list_head list;
8586 struct nfs4_threshold *mdsthreshold;
87
+ struct rcu_head rcu_head;
8688 };
8789
8890 struct nfs_open_dir_context {
8991 struct list_head list;
90
- struct rpc_cred *cred;
92
+ const struct cred *cred;
9193 unsigned long attr_gencount;
9294 __u64 dir_cookie;
9395 __u64 dup_cookie;
....@@ -100,6 +102,8 @@
100102 struct nfs_delegation;
101103
102104 struct posix_acl;
105
+
106
+struct nfs4_xattr_cache;
103107
104108 /*
105109 * nfs fs inode data in memory
....@@ -164,12 +168,11 @@
164168
165169 /* Readers: in-flight sillydelete RPC calls */
166170 /* Writers: rmdir */
167
-#ifdef CONFIG_PREEMPT_RT_BASE
168
- struct semaphore rmdir_sem;
169
-#else
170171 struct rw_semaphore rmdir_sem;
171
-#endif
172172 struct mutex commit_mutex;
173
+
174
+ /* track last access to cached pages */
175
+ unsigned long page_index;
173176
174177 #if IS_ENABLED(CONFIG_NFS_V4)
175178 struct nfs4_cached_acl *nfs4_acl;
....@@ -188,17 +191,23 @@
188191 struct fscache_cookie *fscache;
189192 #endif
190193 struct inode vfs_inode;
194
+
195
+#ifdef CONFIG_NFS_V4_2
196
+ struct nfs4_xattr_cache *xattr_cache;
197
+#endif
191198 };
192199
193200 struct nfs4_copy_state {
194201 struct list_head copies;
202
+ struct list_head src_copies;
195203 nfs4_stateid stateid;
196204 struct completion completion;
197205 uint64_t count;
198206 struct nfs_writeverf verf;
199207 int error;
200208 int flags;
201
- struct nfs4_state *parent_state;
209
+ struct nfs4_state *parent_src_state;
210
+ struct nfs4_state *parent_dst_state;
202211 };
203212
204213 /*
....@@ -210,6 +219,9 @@
210219 #define NFS_ACCESS_EXTEND 0x0008
211220 #define NFS_ACCESS_DELETE 0x0010
212221 #define NFS_ACCESS_EXECUTE 0x0020
222
+#define NFS_ACCESS_XAREAD 0x0040
223
+#define NFS_ACCESS_XAWRITE 0x0080
224
+#define NFS_ACCESS_XALIST 0x0100
213225
214226 /*
215227 * Cache validity bit flags
....@@ -226,6 +238,10 @@
226238 #define NFS_INO_INVALID_MTIME BIT(10) /* cached mtime is invalid */
227239 #define NFS_INO_INVALID_SIZE BIT(11) /* cached size is invalid */
228240 #define NFS_INO_INVALID_OTHER BIT(12) /* other attrs are invalid */
241
+#define NFS_INO_DATA_INVAL_DEFER \
242
+ BIT(13) /* Deferred cache invalidation */
243
+#define NFS_INO_INVALID_BLOCKS BIT(14) /* cached blocks are invalid */
244
+#define NFS_INO_INVALID_XATTR BIT(15) /* xattrs are invalid */
229245
230246 #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
231247 | NFS_INO_INVALID_CTIME \
....@@ -333,33 +349,15 @@
333349 return NFS_SERVER(inode)->caps & cap;
334350 }
335351
336
-static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
337
-{
338
- dentry->d_time = verf;
339
-}
340
-
341352 /**
342353 * nfs_save_change_attribute - Returns the inode attribute change cookie
343354 * @dir - pointer to parent directory inode
344
- * The "change attribute" is updated every time we finish an operation
345
- * that will result in a metadata change on the server.
355
+ * The "cache change attribute" is updated when we need to revalidate
356
+ * our dentry cache after a directory was seen to change on the server.
346357 */
347358 static inline unsigned long nfs_save_change_attribute(struct inode *dir)
348359 {
349360 return NFS_I(dir)->cache_change_attribute;
350
-}
351
-
352
-/**
353
- * nfs_verify_change_attribute - Detects NFS remote directory changes
354
- * @dir - pointer to parent directory inode
355
- * @chattr - previously saved change attribute
356
- * Return "false" if the verifiers doesn't match the change attribute.
357
- * This would usually indicate that the directory contents have changed on
358
- * the server, and that any dentries need revalidating.
359
- */
360
-static inline int nfs_verify_change_attribute(struct inode *dir, unsigned long chattr)
361
-{
362
- return chattr == NFS_I(dir)->cache_change_attribute;
363361 }
364362
365363 /*
....@@ -368,6 +366,7 @@
368366 extern int nfs_sync_mapping(struct address_space *mapping);
369367 extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
370368 extern void nfs_zap_caches(struct inode *);
369
+extern void nfs_set_inode_stale(struct inode *inode);
371370 extern void nfs_invalidate_atime(struct inode *);
372371 extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
373372 struct nfs_fattr *, struct nfs4_label *);
....@@ -393,7 +392,7 @@
393392 struct nfs4_label *label);
394393 extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
395394 extern void put_nfs_open_context(struct nfs_open_context *ctx);
396
-extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
395
+extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode);
397396 extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp);
398397 extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
399398 extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
....@@ -464,7 +463,7 @@
464463 return filp->private_data;
465464 }
466465
467
-static inline struct rpc_cred *nfs_file_cred(struct file *file)
466
+static inline const struct cred *nfs_file_cred(struct file *file)
468467 {
469468 if (file != NULL) {
470469 struct nfs_open_context *ctx =
....@@ -479,10 +478,10 @@
479478 * linux/fs/nfs/direct.c
480479 */
481480 extern ssize_t nfs_direct_IO(struct kiocb *, struct iov_iter *);
482
-extern ssize_t nfs_file_direct_read(struct kiocb *iocb,
483
- struct iov_iter *iter);
484
-extern ssize_t nfs_file_direct_write(struct kiocb *iocb,
485
- struct iov_iter *iter);
481
+ssize_t nfs_file_direct_read(struct kiocb *iocb,
482
+ struct iov_iter *iter, bool swap);
483
+ssize_t nfs_file_direct_write(struct kiocb *iocb,
484
+ struct iov_iter *iter, bool swap);
486485
487486 /*
488487 * linux/fs/nfs/dir.c
....@@ -491,10 +490,19 @@
491490 extern const struct dentry_operations nfs_dentry_operations;
492491
493492 extern void nfs_force_lookup_revalidate(struct inode *dir);
493
+extern void nfs_set_verifier(struct dentry * dentry, unsigned long verf);
494
+#if IS_ENABLED(CONFIG_NFS_V4)
495
+extern void nfs_clear_verifier_delegated(struct inode *inode);
496
+#endif /* IS_ENABLED(CONFIG_NFS_V4) */
497
+extern struct dentry *nfs_add_or_obtain(struct dentry *dentry,
498
+ struct nfs_fh *fh, struct nfs_fattr *fattr,
499
+ struct nfs4_label *label);
494500 extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
495501 struct nfs_fattr *fattr, struct nfs4_label *label);
496
-extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags);
502
+extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
497503 extern void nfs_access_zap_cache(struct inode *inode);
504
+extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
505
+ u32 *mask, bool may_block);
498506
499507 /*
500508 * linux/fs/nfs/symlink.c
....@@ -543,8 +551,9 @@
543551 extern int nfs_wb_page(struct inode *inode, struct page *page);
544552 extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
545553 extern int nfs_commit_inode(struct inode *, int);
546
-extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail);
554
+extern struct nfs_commit_data *nfs_commitdata_alloc(void);
547555 extern void nfs_commit_free(struct nfs_commit_data *data);
556
+bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
548557
549558 static inline int
550559 nfs_have_writebacks(struct inode *inode)