8 #ifndef _LINUX_NFS_FS_H
9 #define _LINUX_NFS_FS_H
17 #ifdef CONFIG_NFS_DEBUG
24 #include <linux/rbtree.h>
26 #include <linux/wait.h>
28 #include <linux/sunrpc/debug.h>
32 #include <linux/nfs.h>
34 #include <linux/nfs3.h>
35 #include <linux/nfs4.h>
44 #define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
78 #define NFS_CONTEXT_ERROR_WRITE (0)
79 #define NFS_CONTEXT_RESEND_WRITES (1)
97 struct nfs_delegation;
149 #ifdef CONFIG_NFS_V3_ACL
172 #if IS_ENABLED(CONFIG_NFS_V4)
176 struct nfs_delegation
__rcu *delegation;
181 struct pnfs_layout_hdr *
layout;
186 #ifdef CONFIG_NFS_FSCACHE
195 #define NFS_INO_INVALID_ATTR 0x0001
196 #define NFS_INO_INVALID_DATA 0x0002
197 #define NFS_INO_INVALID_ATIME 0x0004
198 #define NFS_INO_INVALID_ACCESS 0x0008
199 #define NFS_INO_INVALID_ACL 0x0010
200 #define NFS_INO_REVAL_PAGECACHE 0x0020
201 #define NFS_INO_REVAL_FORCED 0x0040
206 #define NFS_INO_ADVISE_RDPLUS (0)
207 #define NFS_INO_STALE (1)
208 #define NFS_INO_ACL_LRU_SET (2)
209 #define NFS_INO_FLUSHING (4)
210 #define NFS_INO_FSCACHE (5)
211 #define NFS_INO_FSCACHE_LOCK (6)
212 #define NFS_INO_COMMIT (7)
213 #define NFS_INO_LAYOUTCOMMIT (9)
214 #define NFS_INO_LAYOUTCOMMITTING (10)
228 return &NFS_I(inode)->fh;
233 return NFS_SB(inode->
i_sb);
238 return NFS_SERVER(inode)->client;
243 return NFS_SERVER(inode)->nfs_client->rpc_ops;
246 static inline unsigned NFS_MINATTRTIMEO(
const struct inode *
inode)
252 static inline unsigned NFS_MAXATTRTIMEO(
const struct inode *
inode)
258 static inline int NFS_STALE(
const struct inode *
inode)
263 static inline int NFS_FSCACHE(
const struct inode *inode)
268 static inline __u64 NFS_FILEID(
const struct inode *inode)
270 return NFS_I(inode)->fileid;
273 static inline void set_nfs_fileid(
struct inode *inode,
__u64 fileid)
275 NFS_I(inode)->fileid = fileid;
278 static inline void nfs_mark_for_revalidate(
struct inode *inode)
282 spin_lock(&inode->
i_lock);
286 spin_unlock(&inode->
i_lock);
289 static inline int nfs_server_capable(
struct inode *inode,
int cap)
291 return NFS_SERVER(inode)->caps &
cap;
294 static inline void nfs_set_verifier(
struct dentry *
dentry,
unsigned long verf)
305 static inline unsigned long nfs_save_change_attribute(
struct inode *dir)
307 return NFS_I(dir)->cache_change_attribute;
318 static inline int nfs_verify_change_attribute(
struct inode *dir,
unsigned long chattr)
320 return chattr == NFS_I(dir)->cache_change_attribute;
360 static inline void nfs_free_fattr(
const struct nfs_fattr *fattr)
367 static inline void nfs_free_fhandle(
const struct nfs_fh *fh)
373 extern u32 _nfs_display_fhandle_hash(
const struct nfs_fh *fh);
374 static inline u32 nfs_display_fhandle_hash(
const struct nfs_fh *fh)
376 return _nfs_display_fhandle_hash(fh);
378 extern void _nfs_display_fhandle(
const struct nfs_fh *fh,
const char *caption);
379 #define nfs_display_fhandle(fh, caption) \
381 if (unlikely(nfs_debug & NFSDBG_FACILITY)) \
382 _nfs_display_fhandle(fh, caption); \
385 static inline u32 nfs_display_fhandle_hash(
const struct nfs_fh *fh)
389 static inline void nfs_display_fhandle(
const struct nfs_fh *fh,
406 #if IS_ENABLED(CONFIG_NFS_V4)
417 static inline struct rpc_cred *nfs_file_cred(
struct file *
file)
421 nfs_file_open_context(file);
431 #ifdef CONFIG_NFS_V3_ACL
435 const void *,
size_t,
int);
438 # define nfs3_listxattr NULL
439 # define nfs3_getxattr NULL
440 # define nfs3_setxattr NULL
441 # define nfs3_removexattr NULL
450 const struct iovec *iov,
unsigned long nr_segs,
451 loff_t
pos,
bool uio);
453 const struct iovec *iov,
unsigned long nr_segs,
454 loff_t
pos,
bool uio);
479 #define nfs_register_sysctl() 0
480 #define nfs_unregister_sysctl() do { } while(0)
516 #if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
517 extern int nfs_commit_inode(
struct inode *,
int);
522 nfs_commit_inode(
struct inode *inode,
int how)
529 nfs_have_writebacks(
struct inode *inode)
531 return NFS_I(inode)->npages != 0;
547 #ifdef CONFIG_NFS_V3_ACL
571 static inline loff_t nfs_size_to_loff_t(
__u64 size)
575 return (loff_t)
size;
579 nfs_fileid_to_ino_t(
u64 fileid)
583 ino ^= fileid >> (
sizeof(
u64)-
sizeof(
ino_t)) * 8;
587 #define NFS_JUKEBOX_RETRY_TIME (5 * HZ)
592 # define ifdebug(fac) if (unlikely(nfs_debug & NFSDBG_##fac))
593 # define NFS_IFDEBUG(x) x
595 # define ifdebug(fac) if (0)
596 # define NFS_IFDEBUG(x)