📄 nfs_fs.h
字号:
/* * linux/include/linux/nfs_fs.h * * Copyright (C) 1992 Rick Sladkey * * OS-specific nfs filesystem definitions and declarations */#ifndef _LINUX_NFS_FS_H#define _LINUX_NFS_FS_H#include <linux/magic.h>/* * Enable debugging support for nfs client. * Requires RPC_DEBUG. */#ifdef RPC_DEBUG# define NFS_DEBUG#endif/* Default timeout values */#define NFS_MAX_UDP_TIMEOUT (60*HZ)#define NFS_MAX_TCP_TIMEOUT (600*HZ)/* * When flushing a cluster of dirty pages, there can be different * strategies: */#define FLUSH_SYNC 1 /* file being synced, or contention */#define FLUSH_STABLE 4 /* commit to stable storage */#define FLUSH_LOWPRI 8 /* low priority background flush */#define FLUSH_HIGHPRI 16 /* high priority memory reclaim flush */#define FLUSH_NOCOMMIT 32 /* Don't send the NFSv3/v4 COMMIT */#define FLUSH_INVALIDATE 64 /* Invalidate the page cache */#define FLUSH_NOWRITEPAGE 128 /* Don't call writepage() */#ifdef __KERNEL__#include <linux/in.h>#include <linux/mm.h>#include <linux/pagemap.h>#include <linux/rbtree.h>#include <linux/rwsem.h>#include <linux/wait.h>#include <linux/sunrpc/debug.h>#include <linux/sunrpc/auth.h>#include <linux/sunrpc/clnt.h>#include <linux/nfs.h>#include <linux/nfs2.h>#include <linux/nfs3.h>#include <linux/nfs4.h>#include <linux/nfs_xdr.h>#include <linux/nfs_fs_sb.h>#include <linux/rwsem.h>#include <linux/mempool.h>/* * These are the default flags for swap requests */#define NFS_RPC_SWAPFLAGS (RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)/* * NFSv3/v4 Access mode cache entry */struct nfs_access_entry { struct rb_node rb_node; struct list_head lru; unsigned long jiffies; struct rpc_cred * cred; int mask;};struct nfs4_state;struct nfs_open_context { atomic_t count; struct vfsmount *vfsmnt; struct dentry *dentry; struct rpc_cred *cred; struct nfs4_state *state; fl_owner_t lockowner; int mode; int error; struct list_head list; __u64 dir_cookie;};/* * NFSv4 delegation */struct nfs_delegation;struct posix_acl;/* * nfs fs inode data in memory */struct nfs_inode { /* * The 64bit 'inode number' */ __u64 fileid; /* * NFS file handle */ struct nfs_fh fh; /* * Various flags */ unsigned long flags; /* atomic bit ops */ unsigned long cache_validity; /* bit mask */ /* * read_cache_jiffies is when we started read-caching this inode. * attrtimeo is for how long the cached information is assumed * to be valid. A successful attribute revalidation doubles * attrtimeo (up to acregmax/acdirmax), a failure resets it to * acregmin/acdirmin. * * We need to revalidate the cached attrs for this inode if * * jiffies - read_cache_jiffies > attrtimeo */ unsigned long read_cache_jiffies; unsigned long attrtimeo; unsigned long attrtimeo_timestamp; __u64 change_attr; /* v4 only */ unsigned long last_updated; /* "Generation counter" for the attribute cache. This is * bumped whenever we update the metadata on the * server. */ unsigned long cache_change_attribute; /* * Counter indicating the number of outstanding requests that * will cause a file data update. */ atomic_t data_updates; struct rb_root access_cache; struct list_head access_cache_entry_lru; struct list_head access_cache_inode_lru;#ifdef CONFIG_NFS_V3_ACL struct posix_acl *acl_access; struct posix_acl *acl_default;#endif /* * This is the cookie verifier used for NFSv3 readdir * operations */ __be32 cookieverf[2]; /* * This is the list of dirty unwritten pages. */ spinlock_t req_lock; struct list_head dirty; struct list_head commit; struct radix_tree_root nfs_page_tree; unsigned int ndirty, ncommit, npages; /* Open contexts for shared mmap writes */ struct list_head open_files;#ifdef CONFIG_NFS_V4 struct nfs4_cached_acl *nfs4_acl; /* NFSv4 state */ struct list_head open_states; struct nfs_delegation *delegation; int delegation_state; struct rw_semaphore rwsem;#endif /* CONFIG_NFS_V4*/ struct inode vfs_inode;};/* * Cache validity bit flags */#define NFS_INO_INVALID_ATTR 0x0001 /* cached attrs are invalid */#define NFS_INO_INVALID_DATA 0x0002 /* cached data is invalid */#define NFS_INO_INVALID_ATIME 0x0004 /* cached atime is invalid */#define NFS_INO_INVALID_ACCESS 0x0008 /* cached access cred invalid */#define NFS_INO_INVALID_ACL 0x0010 /* cached acls are invalid */#define NFS_INO_REVAL_PAGECACHE 0x0020 /* must revalidate pagecache *//* * Bit offsets in flags field */#define NFS_INO_REVALIDATING (0) /* revalidating attrs */#define NFS_INO_ADVISE_RDPLUS (1) /* advise readdirplus */#define NFS_INO_STALE (2) /* possible stale inode */#define NFS_INO_ACL_LRU_SET (3) /* Inode is on the LRU list */static inline struct nfs_inode *NFS_I(struct inode *inode){ return container_of(inode, struct nfs_inode, vfs_inode);}#define NFS_SB(s) ((struct nfs_server *)(s->s_fs_info))#define NFS_FH(inode) (&NFS_I(inode)->fh)#define NFS_SERVER(inode) (NFS_SB(inode->i_sb))#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client)#define NFS_PROTO(inode) (NFS_SERVER(inode)->nfs_client->rpc_ops)#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf)#define NFS_READTIME(inode) (NFS_I(inode)->read_cache_jiffies)#define NFS_CHANGE_ATTR(inode) (NFS_I(inode)->change_attr)#define NFS_ATTRTIMEO(inode) (NFS_I(inode)->attrtimeo)#define NFS_MINATTRTIMEO(inode) \ (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \ : NFS_SERVER(inode)->acregmin)#define NFS_MAXATTRTIMEO(inode) \ (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \ : NFS_SERVER(inode)->acregmax)#define NFS_ATTRTIMEO_UPDATE(inode) (NFS_I(inode)->attrtimeo_timestamp)#define NFS_FLAGS(inode) (NFS_I(inode)->flags)#define NFS_STALE(inode) (test_bit(NFS_INO_STALE, &NFS_FLAGS(inode)))#define NFS_FILEID(inode) (NFS_I(inode)->fileid)static inline int nfs_caches_unstable(struct inode *inode){ return atomic_read(&NFS_I(inode)->data_updates) != 0;}static inline void nfs_mark_for_revalidate(struct inode *inode){ struct nfs_inode *nfsi = NFS_I(inode); spin_lock(&inode->i_lock); nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS; if (S_ISDIR(inode->i_mode)) nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; spin_unlock(&inode->i_lock);}static inline void NFS_CACHEINV(struct inode *inode){ if (!nfs_caches_unstable(inode)) nfs_mark_for_revalidate(inode);}static inline int nfs_server_capable(struct inode *inode, int cap){ return NFS_SERVER(inode)->caps & cap;}static inline int NFS_USE_READDIRPLUS(struct inode *inode){ return test_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode));}/** * nfs_save_change_attribute - Returns the inode attribute change cookie * @inode - pointer to inode * The "change attribute" is updated every time we finish an operation * that will result in a metadata change on the server. */static inline long nfs_save_change_attribute(struct inode *inode){ return NFS_I(inode)->cache_change_attribute;}/** * nfs_verify_change_attribute - Detects NFS inode cache updates * @inode - pointer to inode * @chattr - previously saved change attribute * Return "false" if metadata has been updated (or is in the process of * being updated) since the change attribute was saved. */static inline int nfs_verify_change_attribute(struct inode *inode, unsigned long chattr){ return !nfs_caches_unstable(inode) && time_after_eq(chattr, NFS_I(inode)->cache_change_attribute);}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -