Back to home page

OSCL-LXR

 
 

    


0001 #ifndef _FS_NFSD_FILECACHE_H
0002 #define _FS_NFSD_FILECACHE_H
0003 
0004 #include <linux/fsnotify_backend.h>
0005 
0006 /*
0007  * This is the fsnotify_mark container that nfsd attaches to the files that it
0008  * is holding open. Note that we have a separate refcount here aside from the
0009  * one in the fsnotify_mark. We only want a single fsnotify_mark attached to
0010  * the inode, and for each nfsd_file to hold a reference to it.
0011  *
0012  * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us
0013  * how to put that reference. If there are still outstanding nfsd_files that
0014  * reference the mark, then we would want to call fsnotify_put_mark on it.
0015  * If there were not, then we'd need to call fsnotify_destroy_mark. Since we
0016  * can't really tell the difference, we use the nfm_mark to keep track of how
0017  * many nfsd_files hold references to the mark. When that counter goes to zero
0018  * then we know to call fsnotify_destroy_mark on it.
0019  */
0020 struct nfsd_file_mark {
0021     struct fsnotify_mark    nfm_mark;
0022     refcount_t      nfm_ref;
0023 };
0024 
0025 /*
0026  * A representation of a file that has been opened by knfsd. These are hashed
0027  * in the hashtable by inode pointer value. Note that this object doesn't
0028  * hold a reference to the inode by itself, so the nf_inode pointer should
0029  * never be dereferenced, only used for comparison.
0030  */
0031 struct nfsd_file {
0032     struct rhash_head   nf_rhash;
0033     struct list_head    nf_lru;
0034     struct rcu_head     nf_rcu;
0035     struct file     *nf_file;
0036     const struct cred   *nf_cred;
0037     struct net      *nf_net;
0038 #define NFSD_FILE_HASHED    (0)
0039 #define NFSD_FILE_PENDING   (1)
0040 #define NFSD_FILE_REFERENCED    (2)
0041     unsigned long       nf_flags;
0042     struct inode        *nf_inode;  /* don't deref */
0043     refcount_t      nf_ref;
0044     unsigned char       nf_may;
0045     struct nfsd_file_mark   *nf_mark;
0046     ktime_t         nf_birthtime;
0047 };
0048 
0049 int nfsd_file_cache_init(void);
0050 void nfsd_file_cache_purge(struct net *);
0051 void nfsd_file_cache_shutdown(void);
0052 int nfsd_file_cache_start_net(struct net *net);
0053 void nfsd_file_cache_shutdown_net(struct net *net);
0054 void nfsd_file_put(struct nfsd_file *nf);
0055 void nfsd_file_close(struct nfsd_file *nf);
0056 struct nfsd_file *nfsd_file_get(struct nfsd_file *nf);
0057 void nfsd_file_close_inode_sync(struct inode *inode);
0058 bool nfsd_file_is_cached(struct inode *inode);
0059 __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
0060           unsigned int may_flags, struct nfsd_file **nfp);
0061 __be32 nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
0062           unsigned int may_flags, struct nfsd_file **nfp);
0063 int nfsd_file_cache_stats_open(struct inode *, struct file *);
0064 #endif /* _FS_NFSD_FILECACHE_H */