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