18c2ecf20Sopenharmony_ci#ifndef _FS_NFSD_FILECACHE_H 28c2ecf20Sopenharmony_ci#define _FS_NFSD_FILECACHE_H 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#include <linux/fsnotify_backend.h> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci/* 78c2ecf20Sopenharmony_ci * This is the fsnotify_mark container that nfsd attaches to the files that it 88c2ecf20Sopenharmony_ci * is holding open. Note that we have a separate refcount here aside from the 98c2ecf20Sopenharmony_ci * one in the fsnotify_mark. We only want a single fsnotify_mark attached to 108c2ecf20Sopenharmony_ci * the inode, and for each nfsd_file to hold a reference to it. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us 138c2ecf20Sopenharmony_ci * how to put that reference. If there are still outstanding nfsd_files that 148c2ecf20Sopenharmony_ci * reference the mark, then we would want to call fsnotify_put_mark on it. 158c2ecf20Sopenharmony_ci * If there were not, then we'd need to call fsnotify_destroy_mark. Since we 168c2ecf20Sopenharmony_ci * can't really tell the difference, we use the nfm_mark to keep track of how 178c2ecf20Sopenharmony_ci * many nfsd_files hold references to the mark. When that counter goes to zero 188c2ecf20Sopenharmony_ci * then we know to call fsnotify_destroy_mark on it. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_cistruct nfsd_file_mark { 218c2ecf20Sopenharmony_ci struct fsnotify_mark nfm_mark; 228c2ecf20Sopenharmony_ci refcount_t nfm_ref; 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* 268c2ecf20Sopenharmony_ci * A representation of a file that has been opened by knfsd. These are hashed 278c2ecf20Sopenharmony_ci * in the hashtable by inode pointer value. Note that this object doesn't 288c2ecf20Sopenharmony_ci * hold a reference to the inode by itself, so the nf_inode pointer should 298c2ecf20Sopenharmony_ci * never be dereferenced, only used for comparison. 308c2ecf20Sopenharmony_ci */ 318c2ecf20Sopenharmony_cistruct nfsd_file { 328c2ecf20Sopenharmony_ci struct hlist_node nf_node; 338c2ecf20Sopenharmony_ci struct list_head nf_lru; 348c2ecf20Sopenharmony_ci struct rcu_head nf_rcu; 358c2ecf20Sopenharmony_ci struct file *nf_file; 368c2ecf20Sopenharmony_ci const struct cred *nf_cred; 378c2ecf20Sopenharmony_ci struct net *nf_net; 388c2ecf20Sopenharmony_ci#define NFSD_FILE_HASHED (0) 398c2ecf20Sopenharmony_ci#define NFSD_FILE_PENDING (1) 408c2ecf20Sopenharmony_ci#define NFSD_FILE_BREAK_READ (2) 418c2ecf20Sopenharmony_ci#define NFSD_FILE_BREAK_WRITE (3) 428c2ecf20Sopenharmony_ci#define NFSD_FILE_REFERENCED (4) 438c2ecf20Sopenharmony_ci unsigned long nf_flags; 448c2ecf20Sopenharmony_ci struct inode *nf_inode; 458c2ecf20Sopenharmony_ci unsigned int nf_hashval; 468c2ecf20Sopenharmony_ci refcount_t nf_ref; 478c2ecf20Sopenharmony_ci unsigned char nf_may; 488c2ecf20Sopenharmony_ci struct nfsd_file_mark *nf_mark; 498c2ecf20Sopenharmony_ci}; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciint nfsd_file_cache_init(void); 528c2ecf20Sopenharmony_civoid nfsd_file_cache_purge(struct net *); 538c2ecf20Sopenharmony_civoid nfsd_file_cache_shutdown(void); 548c2ecf20Sopenharmony_ciint nfsd_file_cache_start_net(struct net *net); 558c2ecf20Sopenharmony_civoid nfsd_file_cache_shutdown_net(struct net *net); 568c2ecf20Sopenharmony_civoid nfsd_file_put(struct nfsd_file *nf); 578c2ecf20Sopenharmony_cistruct nfsd_file *nfsd_file_get(struct nfsd_file *nf); 588c2ecf20Sopenharmony_civoid nfsd_file_close_inode_sync(struct inode *inode); 598c2ecf20Sopenharmony_cibool nfsd_file_is_cached(struct inode *inode); 608c2ecf20Sopenharmony_ci__be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, 618c2ecf20Sopenharmony_ci unsigned int may_flags, struct nfsd_file **nfp); 628c2ecf20Sopenharmony_ciint nfsd_file_cache_stats_open(struct inode *, struct file *); 638c2ecf20Sopenharmony_ci#endif /* _FS_NFSD_FILECACHE_H */ 64