NFSD: delay unmount source's export after inter-server copy completed.
Subsystems (2)
Dai Ngo
reviewerv7 cover NFSD: delay unmount source's export after inter-server copy completed.
Hi Olga, Bruce,
Currently the source's export is mounted and unmounted on every inter-server copy operation. This causes unnecessary overhead for each copy.
This patch series is an enhancement to allow the export to remain mounted for a configurable period (default to 15 minutes). If the export is not being used for the configured time it will be unmounted by a delayed task. If it's used again then its expiration time is extended for another period.
Since mount and unmount are no longer done on every copy request, the restriction of copy size (14*rsize), in __nfs4_copy_file_range, is removed.
-Dai
v2: fix compiler warning of missing prototype.
v3: remove the used of semaphore.
eliminated all RPC calls for subsequence mount by allowing
all exports from one server to share one vfsmount.
make inter-server threshold a module configuration parameter.
v4: convert nsui_refcnt to use refcount_t.
add note about 20secs wait in nfsd4_interssc_connect. removed (14*rsize) restriction from __nfs4_copy_file_range.
v5: make use of the laundomat thread to service delayed unmount list.
destroy delayed unmount list when nfsd is shutdown. make delayed unmount list per nfsd_net to support container.
v6: move content of nfsd4_ssc_umount in to nfsd_net.
move code that manages the delayed unmount list
from nfsd/nfs4proc.c to nfsd/nfs4state.c
cleanup left over from previous versions.
rebase to 5.13-rc2
v7: simplify nfsd4_interssc_connect by moving changes into
functions.
Dai Ngo
reviewerPATCH v7 1/2 NFSD: delay unmount source's export after inter-server copy completed.
Currently the source's export is mounted and unmounted on every inter-server copy operation. This patch is an enhancement to delay the unmount of the source export for a certain period of time to eliminate the mount and unmount overhead on subsequent copy operations.
After a copy operation completes, a work entry is added to the delayed unmount list with an expiration time. This list is serviced by the laundromat thread to unmount the export of the expired entries. Each time the export is being used again, its expiration time is extended and the entry is re-inserted to the tail of the list.
The unmount task and the mount operation of the copy request are synced to make sure the export is not unmounted while it's being used.
--- fs/nfsd/netns.h | 6 +++ fs/nfsd/nfs4proc.c | 135 ++++++++++++++++++++++++++++++++++++++++++++++-- fs/nfsd/nfs4state.c | 71 +++++++++++++++++++++++++ fs/nfsd/nfsd.h | 4 ++ fs/nfsd/nfssvc.c | 3 ++ include/linux/nfs_ssc.h | 14 +++++ 6 files changed, 229 insertions(+), 4 deletions(-)
fs/nfsd/netns.h +6 -0
@@ -176,6 +176,12 @@ struct nfsd_net {unsigned int longest_chain_cachesize;struct shrinker nfsd_reply_cache_shrinker; + +/* tracking server-to-server copy mounts */ +spinlock_t nfsd_ssc_lock; +struct list_head nfsd_ssc_mount_list; +wait_queue_head_t nfsd_ssc_waitq; +/* utsname taken from the process that starts the server */ char nfsd_name[UNX_MAXNODENAME +1 ]; };
fs/nfsd/nfs4proc.c +131 -4
171 lines not on this page · raw message
fs/nfsd/nfs4state.c +71 -0
95 lines not on this page · raw message
fs/nfsd/nfsd.h +4 -0
@@ -484,6 +484,10 @@ static inline bool nfsd_attrs_supported(u32 minorversion, const u32 *bmval)extern int nfsd4_is_junction (struct dentry *dentry);extern int register_cld_notifier (void );extern void unregister_cld_notifier (void ); +#ifdef CONFIG_NFSD_V4_2_INTER_SSC +extern void nfsd4_ssc_init_umount_work (struct nfsd_net *nn); +#endif +#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry) {
fs/nfsd/nfssvc.c +3 -0
@@ -403,6 +403,9 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred)if (ret) goto out_filecache; +#ifdef CONFIG_NFSD_V4_2_INTER_SSC +nfsd4_ssc_init_umount_work (nn); +#endif nn->nfsd_net_up = true;return 0 ;
include/linux/nfs_ssc.h +14 -0
@@ -8,6 +8,7 @@*/ #include <linux/nfs_fs.h> +#include <linux/sunrpc/svc.h> extern struct nfs_ssc_client_ops_tbl nfs_ssc_client_tbl;
@@ -52,6 +53,19 @@ static inline void nfs42_ssc_close(struct file *filep)if (nfs_ssc_client_tbl.ssc_nfs4_ops) (*nfs_ssc_client_tbl.ssc_nfs4_ops->sco_close)(filep); } + +struct nfsd4_ssc_umount_item { +struct list_head nsui_list; +bool nsui_busy; +/* +* nsui_refcnt inited to 2, 1 on list and 1 for consumer. Entry +* is removed when refcnt drops to 1 and nsui_expire expires. +*/ +refcount_t nsui_refcnt; +unsigned long nsui_expire; +struct vfsmount *nsui_vfsmount; +char nsui_ipaddr[RPC_MAX_ADDRBUFLEN ]; +};#endif /*
Signature · 1 line
2.9.5
Dai Ngo
reviewerPATCH v7 2/2 NFSv4.2: remove restriction of copy size for inter-server copy.
In reply to Dai NgoCurrently inter-server copy is allowed only if the copy size is larger than (rsize*14) which is the over-head of the mount operation of the source export. This patch, relying on the delayed unmount feature, removes this restriction since the mount and unmount overhead is now not applicable for every inter-server copy.
--- fs/nfs/nfs4file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/nfs/nfs4file.c +4 -6
@@ -158,13 +158,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, sync = true; retry:if (!nfs42_files_from_same_server (file_in, file_out)) { -/* for inter copy, if copy size if smaller than 12 RPC -* payloads, fallback to traditional copy. There are -* 14 RPCs during an NFSv4.x mount between source/dest -* servers. +/* +* for inter copy, if copy size is too small +* then fallback to generic copy. */ -if (sync || - count <=14 *NFS_SERVER (file_inode (file_in))->rsize) +if (sync)return -EOPNOTSUPP ; cn_resp =kzalloc (sizeof (struct nfs42_copy_notify_res ),GFP_NOFS );
Signature · 1 line
2.9.5
Re: [PATCH v7 2/2] NFSv4.2: remove restriction of copy size for inter-server copy.
Whoops, I overlooked that this is client side, so it needs to go through Trond or Anna, not me.
Also note:
Quoted 3 lines · Dai Ngo
This patch, relying on the delayed unmount feature, removes this restriction since the mount and unmount overhead is now not applicable for every inter-server copy.
There's no guarantee that the same kernel version is running on client and server, or even that the server is a Linux server.
If there's reason to expect that the lower overhead should be more typical of servers in general, then say that....
--b.
Quoted 30 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfs/nfs4file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/nfs/nfs4file.c +4
-6@@ -158,13 +158,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, sync = true; retry:if (!nfs42_files_from_same_server (file_in, file_out)) { -/* for inter copy, if copy size if smaller than 12 RPC -* payloads, fallback to traditional copy. There are -* 14 RPCs during an NFSv4.x mount between source/dest -* servers. +/* +* for inter copy, if copy size is too small +* then fallback to generic copy. */ -if (sync || - count <=14 *NFS_SERVER (file_inode (file_in))->rsize) +if (sync)return -EOPNOTSUPP ; cn_resp =kzalloc (sizeof (struct nfs42_copy_notify_res ),GFP_NOFS );Signature · 1 line
2.9.5
Re: [PATCH v7 2/2] NFSv4.2: remove restriction of copy size for inter-server copy.
Quoted 11 lines · J. Bruce Fields
Whoops, I overlooked that this is client side, so it needs to go through Trond or Anna, not me.
Also note:
Quoted 3 lines · Dai Ngo
This patch, relying on the delayed unmount feature, removes this restriction since the mount and unmount overhead is now not applicable for every inter-server copy.
Quoted 5 lines
There's no guarantee that the same kernel version is running on client and server, or even that the server is a Linux server.
If there's reason to expect that the lower overhead should be more typical of servers in general, then say that....
I'm in support of this patch not because I expect lower overhead is more typical but because the initial logic was there to match the limitations of the only existing implementation (ie Linux server) that was doing a mount for every copy that's out there. Now that we are adding support for delayed unmount to the linux server, it is not important to restrict the size of the copy. Linux server is the ONLY known implementation of the inter-SSC feature thus it's hard to say what's typical. Given the improved linux server implementation shows that it's possible to do short copies as well, I think it's fair to remove that restriction on the client and expect that other implementations would be as good or better.
Yes I think client side maintainers need to chime in if they have objections to the patch.
Quoted 33 lines
--b.
Quoted 30 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfs/nfs4file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/nfs/nfs4file.c +4
-7@@ -158,13 +158,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, sync = true; retry:if (!nfs42_files_from_same_server (file_in, file_out)) { -/* for inter copy, if copy size if smaller than 12 RPC -* payloads, fallback to traditional copy. There are -* 14 RPCs during an NFSv4.x mount between source/dest -* servers. +/* +* for inter copy, if copy size is too small +* then fallback to generic copy. */ -if (sync || - count <=14 *NFS_SERVER (file_inode (file_in))->rsize) +if (sync)return -EOPNOTSUPP ; cn_resp =kzalloc (sizeof (struct nfs42_copy_notify_res ),GFP_NOFS ); --2.9.5
Re: [PATCH v7 2/2] NFSv4.2: remove restriction of copy size for inter-server copy.
Quoted 31 lines · Olga Kornievskaia
Quoted 11 lines · J. Bruce Fields
Whoops, I overlooked that this is client side, so it needs to go through Trond or Anna, not me.
Also note:
Quoted 3 lines · Dai Ngo
This patch, relying on the delayed unmount feature, removes this restriction since the mount and unmount overhead is now not applicable for every inter-server copy.
Quoted 5 lines
There's no guarantee that the same kernel version is running on client and server, or even that the server is a Linux server.
If there's reason to expect that the lower overhead should be more typical of servers in general, then say that....
I'm in support of this patch not because I expect lower overhead is more typical but because the initial logic was there to match the limitations of the only existing implementation (ie Linux server) that was doing a mount for every copy that's out there. Now that we are adding support for delayed unmount to the linux server, it is not important to restrict the size of the copy. Linux server is the ONLY known implementation of the inter-SSC feature thus it's hard to say what's typical. Given the improved linux server implementation shows that it's possible to do short copies as well, I think it's fair to remove that restriction on the client and expect that other implementations would be as good or better.
Quoted 2 lines
Yes I think client side maintainers need to chime in if they have objections to the patch.
So I don't see anything wrong with this patch, and I'm assuming it just got missed due to Bruce initially "claiming" it before realizing it's for the wrong subsystem. Anyway, I just put it into my tree for the next merge.
Anna
Quoted 34 lines
Quoted 34 lines
--b.
Quoted 30 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfs/nfs4file.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/nfs/nfs4file.c +4
-7@@ -158,13 +158,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, sync = true; retry:if (!nfs42_files_from_same_server (file_in, file_out)) { -/* for inter copy, if copy size if smaller than 12 RPC -* payloads, fallback to traditional copy. There are -* 14 RPCs during an NFSv4.x mount between source/dest -* servers. +/* +* for inter copy, if copy size is too small +* then fallback to generic copy. */ -if (sync || - count <=14 *NFS_SERVER (file_inode (file_in))->rsize) +if (sync)return -EOPNOTSUPP ; cn_resp =kzalloc (sizeof (struct nfs42_copy_notify_res ),GFP_NOFS ); --2.9.5