1*4882a593Smuzhiyun #ifndef _FS_NFSD_FILECACHE_H 2*4882a593Smuzhiyun #define _FS_NFSD_FILECACHE_H 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun #include <linux/fsnotify_backend.h> 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun /* 7*4882a593Smuzhiyun * This is the fsnotify_mark container that nfsd attaches to the files that it 8*4882a593Smuzhiyun * is holding open. Note that we have a separate refcount here aside from the 9*4882a593Smuzhiyun * one in the fsnotify_mark. We only want a single fsnotify_mark attached to 10*4882a593Smuzhiyun * the inode, and for each nfsd_file to hold a reference to it. 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us 13*4882a593Smuzhiyun * how to put that reference. If there are still outstanding nfsd_files that 14*4882a593Smuzhiyun * reference the mark, then we would want to call fsnotify_put_mark on it. 15*4882a593Smuzhiyun * If there were not, then we'd need to call fsnotify_destroy_mark. Since we 16*4882a593Smuzhiyun * can't really tell the difference, we use the nfm_mark to keep track of how 17*4882a593Smuzhiyun * many nfsd_files hold references to the mark. When that counter goes to zero 18*4882a593Smuzhiyun * then we know to call fsnotify_destroy_mark on it. 19*4882a593Smuzhiyun */ 20*4882a593Smuzhiyun struct nfsd_file_mark { 21*4882a593Smuzhiyun struct fsnotify_mark nfm_mark; 22*4882a593Smuzhiyun refcount_t nfm_ref; 23*4882a593Smuzhiyun }; 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* 26*4882a593Smuzhiyun * A representation of a file that has been opened by knfsd. These are hashed 27*4882a593Smuzhiyun * in the hashtable by inode pointer value. Note that this object doesn't 28*4882a593Smuzhiyun * hold a reference to the inode by itself, so the nf_inode pointer should 29*4882a593Smuzhiyun * never be dereferenced, only used for comparison. 30*4882a593Smuzhiyun */ 31*4882a593Smuzhiyun struct nfsd_file { 32*4882a593Smuzhiyun struct hlist_node nf_node; 33*4882a593Smuzhiyun struct list_head nf_lru; 34*4882a593Smuzhiyun struct rcu_head nf_rcu; 35*4882a593Smuzhiyun struct file *nf_file; 36*4882a593Smuzhiyun const struct cred *nf_cred; 37*4882a593Smuzhiyun struct net *nf_net; 38*4882a593Smuzhiyun #define NFSD_FILE_HASHED (0) 39*4882a593Smuzhiyun #define NFSD_FILE_PENDING (1) 40*4882a593Smuzhiyun #define NFSD_FILE_BREAK_READ (2) 41*4882a593Smuzhiyun #define NFSD_FILE_BREAK_WRITE (3) 42*4882a593Smuzhiyun #define NFSD_FILE_REFERENCED (4) 43*4882a593Smuzhiyun unsigned long nf_flags; 44*4882a593Smuzhiyun struct inode *nf_inode; 45*4882a593Smuzhiyun unsigned int nf_hashval; 46*4882a593Smuzhiyun refcount_t nf_ref; 47*4882a593Smuzhiyun unsigned char nf_may; 48*4882a593Smuzhiyun struct nfsd_file_mark *nf_mark; 49*4882a593Smuzhiyun }; 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun int nfsd_file_cache_init(void); 52*4882a593Smuzhiyun void nfsd_file_cache_purge(struct net *); 53*4882a593Smuzhiyun void nfsd_file_cache_shutdown(void); 54*4882a593Smuzhiyun int nfsd_file_cache_start_net(struct net *net); 55*4882a593Smuzhiyun void nfsd_file_cache_shutdown_net(struct net *net); 56*4882a593Smuzhiyun void nfsd_file_put(struct nfsd_file *nf); 57*4882a593Smuzhiyun struct nfsd_file *nfsd_file_get(struct nfsd_file *nf); 58*4882a593Smuzhiyun void nfsd_file_close_inode_sync(struct inode *inode); 59*4882a593Smuzhiyun bool nfsd_file_is_cached(struct inode *inode); 60*4882a593Smuzhiyun __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, 61*4882a593Smuzhiyun unsigned int may_flags, struct nfsd_file **nfp); 62*4882a593Smuzhiyun int nfsd_file_cache_stats_open(struct inode *, struct file *); 63*4882a593Smuzhiyun #endif /* _FS_NFSD_FILECACHE_H */ 64