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
....@@ -167,6 +171,9 @@
167171 struct rw_semaphore rmdir_sem;
168172 struct mutex commit_mutex;
169173
174
+ /* track last access to cached pages */
175
+ unsigned long page_index;
176
+
170177 #if IS_ENABLED(CONFIG_NFS_V4)
171178 struct nfs4_cached_acl *nfs4_acl;
172179 /* NFSv4 state */
....@@ -184,17 +191,23 @@
184191 struct fscache_cookie *fscache;
185192 #endif
186193 struct inode vfs_inode;
194
+
195
+#ifdef CONFIG_NFS_V4_2
196
+ struct nfs4_xattr_cache *xattr_cache;
197
+#endif
187198 };
188199
189200 struct nfs4_copy_state {
190201 struct list_head copies;
202
+ struct list_head src_copies;
191203 nfs4_stateid stateid;
192204 struct completion completion;
193205 uint64_t count;
194206 struct nfs_writeverf verf;
195207 int error;
196208 int flags;
197
- struct nfs4_state *parent_state;
209
+ struct nfs4_state *parent_src_state;
210
+ struct nfs4_state *parent_dst_state;
198211 };
199212
200213 /*
....@@ -206,6 +219,9 @@
206219 #define NFS_ACCESS_EXTEND 0x0008
207220 #define NFS_ACCESS_DELETE 0x0010
208221 #define NFS_ACCESS_EXECUTE 0x0020
222
+#define NFS_ACCESS_XAREAD 0x0040
223
+#define NFS_ACCESS_XAWRITE 0x0080
224
+#define NFS_ACCESS_XALIST 0x0100
209225
210226 /*
211227 * Cache validity bit flags
....@@ -222,6 +238,10 @@
222238 #define NFS_INO_INVALID_MTIME BIT(10) /* cached mtime is invalid */
223239 #define NFS_INO_INVALID_SIZE BIT(11) /* cached size is invalid */
224240 #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 */
225245
226246 #define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
227247 | NFS_INO_INVALID_CTIME \
....@@ -329,33 +349,15 @@
329349 return NFS_SERVER(inode)->caps & cap;
330350 }
331351
332
-static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
333
-{
334
- dentry->d_time = verf;
335
-}
336
-
337352 /**
338353 * nfs_save_change_attribute - Returns the inode attribute change cookie
339354 * @dir - pointer to parent directory inode
340
- * The "change attribute" is updated every time we finish an operation
341
- * 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.
342357 */
343358 static inline unsigned long nfs_save_change_attribute(struct inode *dir)
344359 {
345360 return NFS_I(dir)->cache_change_attribute;
346
-}
347
-
348
-/**
349
- * nfs_verify_change_attribute - Detects NFS remote directory changes
350
- * @dir - pointer to parent directory inode
351
- * @chattr - previously saved change attribute
352
- * Return "false" if the verifiers doesn't match the change attribute.
353
- * This would usually indicate that the directory contents have changed on
354
- * the server, and that any dentries need revalidating.
355
- */
356
-static inline int nfs_verify_change_attribute(struct inode *dir, unsigned long chattr)
357
-{
358
- return chattr == NFS_I(dir)->cache_change_attribute;
359361 }
360362
361363 /*
....@@ -364,6 +366,7 @@
364366 extern int nfs_sync_mapping(struct address_space *mapping);
365367 extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
366368 extern void nfs_zap_caches(struct inode *);
369
+extern void nfs_set_inode_stale(struct inode *inode);
367370 extern void nfs_invalidate_atime(struct inode *);
368371 extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
369372 struct nfs_fattr *, struct nfs4_label *);
....@@ -389,7 +392,7 @@
389392 struct nfs4_label *label);
390393 extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
391394 extern void put_nfs_open_context(struct nfs_open_context *ctx);
392
-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);
393396 extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp);
394397 extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
395398 extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
....@@ -460,7 +463,7 @@
460463 return filp->private_data;
461464 }
462465
463
-static inline struct rpc_cred *nfs_file_cred(struct file *file)
466
+static inline const struct cred *nfs_file_cred(struct file *file)
464467 {
465468 if (file != NULL) {
466469 struct nfs_open_context *ctx =
....@@ -475,10 +478,10 @@
475478 * linux/fs/nfs/direct.c
476479 */
477480 extern ssize_t nfs_direct_IO(struct kiocb *, struct iov_iter *);
478
-extern ssize_t nfs_file_direct_read(struct kiocb *iocb,
479
- struct iov_iter *iter);
480
-extern ssize_t nfs_file_direct_write(struct kiocb *iocb,
481
- 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);
482485
483486 /*
484487 * linux/fs/nfs/dir.c
....@@ -487,10 +490,19 @@
487490 extern const struct dentry_operations nfs_dentry_operations;
488491
489492 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);
490500 extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
491501 struct nfs_fattr *fattr, struct nfs4_label *label);
492
-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);
493503 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);
494506
495507 /*
496508 * linux/fs/nfs/symlink.c
....@@ -539,8 +551,9 @@
539551 extern int nfs_wb_page(struct inode *inode, struct page *page);
540552 extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
541553 extern int nfs_commit_inode(struct inode *, int);
542
-extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail);
554
+extern struct nfs_commit_data *nfs_commitdata_alloc(void);
543555 extern void nfs_commit_free(struct nfs_commit_data *data);
556
+bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
544557
545558 static inline int
546559 nfs_have_writebacks(struct inode *inode)