Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  linux/include/linux/nfs_fs.h
0004  *
0005  *  Copyright (C) 1992  Rick Sladkey
0006  *
0007  *  OS-specific nfs filesystem definitions and declarations
0008  */
0009 #ifndef _LINUX_NFS_FS_H
0010 #define _LINUX_NFS_FS_H
0011 
0012 #include <uapi/linux/nfs_fs.h>
0013 
0014 
0015 /*
0016  * Enable dprintk() debugging support for nfs client.
0017  */
0018 #ifdef CONFIG_NFS_DEBUG
0019 # define NFS_DEBUG
0020 #endif
0021 
0022 #include <linux/in.h>
0023 #include <linux/mm.h>
0024 #include <linux/pagemap.h>
0025 #include <linux/rbtree.h>
0026 #include <linux/refcount.h>
0027 #include <linux/rwsem.h>
0028 #include <linux/wait.h>
0029 
0030 #include <linux/sunrpc/debug.h>
0031 #include <linux/sunrpc/auth.h>
0032 #include <linux/sunrpc/clnt.h>
0033 
0034 #include <linux/nfs.h>
0035 #include <linux/nfs2.h>
0036 #include <linux/nfs3.h>
0037 #include <linux/nfs4.h>
0038 #include <linux/nfs_xdr.h>
0039 #include <linux/nfs_fs_sb.h>
0040 
0041 #include <linux/mempool.h>
0042 
0043 /*
0044  * These are the default for number of transports to different server IPs
0045  */
0046 #define NFS_MAX_TRANSPORTS 16
0047 
0048 /*
0049  * Size of the NFS directory verifier
0050  */
0051 #define NFS_DIR_VERIFIER_SIZE       2
0052 
0053 /*
0054  * NFSv3/v4 Access mode cache entry
0055  */
0056 struct nfs_access_entry {
0057     struct rb_node      rb_node;
0058     struct list_head    lru;
0059     kuid_t          fsuid;
0060     kgid_t          fsgid;
0061     struct group_info   *group_info;
0062     __u32           mask;
0063     struct rcu_head     rcu_head;
0064 };
0065 
0066 struct nfs_lock_context {
0067     refcount_t count;
0068     struct list_head list;
0069     struct nfs_open_context *open_context;
0070     fl_owner_t lockowner;
0071     atomic_t io_count;
0072     struct rcu_head rcu_head;
0073 };
0074 
0075 struct nfs4_state;
0076 struct nfs_open_context {
0077     struct nfs_lock_context lock_context;
0078     fl_owner_t flock_owner;
0079     struct dentry *dentry;
0080     const struct cred *cred;
0081     struct rpc_cred __rcu *ll_cred; /* low-level cred - use to check for expiry */
0082     struct nfs4_state *state;
0083     fmode_t mode;
0084 
0085     unsigned long flags;
0086 #define NFS_CONTEXT_BAD         (2)
0087 #define NFS_CONTEXT_UNLOCK  (3)
0088 #define NFS_CONTEXT_FILE_OPEN       (4)
0089     int error;
0090 
0091     struct list_head list;
0092     struct nfs4_threshold   *mdsthreshold;
0093     struct rcu_head rcu_head;
0094 };
0095 
0096 struct nfs_open_dir_context {
0097     struct list_head list;
0098     atomic_t cache_hits;
0099     atomic_t cache_misses;
0100     unsigned long attr_gencount;
0101     __be32  verf[NFS_DIR_VERIFIER_SIZE];
0102     __u64 dir_cookie;
0103     __u64 last_cookie;
0104     pgoff_t page_index;
0105     unsigned int dtsize;
0106     bool force_clear;
0107     bool eof;
0108     struct rcu_head rcu_head;
0109 };
0110 
0111 /*
0112  * NFSv4 delegation
0113  */
0114 struct nfs_delegation;
0115 
0116 struct posix_acl;
0117 
0118 struct nfs4_xattr_cache;
0119 
0120 /*
0121  * nfs fs inode data in memory
0122  */
0123 struct nfs_inode {
0124     /*
0125      * The 64bit 'inode number'
0126      */
0127     __u64 fileid;
0128 
0129     /*
0130      * NFS file handle
0131      */
0132     struct nfs_fh       fh;
0133 
0134     /*
0135      * Various flags
0136      */
0137     unsigned long       flags;          /* atomic bit ops */
0138     unsigned long       cache_validity;     /* bit mask */
0139 
0140     /*
0141      * read_cache_jiffies is when we started read-caching this inode.
0142      * attrtimeo is for how long the cached information is assumed
0143      * to be valid. A successful attribute revalidation doubles
0144      * attrtimeo (up to acregmax/acdirmax), a failure resets it to
0145      * acregmin/acdirmin.
0146      *
0147      * We need to revalidate the cached attrs for this inode if
0148      *
0149      *  jiffies - read_cache_jiffies >= attrtimeo
0150      *
0151      * Please note the comparison is greater than or equal
0152      * so that zero timeout values can be specified.
0153      */
0154     unsigned long       read_cache_jiffies;
0155     unsigned long       attrtimeo;
0156     unsigned long       attrtimeo_timestamp;
0157 
0158     unsigned long       attr_gencount;
0159 
0160     struct rb_root      access_cache;
0161     struct list_head    access_cache_entry_lru;
0162     struct list_head    access_cache_inode_lru;
0163 
0164     union {
0165         /* Directory */
0166         struct {
0167             /* "Generation counter" for the attribute cache.
0168              * This is bumped whenever we update the metadata
0169              * on the server.
0170              */
0171             unsigned long   cache_change_attribute;
0172             /*
0173              * This is the cookie verifier used for NFSv3 readdir
0174              * operations
0175              */
0176             __be32      cookieverf[NFS_DIR_VERIFIER_SIZE];
0177             /* Readers: in-flight sillydelete RPC calls */
0178             /* Writers: rmdir */
0179             struct rw_semaphore rmdir_sem;
0180         };
0181         /* Regular file */
0182         struct {
0183             atomic_long_t   nrequests;
0184             atomic_long_t   redirtied_pages;
0185             struct nfs_mds_commit_info commit_info;
0186             struct mutex    commit_mutex;
0187         };
0188     };
0189 
0190     /* Open contexts for shared mmap writes */
0191     struct list_head    open_files;
0192 
0193 #if IS_ENABLED(CONFIG_NFS_V4)
0194     struct nfs4_cached_acl  *nfs4_acl;
0195         /* NFSv4 state */
0196     struct list_head    open_states;
0197     struct nfs_delegation __rcu *delegation;
0198     struct rw_semaphore rwsem;
0199 
0200     /* pNFS layout information */
0201     struct pnfs_layout_hdr *layout;
0202 #endif /* CONFIG_NFS_V4*/
0203     /* how many bytes have been written/read and how many bytes queued up */
0204     __u64 write_io;
0205     __u64 read_io;
0206 #ifdef CONFIG_NFS_FSCACHE
0207     struct fscache_cookie   *fscache;
0208 #endif
0209     struct inode        vfs_inode;
0210 
0211 #ifdef CONFIG_NFS_V4_2
0212     struct nfs4_xattr_cache *xattr_cache;
0213 #endif
0214 };
0215 
0216 struct nfs4_copy_state {
0217     struct list_head    copies;
0218     struct list_head    src_copies;
0219     nfs4_stateid        stateid;
0220     struct completion   completion;
0221     uint64_t        count;
0222     struct nfs_writeverf    verf;
0223     int         error;
0224     int         flags;
0225     struct nfs4_state   *parent_src_state;
0226     struct nfs4_state   *parent_dst_state;
0227 };
0228 
0229 /*
0230  * Access bit flags
0231  */
0232 #define NFS_ACCESS_READ        0x0001
0233 #define NFS_ACCESS_LOOKUP      0x0002
0234 #define NFS_ACCESS_MODIFY      0x0004
0235 #define NFS_ACCESS_EXTEND      0x0008
0236 #define NFS_ACCESS_DELETE      0x0010
0237 #define NFS_ACCESS_EXECUTE     0x0020
0238 #define NFS_ACCESS_XAREAD      0x0040
0239 #define NFS_ACCESS_XAWRITE     0x0080
0240 #define NFS_ACCESS_XALIST      0x0100
0241 
0242 /*
0243  * Cache validity bit flags
0244  */
0245 #define NFS_INO_INVALID_DATA    BIT(1)      /* cached data is invalid */
0246 #define NFS_INO_INVALID_ATIME   BIT(2)      /* cached atime is invalid */
0247 #define NFS_INO_INVALID_ACCESS  BIT(3)      /* cached access cred invalid */
0248 #define NFS_INO_INVALID_ACL BIT(4)      /* cached acls are invalid */
0249 #define NFS_INO_REVAL_FORCED    BIT(6)      /* force revalidation ignoring a delegation */
0250 #define NFS_INO_INVALID_LABEL   BIT(7)      /* cached label is invalid */
0251 #define NFS_INO_INVALID_CHANGE  BIT(8)      /* cached change is invalid */
0252 #define NFS_INO_INVALID_CTIME   BIT(9)      /* cached ctime is invalid */
0253 #define NFS_INO_INVALID_MTIME   BIT(10)     /* cached mtime is invalid */
0254 #define NFS_INO_INVALID_SIZE    BIT(11)     /* cached size is invalid */
0255 #define NFS_INO_INVALID_OTHER   BIT(12)     /* other attrs are invalid */
0256 #define NFS_INO_DATA_INVAL_DEFER    \
0257                 BIT(13)     /* Deferred cache invalidation */
0258 #define NFS_INO_INVALID_BLOCKS  BIT(14)         /* cached blocks are invalid */
0259 #define NFS_INO_INVALID_XATTR   BIT(15)     /* xattrs are invalid */
0260 #define NFS_INO_INVALID_NLINK   BIT(16)     /* cached nlinks is invalid */
0261 #define NFS_INO_INVALID_MODE    BIT(17)     /* cached mode is invalid */
0262 
0263 #define NFS_INO_INVALID_ATTR    (NFS_INO_INVALID_CHANGE \
0264         | NFS_INO_INVALID_CTIME \
0265         | NFS_INO_INVALID_MTIME \
0266         | NFS_INO_INVALID_SIZE \
0267         | NFS_INO_INVALID_NLINK \
0268         | NFS_INO_INVALID_MODE \
0269         | NFS_INO_INVALID_OTHER)    /* inode metadata is invalid */
0270 
0271 /*
0272  * Bit offsets in flags field
0273  */
0274 #define NFS_INO_STALE       (1)     /* possible stale inode */
0275 #define NFS_INO_ACL_LRU_SET (2)     /* Inode is on the LRU list */
0276 #define NFS_INO_INVALIDATING    (3)     /* inode is being invalidated */
0277 #define NFS_INO_PRESERVE_UNLINKED (4)       /* preserve file if removed while open */
0278 #define NFS_INO_FSCACHE     (5)     /* inode can be cached by FS-Cache */
0279 #define NFS_INO_LAYOUTCOMMIT    (9)     /* layoutcommit required */
0280 #define NFS_INO_LAYOUTCOMMITTING (10)       /* layoutcommit inflight */
0281 #define NFS_INO_LAYOUTSTATS (11)        /* layoutstats inflight */
0282 #define NFS_INO_ODIRECT     (12)        /* I/O setting is O_DIRECT */
0283 
0284 static inline struct nfs_inode *NFS_I(const struct inode *inode)
0285 {
0286     return container_of(inode, struct nfs_inode, vfs_inode);
0287 }
0288 
0289 static inline struct nfs_server *NFS_SB(const struct super_block *s)
0290 {
0291     return (struct nfs_server *)(s->s_fs_info);
0292 }
0293 
0294 static inline struct nfs_fh *NFS_FH(const struct inode *inode)
0295 {
0296     return &NFS_I(inode)->fh;
0297 }
0298 
0299 static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
0300 {
0301     return NFS_SB(inode->i_sb);
0302 }
0303 
0304 static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
0305 {
0306     return NFS_SERVER(inode)->client;
0307 }
0308 
0309 static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
0310 {
0311     return NFS_SERVER(inode)->nfs_client->rpc_ops;
0312 }
0313 
0314 static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
0315 {
0316     struct nfs_server *nfss = NFS_SERVER(inode);
0317     return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
0318 }
0319 
0320 static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
0321 {
0322     struct nfs_server *nfss = NFS_SERVER(inode);
0323     return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
0324 }
0325 
0326 static inline int NFS_STALE(const struct inode *inode)
0327 {
0328     return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
0329 }
0330 
0331 static inline struct fscache_cookie *nfs_i_fscache(struct inode *inode)
0332 {
0333 #ifdef CONFIG_NFS_FSCACHE
0334     return NFS_I(inode)->fscache;
0335 #else
0336     return NULL;
0337 #endif
0338 }
0339 
0340 static inline __u64 NFS_FILEID(const struct inode *inode)
0341 {
0342     return NFS_I(inode)->fileid;
0343 }
0344 
0345 static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
0346 {
0347     NFS_I(inode)->fileid = fileid;
0348 }
0349 
0350 static inline void nfs_mark_for_revalidate(struct inode *inode)
0351 {
0352     struct nfs_inode *nfsi = NFS_I(inode);
0353 
0354     spin_lock(&inode->i_lock);
0355     nfsi->cache_validity |= NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
0356                 NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
0357                 NFS_INO_INVALID_SIZE;
0358     if (S_ISDIR(inode->i_mode))
0359         nfsi->cache_validity |= NFS_INO_INVALID_DATA;
0360     spin_unlock(&inode->i_lock);
0361 }
0362 
0363 static inline int nfs_server_capable(const struct inode *inode, int cap)
0364 {
0365     return NFS_SERVER(inode)->caps & cap;
0366 }
0367 
0368 /**
0369  * nfs_save_change_attribute - Returns the inode attribute change cookie
0370  * @dir - pointer to parent directory inode
0371  * The "cache change attribute" is updated when we need to revalidate
0372  * our dentry cache after a directory was seen to change on the server.
0373  */
0374 static inline unsigned long nfs_save_change_attribute(struct inode *dir)
0375 {
0376     return NFS_I(dir)->cache_change_attribute;
0377 }
0378 
0379 /*
0380  * linux/fs/nfs/inode.c
0381  */
0382 extern int nfs_sync_mapping(struct address_space *mapping);
0383 extern void nfs_zap_mapping(struct inode *inode, struct address_space *mapping);
0384 extern void nfs_zap_caches(struct inode *);
0385 extern void nfs_set_inode_stale(struct inode *inode);
0386 extern void nfs_invalidate_atime(struct inode *);
0387 extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,
0388                 struct nfs_fattr *);
0389 struct inode *nfs_ilookup(struct super_block *sb, struct nfs_fattr *, struct nfs_fh *);
0390 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
0391 extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
0392 extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
0393 extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr);
0394 extern int nfs_getattr(struct user_namespace *, const struct path *,
0395                struct kstat *, u32, unsigned int);
0396 extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
0397 extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
0398 extern int nfs_permission(struct user_namespace *, struct inode *, int);
0399 extern int nfs_open(struct inode *, struct file *);
0400 extern int nfs_attribute_cache_expired(struct inode *inode);
0401 extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
0402 extern int __nfs_revalidate_inode(struct nfs_server *, struct inode *);
0403 extern int nfs_clear_invalid_mapping(struct address_space *mapping);
0404 extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
0405 extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
0406 extern int nfs_revalidate_mapping_rcu(struct inode *inode);
0407 extern int nfs_setattr(struct user_namespace *, struct dentry *, struct iattr *);
0408 extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
0409 extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr);
0410 extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
0411 extern void put_nfs_open_context(struct nfs_open_context *ctx);
0412 extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, const struct cred *cred, fmode_t mode);
0413 extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode, struct file *filp);
0414 extern void nfs_inode_attach_open_context(struct nfs_open_context *ctx);
0415 extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
0416 extern void nfs_file_clear_open_context(struct file *flip);
0417 extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
0418 extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);
0419 extern u64 nfs_compat_user_ino64(u64 fileid);
0420 extern void nfs_fattr_init(struct nfs_fattr *fattr);
0421 extern void nfs_fattr_set_barrier(struct nfs_fattr *fattr);
0422 extern unsigned long nfs_inc_attr_generation_counter(void);
0423 
0424 extern struct nfs_fattr *nfs_alloc_fattr(void);
0425 extern struct nfs_fattr *nfs_alloc_fattr_with_label(struct nfs_server *server);
0426 
0427 static inline void nfs4_label_free(struct nfs4_label *label)
0428 {
0429 #ifdef CONFIG_NFS_V4_SECURITY_LABEL
0430     if (label) {
0431         kfree(label->label);
0432         kfree(label);
0433     }
0434 #endif
0435 }
0436 
0437 static inline void nfs_free_fattr(const struct nfs_fattr *fattr)
0438 {
0439     if (fattr)
0440         nfs4_label_free(fattr->label);
0441     kfree(fattr);
0442 }
0443 
0444 extern struct nfs_fh *nfs_alloc_fhandle(void);
0445 
0446 static inline void nfs_free_fhandle(const struct nfs_fh *fh)
0447 {
0448     kfree(fh);
0449 }
0450 
0451 #ifdef NFS_DEBUG
0452 extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
0453 static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
0454 {
0455     return _nfs_display_fhandle_hash(fh);
0456 }
0457 extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
0458 #define nfs_display_fhandle(fh, caption)            \
0459     do {                            \
0460         if (unlikely(nfs_debug & NFSDBG_FACILITY))  \
0461             _nfs_display_fhandle(fh, caption);  \
0462     } while (0)
0463 #else
0464 static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
0465 {
0466     return 0;
0467 }
0468 static inline void nfs_display_fhandle(const struct nfs_fh *fh,
0469                        const char *caption)
0470 {
0471 }
0472 #endif
0473 
0474 /*
0475  * linux/fs/nfs/nfsroot.c
0476  */
0477 extern int  nfs_root_data(char **root_device, char **root_data); /*__init*/
0478 /* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
0479 extern __be32 root_nfs_parse_addr(char *name); /*__init*/
0480 
0481 /*
0482  * linux/fs/nfs/file.c
0483  */
0484 extern const struct file_operations nfs_file_operations;
0485 #if IS_ENABLED(CONFIG_NFS_V4)
0486 extern const struct file_operations nfs4_file_operations;
0487 #endif /* CONFIG_NFS_V4 */
0488 extern const struct address_space_operations nfs_file_aops;
0489 extern const struct address_space_operations nfs_dir_aops;
0490 
0491 static inline struct nfs_open_context *nfs_file_open_context(struct file *filp)
0492 {
0493     return filp->private_data;
0494 }
0495 
0496 static inline const struct cred *nfs_file_cred(struct file *file)
0497 {
0498     if (file != NULL) {
0499         struct nfs_open_context *ctx =
0500             nfs_file_open_context(file);
0501         if (ctx)
0502             return ctx->cred;
0503     }
0504     return NULL;
0505 }
0506 
0507 /*
0508  * linux/fs/nfs/direct.c
0509  */
0510 int nfs_swap_rw(struct kiocb *iocb, struct iov_iter *iter);
0511 ssize_t nfs_file_direct_read(struct kiocb *iocb,
0512                  struct iov_iter *iter, bool swap);
0513 ssize_t nfs_file_direct_write(struct kiocb *iocb,
0514                   struct iov_iter *iter, bool swap);
0515 
0516 /*
0517  * linux/fs/nfs/dir.c
0518  */
0519 extern const struct file_operations nfs_dir_operations;
0520 extern const struct dentry_operations nfs_dentry_operations;
0521 
0522 extern void nfs_force_lookup_revalidate(struct inode *dir);
0523 extern void nfs_set_verifier(struct dentry * dentry, unsigned long verf);
0524 #if IS_ENABLED(CONFIG_NFS_V4)
0525 extern void nfs_clear_verifier_delegated(struct inode *inode);
0526 #endif /* IS_ENABLED(CONFIG_NFS_V4) */
0527 extern struct dentry *nfs_add_or_obtain(struct dentry *dentry,
0528             struct nfs_fh *fh, struct nfs_fattr *fattr);
0529 extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh,
0530             struct nfs_fattr *fattr);
0531 extern int nfs_may_open(struct inode *inode, const struct cred *cred, int openflags);
0532 extern void nfs_access_zap_cache(struct inode *inode);
0533 extern int nfs_access_get_cached(struct inode *inode, const struct cred *cred,
0534                  u32 *mask, bool may_block);
0535 
0536 /*
0537  * linux/fs/nfs/symlink.c
0538  */
0539 extern const struct inode_operations nfs_symlink_inode_operations;
0540 
0541 /*
0542  * linux/fs/nfs/sysctl.c
0543  */
0544 #ifdef CONFIG_SYSCTL
0545 extern int nfs_register_sysctl(void);
0546 extern void nfs_unregister_sysctl(void);
0547 #else
0548 #define nfs_register_sysctl() 0
0549 #define nfs_unregister_sysctl() do { } while(0)
0550 #endif
0551 
0552 /*
0553  * linux/fs/nfs/namespace.c
0554  */
0555 extern const struct inode_operations nfs_mountpoint_inode_operations;
0556 extern const struct inode_operations nfs_referral_inode_operations;
0557 extern int nfs_mountpoint_expiry_timeout;
0558 extern void nfs_release_automount_timer(void);
0559 
0560 /*
0561  * linux/fs/nfs/unlink.c
0562  */
0563 extern void nfs_complete_unlink(struct dentry *dentry, struct inode *);
0564 
0565 /*
0566  * linux/fs/nfs/write.c
0567  */
0568 extern int  nfs_congestion_kb;
0569 extern int  nfs_writepage(struct page *page, struct writeback_control *wbc);
0570 extern int  nfs_writepages(struct address_space *, struct writeback_control *);
0571 extern int  nfs_flush_incompatible(struct file *file, struct page *page);
0572 extern int  nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
0573 
0574 /*
0575  * Try to write back everything synchronously (but check the
0576  * return value!)
0577  */
0578 extern int nfs_sync_inode(struct inode *inode);
0579 extern int nfs_wb_all(struct inode *inode);
0580 extern int nfs_wb_page(struct inode *inode, struct page *page);
0581 int nfs_wb_folio_cancel(struct inode *inode, struct folio *folio);
0582 extern int  nfs_commit_inode(struct inode *, int);
0583 extern struct nfs_commit_data *nfs_commitdata_alloc(void);
0584 extern void nfs_commit_free(struct nfs_commit_data *data);
0585 bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);
0586 
0587 static inline bool nfs_have_writebacks(const struct inode *inode)
0588 {
0589     if (S_ISREG(inode->i_mode))
0590         return atomic_long_read(&NFS_I(inode)->nrequests) != 0;
0591     return false;
0592 }
0593 
0594 /*
0595  * linux/fs/nfs/read.c
0596  */
0597 int  nfs_read_folio(struct file *, struct folio *);
0598 void nfs_readahead(struct readahead_control *);
0599 
0600 /*
0601  * inline functions
0602  */
0603 
0604 static inline loff_t nfs_size_to_loff_t(__u64 size)
0605 {
0606     return min_t(u64, size, OFFSET_MAX);
0607 }
0608 
0609 static inline ino_t
0610 nfs_fileid_to_ino_t(u64 fileid)
0611 {
0612     ino_t ino = (ino_t) fileid;
0613     if (sizeof(ino_t) < sizeof(u64))
0614         ino ^= fileid >> (sizeof(u64)-sizeof(ino_t)) * 8;
0615     return ino;
0616 }
0617 
0618 #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
0619 
0620 /* We need to block new opens while a file is being unlinked.
0621  * If it is opened *before* we decide to unlink, we will silly-rename
0622  * instead. If it is opened *after*, then we need to create or will fail.
0623  * If we allow the two to race, we could end up with a file that is open
0624  * but deleted on the server resulting in ESTALE.
0625  * So use ->d_fsdata to record when the unlink is happening
0626  * and block dentry revalidation while it is set.
0627  */
0628 #define NFS_FSDATA_BLOCKED ((void*)1)
0629 
0630 # undef ifdebug
0631 # ifdef NFS_DEBUG
0632 #  define ifdebug(fac)      if (unlikely(nfs_debug & NFSDBG_##fac))
0633 #  define NFS_IFDEBUG(x)    x
0634 # else
0635 #  define ifdebug(fac)      if (0)
0636 #  define NFS_IFDEBUG(x)
0637 # endif
0638 #endif