nfsd: open file caching
Subsystems (9)
v4 cover nfsd: open file caching
v4:
- squash some of the patches down into one patch to reduce churn
- close cached open files after unlink instead of before
- don't just close files after nfsd does an unlink, must do it after any vfs-layer unlink. Use fsnotify to handle that.
- use a SRCU notifier chain for setlease
- add patch to allow non-kthreads to do a fput_sync
v3:
- open files are now hashed on inode pointer instead of fh
- eliminate the recurring workqueue job in favor of shrinker/LRU and notifier from lease setting code
- have nfsv4 use the cache as well
- removal of raparms cache
v2:
- changelog cleanups and clarifications
- allow COMMIT to use cached open files
- tracepoints for nfsd_file cache
- proactively close open files prior to REMOVE, or a RENAME over a positive dentry
This is the fourth iteration of the open file cache patches for nfsd. There are some rather major changes here vs. the earlier sets, particularly in how we close cached open files when there is vfs-layer activity (unlinks or setlease calls in particular).
For those seeing this for the first time, main impetus here is to help speed up NFSv3 I/O. nfsd will do an open+read/write+close for every READ or WRITE RPC. This patchset allows us to cache those open files more or less indefinitely, and close them out in response to certain vfs-layer activity (unlinks and setlease attempts primarily).
The first few patches in the series make (small) changes to several subsystems to enable the caching infrastructure. The 8th patch adds the cache itself, and then the remaining patches hook the nfsd code up to the cache. The final patch rips out the raparms cache since it's no longer needed with these changes.
The most controversial piece here I think will be the 3rd patch in the series which allows fput_sync to run in non-kthread context. This is necessary to allow userland threads to close out cached nfsd files in advance of setlease attempts. Al, I'd appreciate it if you could weigh in on that one. I'm fine with adding more scary warnings to the comment above it if you think it's warranted.
Jeff Layton (16):
locks: change tracepoint for generic_add_lease
list_lru: add list_lru_rotate
fs: allow __fput_sync to be used by non-kthreads and in modules
fsnotify: export several symbols
locks: create a new notifier chain for lease attempts
nfsd: move include of state.h from trace.c to trace.h
sunrpc: add a new cache_detail operation for when a cache is flushed
nfsd: add a new struct file caching facility to nfsd
nfsd: hook up nfsd_write to the new nfsd_file cache
nfsd: hook up nfsd_read to the nfsd_file cache
nfsd: hook nfsd_commit up to the nfsd_file cache
nfsd: convert nfs4_file->fi_fds array to use nfsd_files
nfsd: have nfsd_test_lock use the nfsd_file cache
nfsd: convert fi_deleg_file and ls_file fields to nfsd_file
nfsd: hook up nfs4_preprocess_stateid_op to the nfsd_file cache
nfsd: rip out the raparms cache
fs/file_table.c | 27 +- fs/locks.c | 37 +++ fs/nfsd/Kconfig | 2 + fs/nfsd/Makefile | 3 +- fs/nfsd/export.c | 14 + fs/nfsd/filecache.c | 552 ++++++++++++++++++++++++++++++++++++++++ fs/nfsd/filecache.h | 37 +++ fs/nfsd/nfs3proc.c | 2 +- fs/nfsd/nfs4layouts.c | 12 +- fs/nfsd/nfs4proc.c | 32 +-- fs/nfsd/nfs4state.c | 174 ++++++------- fs/nfsd/nfs4xdr.c | 16 +- fs/nfsd/nfsproc.c | 2 +- fs/nfsd/nfssvc.c | 16 +- fs/nfsd/state.h | 10 +- fs/nfsd/trace.c | 2 - fs/nfsd/trace.h | 129 ++++++++++ fs/nfsd/vfs.c | 220 +++------------- fs/nfsd/vfs.h | 8 +- fs/nfsd/xdr4.h | 15 +- fs/notify/group.c | 2 + fs/notify/mark.c | 3 + include/linux/file.h | 2 +- include/linux/fs.h | 1 + include/linux/list_lru.h | 13 + include/linux/sunrpc/cache.h | 1 + include/trace/events/filelock.h | 38 ++- kernel/acct.c | 2 +- mm/list_lru.c | 15 ++ net/sunrpc/cache.c | 3 + 30 files changed, 1027 insertions(+), 363 deletions(-) create mode 100644 fs/nfsd/filecache.c create mode 100644 fs/nfsd/filecache.h
Signature · 1 line
2.4.3
PATCH v4 1/16 locks: change tracepoint for generic_add_lease
...add some more helpful info.
--- include/trace/events/filelock.h | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-)
include/trace/events/filelock.h +35 -3
@@ -81,15 +81,47 @@ DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, st DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl),TP_ARGS (inode, fl)); -DEFINE_EVENT(filelock_lease, generic_add_lease, TP_PROTO(struct inode *inode, struct file_lock *fl), -TP_ARGS (inode, fl)); - DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl),TP_ARGS (inode, fl)); DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl),TP_ARGS (inode, fl)); +TRACE_EVENT (generic_add_lease, + TP_PROTO(struct inode *inode, struct file_lock *fl), + +TP_ARGS (inode, fl), + +TP_STRUCT__entry ( + __field(unsigned long, i_ino) + __field(int, wcount) + __field(int, dcount) + __field(int, icount) + __field(dev_t, s_dev) + __field(fl_owner_t, fl_owner) + __field(unsigned int, fl_flags) + __field(unsigned char, fl_type) + ), + +TP_fast_assign ( + __entry->s_dev = inode->i_sb->s_dev; + __entry->i_ino = inode->i_ino; + __entry->wcount = atomic_read(&inode->i_writecount); + __entry->dcount = d_count(fl->fl_file->f_path.dentry); + __entry->icount = atomic_read(&inode->i_count); + __entry->fl_owner = fl ? fl->fl_owner : NULL; + __entry->fl_flags = fl ? fl->fl_flags : 0; + __entry->fl_type = fl ? fl->fl_type : 0; + ), + +TP_printk ("dev=0x%x:0x%x ino=0x%lx wcount=%d dcount=%d icount=%d fl_owner=0x%p fl_flags=%s fl_type=%s" , +MAJOR (__entry->s_dev),MINOR (__entry->s_dev), + __entry->i_ino, __entry->wcount, __entry->dcount, + __entry->icount, __entry->fl_owner, +show_fl_flags (__entry->fl_flags), +show_fl_type (__entry->fl_type)) +); +#endif /* _TRACE_FILELOCK_H */ /* This part must be outside protection */
Signature · 1 line
2.4.3
A message that is not in the archive (sent off-list or not yet received): 1441968882-7851-1-git-send-email-jeff.layton-7I+n7zu2hftEKMMhf/[email protected]
PATCH v4 5/16 locks: create a new notifier chain for lease attempts
With the new file caching infrastructure in nfsd, we can end up holding files open for an indefinite period of time, even when they are still idle. This may prevent the kernel from handing out leases on the file, which is something we don't want to block.
Fix this by running a SRCU notifier call chain whenever on any lease attempt. nfsd can then purge the cache for that inode before returning.
Since SRCU is only conditionally compiled in, we must only define the new chain if it's enabled, and users of the chain must ensure that SRCU is enabled.
--- fs/locks.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 38 insertions(+)
fs/locks.c +37 -0
@@ -166,6 +166,7 @@ int lease_break_time = 45;DEFINE_STATIC_LGLOCK (file_lock_lglock); static DEFINE_PER_CPU(struct hlist_head, file_lock_list); +/* * The blocked_hash is used to find POSIX lock loops for deadlock detection. * It is protected by blocked_lock_lock.
@@ -1780,6 +1781,40 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp, }EXPORT_SYMBOL (generic_setlease); +#if IS_ENABLED (CONFIG_SRCU ) +/* +* Kernel subsystems can register to be notified on any attempt to set +* a new lease with the lease_notifier_chain. This is used by (e.g.) nfsd +* to close files that it may have cached when there is an attempt to set a +* conflicting lease. +*/ +struct srcu_notifier_head lease_notifier_chain; +EXPORT_SYMBOL_GPL (lease_notifier_chain); + +static inline void +lease_notifier_chain_init (void ) +{ +srcu_init_notifier_head (&lease_notifier_chain); +} + +static inline void +setlease_notifier (long arg,struct file_lock *lease) +{ +if (arg !=F_UNLCK ) +srcu_notifier_call_chain (&lease_notifier_chain, arg, lease); +} +#else /* !IS_ENABLED(CONFIG_SRCU) */ +static inline void +lease_notifier_chain_init (void ) +{ +} + +static inline void +setlease_notifier (long arg,struct file_lock *lease) +{ +} +#endif /* IS_ENABLED(CONFIG_SRCU) */ +/** * vfs_setlease - sets a lease on an open file * @filp: file pointer
@@ -1800,6 +1835,7 @@ EXPORT_SYMBOL(generic_setlease);int vfs_setlease (struct file *filp,long arg,struct file_lock **lease,void **priv) { +setlease_notifier (arg, *lease);if (filp->f_op->setlease)return filp->f_op->setlease (filp, arg, lease, priv);else
@@ -2696,6 +2732,7 @@ static int __init filelock_init(void)for_each_possible_cpu (i)INIT_HLIST_HEAD (per_cpu_ptr (&file_lock_list, i)); +lease_notifier_chain_init ();return 0 ; }
include/linux/fs.h +1 -0
@@ -1041,6 +1041,7 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg);extern int fcntl_getlease (struct file *filp);/* fs/locks.c */ +extern struct srcu_notifier_head lease_notifier_chain;void locks_free_lock_context (struct file_lock_context *ctx);void locks_free_lock (struct file_lock *fl);extern void locks_init_lock (struct file_lock *);
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 8/16 nfsd: add a new struct file caching facility to nfsd
In reply to a message not in the archiveCurrently, 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.
Note that this patch just adds the infrastructure to allow the caching of open files. Later patches will actually make nfsd use it.
--- fs/nfsd/Kconfig | 2 + fs/nfsd/Makefile | 3 +- fs/nfsd/export.c | 14 ++ fs/nfsd/filecache.c | 552 ++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/filecache.h | 37 ++++ fs/nfsd/nfssvc.c | 10 +- fs/nfsd/trace.h | 127 ++++++++++++ fs/nfsd/vfs.c | 3 +- fs/nfsd/vfs.h | 1 + 9 files changed, 746 insertions(+), 3 deletions(-) create mode 100644 fs/nfsd/filecache.c create mode 100644 fs/nfsd/filecache.h
fs/nfsd/Kconfig +2 -0
@@ -6,6 +6,8 @@ config NFSD select SUNRPC select EXPORTFS select NFS_ACL_SUPPORT if NFSD_V2_ACL + select SRCU + select FSNOTIFY depends on MULTIUSER help Choose Y here if you want to allow other computers to access
fs/nfsd/Makefile +2 -1
@@ -10,7 +10,8 @@ obj-$(CONFIG_NFSD) += nfsd.o nfsd-y += trace.o nfsd-y += nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \ - export.o auth.o lockd.o nfscache.o nfsxdr.o stats.o + export.o auth.o lockd.o nfscache.o nfsxdr.o \ + stats.o filecache.o nfsd-$(CONFIG_NFSD_FAULT_INJECTION) += fault_inject.o nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o nfsd-$(CONFIG_NFSD_V3) += nfs3proc.o nfs3xdr.o
fs/nfsd/export.c +14 -0
@@ -21,6 +21,7 @@#include "nfsfh.h" #include "netns.h" #include "pnfs.h" +#include "filecache.h" #define NFSDDBG_FACILITY NFSDDBG_EXPORT
@@ -231,6 +232,18 @@ static struct cache_head *expkey_alloc(void)return NULL ; } +static void +expkey_flush (void ) +{ +/* +* Take the nfsd_mutex here to ensure that the file cache is not +* destroyed while we're in the middle of flushing. +*/ +mutex_lock (&nfsd_mutex); +nfsd_file_cache_purge (); +mutex_unlock (&nfsd_mutex); +} +static struct cache_detail svc_expkey_cache_template = { .owner =THIS_MODULE , .hash_size =EXPKEY_HASHMAX ,
@@ -243,6 +256,7 @@ static struct cache_detail svc_expkey_cache_template = { .init = expkey_init, .update = expkey_update, .alloc = expkey_alloc, + .flush = expkey_flush, }; static int
fs/nfsd/filecache.c new file +552 -0
552 lines not on this page · raw message
fs/nfsd/filecache.h new file +37 -0
@@ -0,0 +1,37 @@ +#ifndef _FS_NFSD_FILECACHE_H +#define _FS_NFSD_FILECACHE_H + +#include <linux/fsnotify_backend.h> + +/* +* 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 be 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; +#define NFSD_FILE_HASHED (0) +#define NFSD_FILE_PENDING (1) +#define NFSD_FILE_BREAK_READ (2) +#define NFSD_FILE_BREAK_WRITE (3) +unsigned long nf_flags; +struct inode *nf_inode; +unsigned int nf_hashval; +atomic_t nf_ref; +unsigned char nf_may; +struct fsnotify_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); +__be32 nfsd_file_acquire (struct svc_rqst *rqstp,struct svc_fh *fhp, +unsigned int may_flags,struct nfsd_file **nfp); +#endif /* _FS_NFSD_FILECACHE_H */
fs/nfsd/nfssvc.c +9 -1
@@ -22,6 +22,7 @@#include "cache.h" #include "vfs.h" #include "netns.h" +#include "filecache.h" #define NFSDDBG_FACILITY NFSDDBG_SVC
@@ -224,11 +225,17 @@ static int nfsd_startup_generic(int nrservs)if (ret) goto dec_users; - ret =nfs4_state_start (); + ret =nfsd_file_cache_init ();if (ret) goto out_racache; + + ret =nfs4_state_start (); +if (ret) + goto out_file_cache;return 0 ; +out_file_cache: +nfsd_file_cache_shutdown (); out_racache:nfsd_racache_shutdown (); dec_users:
@@ -242,6 +249,7 @@ static void nfsd_shutdown_generic(void)return ;nfs4_state_shutdown (); +nfsd_file_cache_shutdown ();nfsd_racache_shutdown (); }
fs/nfsd/trace.h +127 -0
139 lines not on this page · raw message
fs/nfsd/vfs.c +2 -1
@@ -623,7 +623,8 @@ nfsd_access(struct svc_rqst *rqstp, struct svc_fh *fhp, u32 *access, u32 *suppor }#endif /* CONFIG_NFSD_V3 */ -static int nfsd_open_break_lease (struct inode *inode,int access) +int +nfsd_open_break_lease (struct inode *inode,int access) {unsigned int mode;
fs/nfsd/vfs.h +1 -0
@@ -69,6 +69,7 @@ __be32 do_nfsd_create(struct svc_rqst *, struct svc_fh *,__be32 nfsd_commit (struct svc_rqst *,struct svc_fh *,loff_t ,unsigned long );#endif /* CONFIG_NFSD_V3 */ +int nfsd_open_break_lease (struct inode *,int );__be32 nfsd_open (struct svc_rqst *,struct svc_fh *,umode_t ,int ,struct file **);struct raparms ;
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 9/16 nfsd: hook up nfsd_write to the new nfsd_file cache
In reply to a message not in the archiveNote that all callers currently pass in NULL for "file" anyway, so there was already some dead code in here. Just eliminate that parm and have it use the file cache instead of dealing directly with a filp.
--- fs/nfsd/nfs3proc.c | 2 +- fs/nfsd/nfsproc.c | 2 +- fs/nfsd/vfs.c | 33 +++++++++++---------------------- fs/nfsd/vfs.h | 2 +- 4 files changed, 14 insertions(+), 25 deletions(-)
fs/nfsd/nfs3proc.c +1 -1
@@ -192,7 +192,7 @@ nfsd3_proc_write(struct svc_rqst *rqstp, struct nfsd3_writeargs *argp,fh_copy (&resp->fh, &argp->fh); resp->committed = argp->stable; - nfserr = nfsd_write(rqstp, &resp->fh, NULL, + nfserr = nfsd_write(rqstp, &resp->fh, argp->offset, rqstp->rq_vec, argp->vlen, &cnt,
fs/nfsd/nfsproc.c +1 -1
@@ -213,7 +213,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,SVCFH_fmt (&argp->fh), argp->len, argp->offset); - nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), NULL, + nfserr = nfsd_write(rqstp, fh_copy(&resp->fh, &argp->fh), argp->offset, rqstp->rq_vec, argp->vlen, &cnt,
fs/nfsd/vfs.c +11 -22
@@ -42,6 +42,7 @@#include "nfsd.h" #include "vfs.h" +#include "filecache.h" #define NFSDDBG_FACILITY NFSDDBG_FILEOP
@@ -1009,30 +1010,18 @@ __be32 nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp,* N.B. After this call fhp needs an fh_put */ __be32 -nfsd_write (struct svc_rqst *rqstp,struct svc_fh *fhp,struct file *file, -loff_t offset,struct kvec *vec,int vlen,unsigned long *cnt, -int *stablep) +nfsd_write (struct svc_rqst *rqstp,struct svc_fh *fhp,loff_t offset, +struct kvec *vec,int vlen,unsigned long *cnt,int *stablep) { -__be32 err =0 ; - -if (file) { - err =nfsd_permission (rqstp, fhp->fh_export, fhp->fh_dentry, -NFSD_MAY_WRITE |NFSD_MAY_OWNER_OVERRIDE ); -if (err) - goto out; - err =nfsd_vfs_write (rqstp, fhp, file, offset, vec, vlen, cnt, - stablep); - }else { - err =nfsd_open (rqstp, fhp,S_IFREG ,NFSD_MAY_WRITE , &file); -if (err) - goto out; - -if (cnt) - err =nfsd_vfs_write (rqstp, fhp, file, offset, vec, vlen, - cnt, stablep); -fput (file); +__be32 err; +struct nfsd_file *nf; + + err =nfsd_file_acquire (rqstp, fhp,NFSD_MAY_WRITE , &nf); +if (err == nfs_ok) { + err =nfsd_vfs_write (rqstp, fhp, nf->nf_file, offset, vec, + vlen, cnt, stablep); +nfsd_file_put (nf); } -out:return err; }
fs/nfsd/vfs.h +1 -1
@@ -79,7 +79,7 @@ __be32 nfsd_readv(struct file *, loff_t, struct kvec *, int, unsigned long *);__be32 nfsd_read (struct svc_rqst *,struct svc_fh *,loff_t ,struct kvec *,int ,unsigned long *); -__be32 nfsd_write (struct svc_rqst *,struct svc_fh *,struct file *, +__be32 nfsd_write (struct svc_rqst *,struct svc_fh *,loff_t ,struct kvec *,int ,unsigned long *,int *); __be32 nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, loff_t offset,
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 10/16 nfsd: hook up nfsd_read to the nfsd_file cache
In reply to a message not in the archive--- fs/nfsd/vfs.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
fs/nfsd/vfs.c +8 -13
@@ -987,20 +987,15 @@ out_nfserr:__be32 nfsd_read (struct svc_rqst *rqstp,struct svc_fh *fhp,loff_t offset,struct kvec *vec,int vlen,unsigned long *count) { -struct file *file; -struct raparms *ra; -__be32 err; - - err =nfsd_open (rqstp, fhp,S_IFREG ,NFSD_MAY_READ , &file); -if (err) -return err; - - ra =nfsd_init_raparms (file); - err =nfsd_vfs_read (rqstp, file, offset, vec, vlen, count); -if (ra) -nfsd_put_raparams (file, ra); -fput (file); +__be32 err; +struct nfsd_file *nf; + err =nfsd_file_acquire (rqstp, fhp,NFSD_MAY_READ , &nf); +if (err == nfs_ok) { + err =nfsd_vfs_read (rqstp, nf->nf_file, offset, vec, vlen, + count); +nfsd_file_put (nf); + }return err; }
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 11/16 nfsd: hook nfsd_commit up to the nfsd_file cache
In reply to a message not in the archiveUse cached filps if possible instead of opening a new one every time.
--- fs/nfsd/vfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
fs/nfsd/vfs.c +7 -7
@@ -1034,9 +1034,9 @@ __be32 nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset, unsigned long count) { - struct file *file; -loff_t end =LLONG_MAX ; -__be32 err = nfserr_inval; + struct nfsd_file *nf; +loff_t end =LLONG_MAX ; +__be32 err = nfserr_inval;if (offset <0 ) goto out;
@@ -1046,12 +1046,12 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, goto out; } - err =nfsd_open (rqstp, fhp,S_IFREG , -NFSD_MAY_WRITE |NFSD_MAY_NOT_BREAK_LEASE , &file); + err =nfsd_file_acquire (rqstp, fhp, +NFSD_MAY_WRITE |NFSD_MAY_NOT_BREAK_LEASE , &nf);if (err) goto out;if (EX_ISSYNC (fhp->fh_export)) { -int err2 =vfs_fsync_range (file, offset, end,0 ); +int err2 =vfs_fsync_range (nf->nf_file, offset, end,0 );if (err2 != -EINVAL ) err =nfserrno (err2);
@@ -1059,7 +1059,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, err = nfserr_notsupp; } -fput (file); +nfsd_file_put (nf); out:return err; }
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 13/16 nfsd: have nfsd_test_lock use the nfsd_file cache
In reply to a message not in the archive--- fs/nfsd/nfs4state.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nfsd/nfs4state.c +4 -4
@@ -5568,11 +5568,11 @@ out:*/ static __be32 nfsd_test_lock (struct svc_rqst *rqstp,struct svc_fh *fhp,struct file_lock *lock) { -struct file *file; -__be32 err =nfsd_open (rqstp, fhp,S_IFREG ,NFSD_MAY_READ , &file); +struct nfsd_file *nf; +__be32 err =nfsd_file_acquire (rqstp, fhp,NFSD_MAY_READ , &nf);if (!err) { - err =nfserrno (vfs_test_lock (file, lock)); -fput (file); + err =nfserrno (vfs_test_lock (nf->nf_file, lock)); +nfsd_file_put (nf); }return err; }
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 15/16 nfsd: hook up nfs4_preprocess_stateid_op to the nfsd_file cache
In reply to a message not in the archiveHave nfs4_preprocess_stateid_op pass back a nfsd_file instead of a filp. Since we now presume that the struct file will be persistent in most cases, we can stop fiddling with the raparms in the read code. This also means that we don't really care about the rd_tmp_file field anymore.
--- fs/nfsd/nfs4proc.c | 32 ++++++++++++++++---------------- fs/nfsd/nfs4state.c | 24 ++++++++++-------------- fs/nfsd/nfs4xdr.c | 16 +++++----------- fs/nfsd/state.h | 2 +- fs/nfsd/xdr4.h | 15 +++++++-------- 5 files changed, 39 insertions(+), 50 deletions(-)
fs/nfsd/nfs4proc.c +16 -16
@@ -758,7 +758,7 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, {__be32 status; - read->rd_filp =NULL ; + read->rd_nf =NULL ;if (read->rd_offset >=OFFSET_MAX )return nfserr_inval;
@@ -775,7 +775,7 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,/* check stateid */ status =nfs4_preprocess_stateid_op (rqstp, cstate, &read->rd_stateid, -RD_STATE , &read->rd_filp, &read->rd_tmp_file); +RD_STATE , &read->rd_nf);if (status) {dprintk ("NFSD: nfsd4_read: couldn't process stateid!\n" ); goto out;
@@ -921,7 +921,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,if (setattr->sa_iattr.ia_valid &ATTR_SIZE ) { status =nfs4_preprocess_stateid_op (rqstp, cstate, - &setattr->sa_stateid,WR_STATE ,NULL ,NULL ); + &setattr->sa_stateid,WR_STATE ,NULL );if (status) {dprintk ("NFSD: nfsd4_setattr: couldn't process stateid!\n" );return status;
@@ -977,7 +977,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_write *write) {stateid_t *stateid = &write->wr_stateid; -struct file *filp =NULL ; +struct nfsd_file *nf =NULL ;__be32 status = nfs_ok;unsigned long cnt;int nvecs;
@@ -986,7 +986,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,return nfserr_inval; status =nfs4_preprocess_stateid_op (rqstp, cstate, stateid,WR_STATE , - &filp,NULL ); + &nf);if (status) {dprintk ("NFSD: nfsd4_write: couldn't process stateid!\n" );return status;
@@ -999,10 +999,10 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nvecs =fill_in_write_vector (rqstp->rq_vec, write);WARN_ON_ONCE (nvecs >ARRAY_SIZE (rqstp->rq_vec)); - status =nfsd_vfs_write (rqstp, &cstate->current_fh, filp, + status =nfsd_vfs_write (rqstp, &cstate->current_fh, nf->nf_file, write->wr_offset, rqstp->rq_vec, nvecs, &cnt, &write->wr_how_written); -fput (filp); +nfsd_file_put (nf); write->wr_bytes_written = cnt;
@@ -1014,21 +1014,21 @@ nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, struct nfsd4_fallocate *fallocate, int flags) {__be32 status = nfserr_notsupp; -struct file *file; +struct nfsd_file *nf; status =nfs4_preprocess_stateid_op (rqstp, cstate, &fallocate->falloc_stateid, -WR_STATE , &file,NULL ); +WR_STATE , &nf);if (status != nfs_ok) {dprintk ("NFSD: nfsd4_fallocate: couldn't process stateid!\n" );return status; } - status =nfsd4_vfs_fallocate (rqstp, &cstate->current_fh, file, + status =nfsd4_vfs_fallocate (rqstp, &cstate->current_fh, nf->nf_file, fallocate->falloc_offset, fallocate->falloc_length, flags); -fput (file); +nfsd_file_put (nf);return status; }
@@ -1053,11 +1053,11 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, {int whence;__be32 status; -struct file *file; +struct nfsd_file *nf; status =nfs4_preprocess_stateid_op (rqstp, cstate, &seek->seek_stateid, -RD_STATE , &file,NULL ); +RD_STATE , &nf);if (status) {dprintk ("NFSD: nfsd4_seek: couldn't process stateid!\n" );return status;
@@ -1079,14 +1079,14 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,* Note: This call does change file->f_pos, but nothing in NFSD * should ever file->f_pos. */ - seek->seek_pos =vfs_llseek (file, seek->seek_offset, whence); + seek->seek_pos =vfs_llseek (nf->nf_file, seek->seek_offset, whence);if (seek->seek_pos <0 ) status =nfserrno (seek->seek_pos); -else if (seek->seek_pos >=i_size_read (file_inode (file))) +else if (seek->seek_pos >=i_size_read (file_inode (nf->nf_file))) seek->seek_eof = true; out: -fput (file); +nfsd_file_put (nf);return status; }
fs/nfsd/nfs4state.c +10 -14
@@ -4638,7 +4638,7 @@ nfs4_check_olstateid(struct svc_fh *fhp, struct nfs4_ol_stateid *ols, int flags)static __be32 nfs4_check_file (struct svc_rqst *rqstp,struct svc_fh *fhp,struct nfs4_stid *s, -struct file **filpp,bool *tmp_file,int flags) +struct nfsd_file **nfp,int flags) {int acc = (flags &RD_STATE ) ?NFSD_MAY_READ :NFSD_MAY_WRITE ;struct nfsd_file *nf;
@@ -4648,20 +4648,18 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s,if (nf) { status =nfsd_permission (rqstp, fhp->fh_export, fhp->fh_dentry, acc |NFSD_MAY_OWNER_OVERRIDE ); -if (status) +if (status) { +nfsd_file_put (nf); goto out; + } }else { status =nfsd_file_acquire (rqstp, fhp, acc, &nf);if (status)return status; - -if (tmp_file) - *tmp_file = true; } - *filpp =get_file (nf->nf_file); + *nfp = nf; out: -nfsd_file_put (nf);return status; }
@@ -4671,7 +4669,7 @@ out:__be32 nfs4_preprocess_stateid_op (struct svc_rqst *rqstp,struct nfsd4_compound_state *cstate,stateid_t *stateid, -int flags,struct file **filpp,bool *tmp_file) +int flags,struct nfsd_file **nfp) {struct svc_fh *fhp = &cstate->current_fh;struct inode *ino =d_inode (fhp->fh_dentry);
@@ -4680,10 +4678,8 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,struct nfs4_stid *s =NULL ;__be32 status; -if (filpp) - *filpp =NULL ; -if (tmp_file) - *tmp_file = false; +if (nfp) + *nfp =NULL ;if (grace_disallows_io (net, ino))return nfserr_grace;
@@ -4720,8 +4716,8 @@ nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, status =nfs4_check_fh (fhp, s); done: -if (!status && filpp) - status =nfs4_check_file (rqstp, fhp, s, filpp, tmp_file, flags); +if (status == nfs_ok && nfp) + status =nfs4_check_file (rqstp, fhp, s, nfp, flags); out:if (s)nfs4_put_stid (s);
fs/nfsd/nfs4xdr.c +5 -11
@@ -49,6 +49,7 @@#include "cache.h" #include "netns.h" #include "pnfs.h" +#include "filecache.h" #ifdef CONFIG_NFSD_V4_SECURITY_LABEL #include <linux/security.h>
@@ -3460,14 +3461,14 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, {unsigned long maxcount;struct xdr_stream *xdr = &resp->xdr; -struct file *file = read->rd_filp; +struct file *file;int starting_len = xdr->buf->len; -struct raparms *ra =NULL ;__be32 *p;if (nfserr) goto out; + file = read->rd_nf->nf_file; p =xdr_reserve_space (xdr,8 );/* eof flag and byte count */ if (!p) {WARN_ON_ONCE (test_bit (RQ_SPLICE_OK , &resp->rqstp->rq_flags));
@@ -3487,24 +3488,17 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, (xdr->buf->buflen - xdr->buf->len)); maxcount = min_t(unsigned long, maxcount, read->rd_length); -if (read->rd_tmp_file) - ra =nfsd_init_raparms (file); -if (file->f_op->splice_read &&test_bit (RQ_SPLICE_OK , &resp->rqstp->rq_flags)) nfserr =nfsd4_encode_splice_read (resp, read, file, maxcount);else nfserr =nfsd4_encode_readv (resp, read, file, maxcount); -if (ra) -nfsd_put_raparams (file, ra); -if (nfserr)xdr_truncate_encode (xdr, starting_len); - out: -if (file) -fput (file); +if (read->rd_nf) +nfsd_file_put (read->rd_nf);return nfserr; }
fs/nfsd/state.h +1 -1
@@ -585,7 +585,7 @@ struct nfsd_net;extern __be32 nfs4_preprocess_stateid_op (struct svc_rqst *rqstp,struct nfsd4_compound_state *cstate,stateid_t *stateid, -int flags,struct file **filp,bool *tmp_file); +int flags,struct nfsd_file **filp);__be32 nfsd4_lookup_stateid (struct nfsd4_compound_state *cstate,stateid_t *stateid,unsigned char typemask,struct nfs4_stid **s,struct nfsd_net *nn);
fs/nfsd/xdr4.h +7 -8
@@ -268,15 +268,14 @@ struct nfsd4_open_downgrade {struct nfsd4_read { -stateid_t rd_stateid;/* request */ -u64 rd_offset;/* request */ -u32 rd_length;/* request */ -int rd_vlen; -struct file *rd_filp; -bool rd_tmp_file; +stateid_t rd_stateid;/* request */ +u64 rd_offset;/* request */ +u32 rd_length;/* request */ +int rd_vlen; +struct nfsd_file *rd_nf; -struct svc_rqst *rd_rqstp;/* response */ -struct svc_fh * rd_fhp;/* response */ +struct svc_rqst *rd_rqstp;/* response */ +struct svc_fh *rd_fhp;/* response */ };struct nfsd4_readdir {
Signature · 6 lines
2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/16 list_lru: add list_lru_rotate
In reply to Jeff LaytonAdd a function that can move an entry to the MRU end of the list.
--- include/linux/list_lru.h | 13 +++++++++++++ mm/list_lru.c | 15 +++++++++++++++ 2 files changed, 28 insertions(+)
include/linux/list_lru.h +13 -0
@@ -96,6 +96,19 @@ bool list_lru_add(struct list_lru *lru, struct list_head *item);bool list_lru_del (struct list_lru *lru,struct list_head *item);/** +* list_lru_rotate: rotate an element to the end of an lru list +* @list_lru: the lru pointer +* @item: the item to be rotated +* +* This function moves an entry to the end of an LRU list. Should be used when +* an entry that is on the LRU is used, and should be moved to the MRU end of +* the list. If the item is not on a list, then this function has no effect. +* The comments about an element already pertaining to a list are also valid +* for list_lru_rotate. +*/ +void list_lru_rotate (struct list_lru *lru,struct list_head *item); + +/** * list_lru_count_one: return the number of objects currently held by @lru * @lru: the lru pointer. * @nid: the node id to count from.
mm/list_lru.c +15 -0
@@ -130,6 +130,21 @@ bool list_lru_del(struct list_lru *lru, struct list_head *item) }EXPORT_SYMBOL_GPL (list_lru_del); +void list_lru_rotate (struct list_lru *lru,struct list_head *item) +{ +int nid =page_to_nid (virt_to_page (item)); +struct list_lru_node *nlru = &lru->node[nid]; +struct list_lru_one *l; + +spin_lock (&nlru->lock); +if (!list_empty (item)) { + l =list_lru_from_kmem (nlru, item); +list_move_tail (item, &l->list); + } +spin_unlock (&nlru->lock); +} +EXPORT_SYMBOL_GPL (list_lru_rotate); +void list_lru_isolate (struct list_lru_one *list,struct list_head *item) {list_del_init (item);
Signature · 7 lines
2.4.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH v4 3/16 fs: allow __fput_sync to be used by non-kthreads and in modules
In reply to Jeff LaytonWe want nfsd to keep a cache of open files, but that would potentially block userland callers from obtaining leases on them. To fix this, we'll be adding a new notifier chain to the lease code that will call back into nfsd on any attempt to set a FL_LEASE. nfsd can then close any open files for that inode in advance of that.
The problem however is that since that notifier will run in normal process context, the final __fput will be delayed a'la task_work and we are still unable to set a lease. What we need to do is to put the struct file synchronously so that the __fput runs before returning from the notifier call.
The comments over __fput_sync and the BUG_ON in there mandate that it should only be used in kthread context, but I see no reason why that should be so. As long as the caller avoids holding locks that may be problematic, it should be OK to use it from normal process context as well.
Remove the __ prefix and the BUG_ON from that function and update the comments over it. Also export it so that it can be used from nfsd code, and move the export of fput just below the function definition.
--- fs/file_table.c | 27 ++++++++++++++------------- include/linux/file.h | 2 +- kernel/acct.c | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-)
fs/file_table.c +14 -13
@@ -280,25 +280,26 @@ void fput(struct file *file)schedule_delayed_work (&delayed_fput_work,1 ); } } +EXPORT_SYMBOL (fput);/* -* synchronous analog of fput(); for kernel threads that might be needed -* in some umount() (and thus can't use flush_delayed_fput() without -* risking deadlocks), need to wait for completion of __fput() and know -* for this specific struct file it won't involve anything that would -* need them. Use only if you really need it - at the very least, -* don't blindly convert fput() by kernel thread to that. +* synchronous analog of fput(); this is necessary for tasks +* that might be needed in some umount() (and thus can't use +* flush_delayed_fput() without risking deadlocks), need to wait for +* completion of __fput() and know for this specific struct file it +* won't involve anything that would need them. It's also necessary +* for nfsd, which needs to be able to synchronously close files +* on which userspace programs are trying to set leases. +* +* Use only if you really need it - at the very least, don't blindly +* convert fput() to this. */ -void __fput_sync (struct file *file) +void fput_sync (struct file *file) { -if (atomic_long_dec_and_test (&file->f_count)) { -struct task_struct *task = current; -BUG_ON (!(task->flags &PF_KTHREAD )); +if (atomic_long_dec_and_test (&file->f_count))__fput (file); - } } - -EXPORT_SYMBOL (fput); +EXPORT_SYMBOL (fput_sync);void put_filp (struct file *file) {
include/linux/file.h +1 -1
@@ -71,6 +71,6 @@ extern void put_unused_fd(unsigned int fd);extern void fd_install (unsigned int fd,struct file *file);extern void flush_delayed_fput (void ); -extern void __fput_sync (struct file *); +extern void fput_sync (struct file *);#endif /* __LINUX_FILE_H */
kernel/acct.c +1 -1
@@ -183,7 +183,7 @@ static void close_work(struct work_struct *work)struct file *file = acct->file;if (file->f_op->flush) file->f_op->flush (file,NULL ); -__fput_sync (file); +fput_sync (file);complete (&acct->done); }
Signature · 1 line
2.4.3
A message that is not in the archive (sent off-list or not yet received): 1441968882-7851-4-git-send-email-jeff.layton-7I+n7zu2hftEKMMhf/[email protected]
Re: [PATCH v4 03/16] fs: allow __fput_sync to be used by non-kthreads and in modules
Quoted 18 lines · Jeff Layton
We want nfsd to keep a cache of open files, but that would potentially block userland callers from obtaining leases on them. To fix this, we'll be adding a new notifier chain to the lease code that will call back into nfsd on any attempt to set a
FL_LEASE. nfsd can then close any open files for that inode in advance of that.The problem however is that since that notifier will run in normal process context, the final
__fputwill be delayed a'latask_workand we are still unable to set a lease. What we need to do is to put the struct file synchronously so that the__fputruns before returning from the notifier call.The comments over
__fput_syncand theBUG_ONin there mandate that it should only be used in kthread context, but I see no reason why that should be so. As long as the caller avoids holding locks that may be problematic, it should be OK to use it from normal process context as well.
Quoted 3 lines
Remove the __ prefix and the
BUG_ONfrom that function and update the comments over it. Also export it so that it can be used from nfsd code, and move the export of fput just below the function definition.
I really don't like that.
a) how deep in kernel stack will that thing run?
b) what locking environment is expected in your case?
And opening it for use by any random driver that just feels like e.g. using it to go parse its config over there in /lib/we/are/special/wank.conf with 5Kb worth of kernel stack already eaten is a really bad idea. --
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 20150911140049.GN22011-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org
Re: [PATCH v4 03/16] fs: allow __fput_sync to be used by non-kthreads and in modules
Quoted 23 lines · On Fri, 11 Sep 2015 15:00:49 +0100 Al Viro…
Quoted 18 lines · Jeff Layton
We want nfsd to keep a cache of open files, but that would potentially block userland callers from obtaining leases on them. To fix this, we'll be adding a new notifier chain to the lease code that will call back into nfsd on any attempt to set a
FL_LEASE. nfsd can then close any open files for that inode in advance of that.The problem however is that since that notifier will run in normal process context, the final
__fputwill be delayed a'latask_workand we are still unable to set a lease. What we need to do is to put the struct file synchronously so that the__fputruns before returning from the notifier call.The comments over
__fput_syncand theBUG_ONin there mandate that it should only be used in kthread context, but I see no reason why that should be so. As long as the caller avoids holding locks that may be problematic, it should be OK to use it from normal process context as well.Quoted 3 lines
Remove the __ prefix and the
BUG_ONfrom that function and update the comments over it. Also export it so that it can be used from nfsd code, and move the export of fput just below the function definition.
Quoted 7 lines
I really don't like that.
a) how deep in kernel stack will that thing run?
b) what locking environment is expected in your case?And opening it for use by any random driver that just feels like e.g. using it to go parse its config over there in
/lib/we/are/special/wank.confwith 5Kb worth of kernel stack already eaten is a really bad idea.
Not too deep in our case, and with no real locking held aside from a SRCU lock. Basically we're going to have a SRCU notifier chain that will run from vfs_setlease. That will call back into the nfsd code when it's running which will scan the hash for open files for the inode, unhash and release them (synchronously). If they're being held open in the cache but are otherwise idle, that's enough to allow a lease to be acquired.
That said, I'm not thrilled with it either. There are some alternatives:
1) we could just call task_work_run after the fput, but that seems scary if (e.g.) some random interrupt walks in and queues up some task_work.
2) we could add a "delayed_fput(file)", that adds it to the delayed_fput_list, even when being run from normal process context. Then we could just flush_delayed_fput() afterward. More context switching, but that should be relatively safe I'd think.
Signature · 5 lines
Jeff Layton <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 4/16 fsnotify: export several symbols
In reply to Jeff LaytonWith nfsd's new open-file caching infrastructure, we need a way to know when unlinks occur so it can close files that it may be holding open. fsnotify fits the bill nicely, but the symbols aren't currently exported to modules. Export some of its symbols so nfsd can use this infrastructure.
--- fs/notify/group.c | 2 ++ fs/notify/mark.c | 3 +++ 2 files changed, 5 insertions(+)
fs/notify/group.c +2 -0
@@ -81,6 +81,7 @@ void fsnotify_put_group(struct fsnotify_group *group)if (atomic_dec_and_test (&group->refcnt))fsnotify_final_destroy_group (group); } +EXPORT_SYMBOL_GPL (fsnotify_put_group);/* * Create a new fsnotify_group and hold a reference for the group returned.
@@ -109,6 +110,7 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)return group; } +EXPORT_SYMBOL_GPL (fsnotify_alloc_group);int fsnotify_fasync (int fd,struct file *file,int on) {
fs/notify/mark.c +3 -0
@@ -184,6 +184,7 @@ void fsnotify_destroy_mark(struct fsnotify_mark *mark,fsnotify_destroy_mark_locked (mark, group);mutex_unlock (&group->mark_mutex); } +EXPORT_SYMBOL_GPL (fsnotify_destroy_mark);/* * Destroy all marks in the given list. The marks must be already detached from
@@ -371,6 +372,7 @@ int fsnotify_add_mark(struct fsnotify_mark *mark, struct fsnotify_group *group,mutex_unlock (&group->mark_mutex);return ret; } +EXPORT_SYMBOL_GPL (fsnotify_add_mark);/* * Given a list of marks, find the mark associated with given group. If found
@@ -440,6 +442,7 @@ void fsnotify_init_mark(struct fsnotify_mark *mark,atomic_set (&mark->refcnt,1 ); mark->free_mark = free_mark; } +EXPORT_SYMBOL_GPL (fsnotify_init_mark);static int fsnotify_mark_destroy (void *ignored) {
Signature · 1 line
2.4.3
PATCH v4 6/16 nfsd: move include of state.h from trace.c to trace.h
In reply to Jeff LaytonAny file which includes trace.h will need to include state.h, even if they aren't using any state tracepoints. Ensure that we include any headers that might be needed in trace.h instead of relying on the *.c files to have the right ones.
--- fs/nfsd/trace.c | 2 -- fs/nfsd/trace.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
fs/nfsd/trace.c +0 -2
@@ -1,5 +1,3 @@ -#include "state.h" -#define CREATE_TRACE_POINTS #include "trace.h"
fs/nfsd/trace.h +2 -0
@@ -9,6 +9,8 @@#include <linux/tracepoint.h> +#include "state.h" + DECLARE_EVENT_CLASS(nfsd_stateid_class, TP_PROTO(stateid_t *stp), TP_ARGS(stp),
Signature · 1 line
2.4.3
PATCH v4 7/16 sunrpc: add a new cache_detail operation for when a cache is flushed
In reply to Jeff LaytonWhen the exports table is changed, exportfs will usually write a new time to the "flush" file in the nfsd.export cache procfile. This tells the kernel to flush any entries that are older than that value.
This gives us a mechanism to tell whether an unexport might have occurred. Add a new ->flush cache_detail operation that is called after flushing the cache whenever someone writes to a "flush" file.
--- include/linux/sunrpc/cache.h | 1 + net/sunrpc/cache.c | 3 +++ 2 files changed, 4 insertions(+)
include/linux/sunrpc/cache.h +1 -0
@@ -98,6 +98,7 @@ struct cache_detail { int has_died);struct cache_head * (*alloc)(void ); +void (*flush)(void );int (*match)(struct cache_head *orig,struct cache_head *new);void (*init)(struct cache_head *orig,struct cache_head *new);void (*update)(struct cache_head *orig,struct cache_head *new);
net/sunrpc/cache.c +3 -0
@@ -1451,6 +1451,9 @@ static ssize_t write_flush(struct file *file, const char __user *buf, cd->nextcheck =seconds_since_boot ();cache_flush (); +if (cd->flush) + cd->flush (); + *ppos += count;return count; }
Signature · 1 line
2.4.3
PATCH v4 12/16 nfsd: convert nfs4_file->fi_fds array to use nfsd_files
In reply to Jeff Layton--- fs/nfsd/nfs4state.c | 23 ++++++++++++----------- fs/nfsd/state.h | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-)
fs/nfsd/nfs4state.c +12 -11
@@ -49,6 +49,7 @@#include "netns.h" #include "pnfs.h" +#include "filecache.h" #define NFSDDBG_FACILITY NFSDDBG_PROC
@@ -292,7 +293,7 @@ static struct file * __nfs4_get_fd(struct nfs4_file *f, int oflag) {if (f->fi_fds[oflag]) -return get_file (f->fi_fds[oflag]); +return get_file (f->fi_fds[oflag]->nf_file);return NULL ; }
@@ -449,17 +450,17 @@ static void __nfs4_file_put_access(struct nfs4_file *fp, int oflag)might_lock (&fp->fi_lock);if (atomic_dec_and_lock (&fp->fi_access[oflag], &fp->fi_lock)) { -struct file *f1 =NULL ; -struct file *f2 =NULL ; +struct nfsd_file *f1 =NULL ; +struct nfsd_file *f2 =NULL ;swap (f1, fp->fi_fds[oflag]);if (atomic_read (&fp->fi_access[1 - oflag]) ==0 )swap (f2, fp->fi_fds[O_RDWR ]);spin_unlock (&fp->fi_lock);if (f1) -fput (f1); +nfsd_file_put (f1);if (f2) -fput (f2); +nfsd_file_put (f2); } }
@@ -3827,7 +3828,7 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *cur_fh, struct nfs4_ol_stateid *stp, struct nfsd4_open *open) { - struct file *filp = NULL; + struct nfsd_file *nf = NULL;__be32 status;int oflag =nfs4_access_to_omode (open->op_share_access);int access =nfs4_access_to_access (open->op_share_access);
@@ -3863,18 +3864,18 @@ static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp,if (!fp->fi_fds[oflag]) {spin_unlock (&fp->fi_lock); - status =nfsd_open (rqstp, cur_fh,S_IFREG , access, &filp); + status =nfsd_file_acquire (rqstp, cur_fh, access, &nf);if (status) goto out_put_access;spin_lock (&fp->fi_lock);if (!fp->fi_fds[oflag]) { - fp->fi_fds[oflag] = filp; - filp =NULL ; + fp->fi_fds[oflag] = nf; + nf =NULL ; } }spin_unlock (&fp->fi_lock); -if (filp) -fput (filp); +if (nf) +nfsd_file_put (nf); status =nfsd4_truncate (rqstp, cur_fh, open);if (status)
fs/nfsd/state.h +1 -1
@@ -499,7 +499,7 @@ struct nfs4_file { };struct list_head fi_clnt_odstate;/* One each for O_RDONLY, O_WRONLY, O_RDWR: */ -struct file * fi_fds[3 ]; +struct nfsd_file *fi_fds[3 ];/* * Each open or lock stateid contributes 0-4 to the counts * below depending on which bits are set in st_access_bitmap:
Signature · 1 line
2.4.3
PATCH v4 14/16 nfsd: convert fi_deleg_file and ls_file fields to nfsd_file
In reply to Jeff LaytonHave them keep an nfsd_file reference instead of a struct file.
--- fs/nfsd/nfs4layouts.c | 12 ++--- fs/nfsd/nfs4state.c | 131 ++++++++++++++++++++++++++------------------------ fs/nfsd/state.h | 6 +-- 3 files changed, 76 insertions(+), 73 deletions(-)
fs/nfsd/nfs4layouts.c +6 -6
@@ -144,8 +144,8 @@ nfsd4_free_layout_stateid(struct nfs4_stid *stid)list_del_init (&ls->ls_perfile);spin_unlock (&fp->fi_lock); -vfs_setlease (ls->ls_file,F_UNLCK ,NULL , (void **)&ls); -fput (ls->ls_file); +vfs_setlease (ls->ls_file->nf_file,F_UNLCK ,NULL , (void **)&ls); +nfsd_file_put (ls->ls_file);if (ls->ls_recalled)atomic_dec (&ls->ls_stid.sc_file->fi_lo_recalls);
@@ -169,7 +169,7 @@ nfsd4_layout_setlease(struct nfs4_layout_stateid *ls) fl->fl_end =OFFSET_MAX ; fl->fl_owner = ls; fl->fl_pid = current->tgid; - fl->fl_file = ls->ls_file; + fl->fl_file = ls->ls_file->nf_file; status =vfs_setlease (fl->fl_file, fl->fl_type, &fl,NULL );if (status) {
@@ -206,13 +206,13 @@ nfsd4_alloc_layout_stateid(struct nfsd4_compound_state *cstate, NFSPROC4_CLNT_CB_LAYOUT);if (parent->sc_type ==NFS4_DELEG_STID ) - ls->ls_file =get_file (fp->fi_deleg_file); + ls->ls_file =nfsd_file_get (fp->fi_deleg_file);else ls->ls_file =find_any_file (fp);BUG_ON (!ls->ls_file);if (nfsd4_layout_setlease (ls)) { -fput (ls->ls_file); +nfsd_file_put (ls->ls_file);put_nfs4_file (fp);kmem_cache_free (nfs4_layout_stateid_cache, ls);return NULL ;
@@ -598,7 +598,7 @@ nfsd4_cb_layout_fail(struct nfs4_layout_stateid *ls) argv[0 ] ="/sbin/nfsd-recall-failed" ; argv[1 ] = addr_str; - argv[2 ] = ls->ls_file->f_path.mnt->mnt_sb->s_id; + argv[2 ] = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_id; argv[3 ] =NULL ; error =call_usermodehelper (argv[0 ], argv, envp,UMH_WAIT_PROC );
fs/nfsd/nfs4state.c +67 -64
354 lines not on this page · raw message
fs/nfsd/state.h +3 -3
@@ -509,7 +509,7 @@ struct nfs4_file {*/ atomic_t fi_access[2 ];u32 fi_share_deny; -struct file *fi_deleg_file; +struct nfsd_file *fi_deleg_file;int fi_delegees;struct knfsd_fh fi_fhandle;bool fi_had_conflict;
@@ -557,7 +557,7 @@ struct nfs4_layout_stateid {spinlock_t ls_lock;struct list_head ls_layouts;u32 ls_layout_type; -struct file *ls_file; +struct nfsd_file *ls_file;struct nfsd4_callback ls_recall;stateid_t ls_recall_sid;bool ls_recalled;
@@ -620,7 +620,7 @@ static inline void get_nfs4_file(struct nfs4_file *fi) {atomic_inc (&fi->fi_ref); } -struct file *find_any_file (struct nfs4_file *f); +struct nfsd_file *find_any_file (struct nfs4_file *f);/* grace period management */ void nfsd4_end_grace (struct nfsd_net *nn);
Signature · 1 line
2.4.3
PATCH v4 16/16 nfsd: rip out the raparms cache
In reply to Jeff LaytonNothing uses it anymore.
--- fs/nfsd/nfssvc.c | 14 +----- fs/nfsd/vfs.c | 147 ------------------------------------------------------- fs/nfsd/vfs.h | 5 -- 3 files changed, 1 insertion(+), 165 deletions(-)
fs/nfsd/nfssvc.c +1 -13
@@ -216,18 +216,9 @@ static int nfsd_startup_generic(int nrservs)if (nfsd_users++)return 0 ; -/* -* Readahead param cache - will no-op if it already exists. -* (Note therefore results will be suboptimal if number of -* threads is modified after nfsd start.) -*/ - ret =nfsd_racache_init (2 *nrservs); -if (ret) - goto dec_users; - ret =nfsd_file_cache_init ();if (ret) - goto out_racache; + goto dec_users; ret =nfs4_state_start ();if (ret)
@@ -236,8 +227,6 @@ static int nfsd_startup_generic(int nrservs) out_file_cache:nfsd_file_cache_shutdown (); -out_racache: -nfsd_racache_shutdown (); dec_users: nfsd_users--;return ret;
@@ -250,7 +239,6 @@ static void nfsd_shutdown_generic(void)nfs4_state_shutdown ();nfsd_file_cache_shutdown (); -nfsd_racache_shutdown (); }static bool nfsd_needs_lockd (void )
fs/nfsd/vfs.c +0 -147
162 lines not on this page · raw message
fs/nfsd/vfs.h +0 -5
@@ -39,8 +39,6 @@typedef int (*nfsd_filldir_t )(void *,const char *,int ,loff_t ,u64 ,unsigned );/* nfsd/vfs.c */ -int nfsd_racache_init (int ); -void nfsd_racache_shutdown (void );int nfsd_cross_mnt (struct svc_rqst *rqstp,struct dentry **dpp,struct svc_export **expp); __be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
@@ -105,9 +103,6 @@ __be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,__be32 nfsd_permission (struct svc_rqst *,struct svc_export *,struct dentry *,int ); -struct raparms *nfsd_init_raparms (struct file *file); -void nfsd_put_raparams (struct file *file,struct raparms *ra); -static inline int fh_want_write (struct svc_fh *fh) {int ret =mnt_want_write (fh->fh_export->ex_path.mnt);
Signature · 1 line
2.4.3