mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 05:20:53 +07:00
65294c1f2c
Currently, NFSv2/3 reads and writes have to open a file, do the read or write and then close it again for each RPC. This is highly inefficient, especially when the underlying filesystem has a relatively slow open routine. This patch adds a new open file cache to knfsd. Rather than doing an open for each RPC, the read/write handlers can call into this cache to see if there is one already there for the correct filehandle and NFS_MAY_READ/WRITE flags. If there isn't an entry, then we create a new one and attempt to perform the open. If there is, then we wait until the entry is fully instantiated and return it if it is at the end of the wait. If it's not, then we attempt to take over construction. Since the main goal is to speed up NFSv2/3 I/O, we don't want to close these files on last put of these objects. We need to keep them around for a little while since we never know when the next READ/WRITE will come in. Cache entries have a hardcoded 1s timeout, and we have a recurring workqueue job that walks the cache and purges any entries that have expired. Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Richard Sharpe <richard.sharpe@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
61 lines
2.2 KiB
C
61 lines
2.2 KiB
C
#ifndef _FS_NFSD_FILECACHE_H
|
|
#define _FS_NFSD_FILECACHE_H
|
|
|
|
#include <linux/fsnotify_backend.h>
|
|
|
|
/*
|
|
* This is the fsnotify_mark container that nfsd attaches to the files that it
|
|
* is holding open. Note that we have a separate refcount here aside from the
|
|
* one in the fsnotify_mark. We only want a single fsnotify_mark attached to
|
|
* the inode, and for each nfsd_file to hold a reference to it.
|
|
*
|
|
* The fsnotify_mark is itself refcounted, but that's not sufficient to tell us
|
|
* how to put that reference. If there are still outstanding nfsd_files that
|
|
* reference the mark, then we would want to call fsnotify_put_mark on it.
|
|
* If there were not, then we'd need to call fsnotify_destroy_mark. Since we
|
|
* can't really tell the difference, we use the nfm_mark to keep track of how
|
|
* many nfsd_files hold references to the mark. When that counter goes to zero
|
|
* then we know to call fsnotify_destroy_mark on it.
|
|
*/
|
|
struct nfsd_file_mark {
|
|
struct fsnotify_mark nfm_mark;
|
|
atomic_t nfm_ref;
|
|
};
|
|
|
|
/*
|
|
* A representation of a file that has been opened by knfsd. These are hashed
|
|
* in the hashtable by inode pointer value. Note that this object doesn't
|
|
* hold a reference to the inode by itself, so the nf_inode pointer should
|
|
* never be dereferenced, only used for comparison.
|
|
*/
|
|
struct nfsd_file {
|
|
struct hlist_node nf_node;
|
|
struct list_head nf_lru;
|
|
struct rcu_head nf_rcu;
|
|
struct file *nf_file;
|
|
const struct cred *nf_cred;
|
|
#define NFSD_FILE_HASHED (0)
|
|
#define NFSD_FILE_PENDING (1)
|
|
#define NFSD_FILE_BREAK_READ (2)
|
|
#define NFSD_FILE_BREAK_WRITE (3)
|
|
#define NFSD_FILE_REFERENCED (4)
|
|
unsigned long nf_flags;
|
|
struct inode *nf_inode;
|
|
unsigned int nf_hashval;
|
|
atomic_t nf_ref;
|
|
unsigned char nf_may;
|
|
struct nfsd_file_mark *nf_mark;
|
|
};
|
|
|
|
int nfsd_file_cache_init(void);
|
|
void nfsd_file_cache_purge(void);
|
|
void nfsd_file_cache_shutdown(void);
|
|
void nfsd_file_put(struct nfsd_file *nf);
|
|
struct nfsd_file *nfsd_file_get(struct nfsd_file *nf);
|
|
void nfsd_file_close_inode_sync(struct inode *inode);
|
|
bool nfsd_file_is_cached(struct inode *inode);
|
|
__be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
|
|
unsigned int may_flags, struct nfsd_file **nfp);
|
|
int nfsd_file_cache_stats_open(struct inode *, struct file *);
|
|
#endif /* _FS_NFSD_FILECACHE_H */
|