FILE
filecache.h
File preview with syntax highlighting.
linux-6.19.14/fs/nfsd/filecache.h
1#ifndef _FS_NFSD_FILECACHE_H 2#define _FS_NFSD_FILECACHE_H 3 4#include <linux/fsnotify_backend.h> 5 6/* 7 * Limit the time that the list_lru_one lock is held during 8 * an LRU scan. 9 */ 10#define NFSD_FILE_GC_BATCH (16UL) 11 12/* 13 * This is the fsnotify_mark container that nfsd attaches to the files that it 14 * is holding open. Note that we have a separate refcount here aside from the 15 * one in the fsnotify_mark. We only want a single fsnotify_mark attached to 16 * the inode, and for each nfsd_file to hold a reference to it. 17 * 18 * The fsnotify_mark is itself refcounted, but that's not sufficient to tell us 19 * how to put that reference. If there are still outstanding nfsd_files that 20 * reference the mark, then we would want to call fsnotify_put_mark on it. 21 * If there were not, then we'd need to call fsnotify_destroy_mark. Since we 22 * can't really tell the difference, we use the nfm_mark to keep track of how 23 * many nfsd_files hold references to the mark. When that counter goes to zero 24 * then we know to call fsnotify_destroy_mark on it. 25 */ 26struct nfsd_file_mark { 27 struct fsnotify_mark nfm_mark; 28 refcount_t nfm_ref; 29}; 30 31/* 32 * A representation of a file that has been opened by knfsd. These are hashed 33 * in the hashtable by inode pointer value. Note that this object doesn't 34 * hold a reference to the inode by itself, so the nf_inode pointer should 35 * never be dereferenced, only used for comparison. 36 */ 37struct nfsd_file { 38 struct rhlist_head nf_rlist; 39 void *nf_inode; 40 struct file *nf_file; 41 const struct cred *nf_cred; 42 struct net *nf_net; 43#define NFSD_FILE_HASHED (0) 44#define NFSD_FILE_PENDING (1) 45#define NFSD_FILE_REFERENCED (2) 46#define NFSD_FILE_GC (3) 47#define NFSD_FILE_RECENT (4) 48 unsigned long nf_flags; 49 refcount_t nf_ref; 50 unsigned char nf_may; 51 52 struct nfsd_file_mark *nf_mark; 53 struct list_head nf_lru; 54 struct list_head nf_gc; 55 struct rcu_head nf_rcu; 56 ktime_t nf_birthtime; 57 58 u32 nf_dio_mem_align; 59 u32 nf_dio_offset_align; 60 u32 nf_dio_read_offset_align; 61}; 62 63int nfsd_file_cache_init(void); 64void nfsd_file_cache_purge(struct net *); 65void nfsd_file_cache_shutdown(void); 66int nfsd_file_cache_start_net(struct net *net); 67void nfsd_file_cache_shutdown_net(struct net *net); 68void nfsd_file_put(struct nfsd_file *nf); 69struct net *nfsd_file_put_local(struct nfsd_file __rcu **nf); 70struct nfsd_file *nfsd_file_get(struct nfsd_file *nf); 71struct file *nfsd_file_file(struct nfsd_file *nf); 72void nfsd_file_close_inode_sync(struct inode *inode); 73void nfsd_file_net_dispose(struct nfsd_net *nn); 74bool nfsd_file_is_cached(struct inode *inode); 75__be32 nfsd_file_acquire_gc(struct svc_rqst *rqstp, struct svc_fh *fhp, 76 unsigned int may_flags, struct nfsd_file **nfp); 77__be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp, 78 unsigned int may_flags, struct nfsd_file **nfp); 79__be32 nfsd_file_acquire_opened(struct svc_rqst *rqstp, struct svc_fh *fhp, 80 unsigned int may_flags, struct file *file, 81 struct nfsd_file **nfp); 82__be32 nfsd_file_acquire_local(struct net *net, struct svc_cred *cred, 83 struct auth_domain *client, struct svc_fh *fhp, 84 unsigned int may_flags, struct nfsd_file **pnf); 85__be32 nfsd_file_acquire_dir(struct svc_rqst *rqstp, struct svc_fh *fhp, 86 struct nfsd_file **pnf); 87int nfsd_file_cache_stats_show(struct seq_file *m, void *v); 88#endif /* _FS_NFSD_FILECACHE_H */
~/
Read-only file preview.