Message ID | 164313725230.3285.5420060785593218794.stgit@bazille.1015granger.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Clean up struct svc_serv_ops | expand |
On Wed, 26 Jan 2022, Chuck Lever wrote: > Clean up. Neil observed that "any code that calls svc_shutdown_net() > knows what the shutdown function should be, and so can call it > directly." > > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > --- > fs/lockd/svc.c | 5 ++--- > fs/nfsd/nfssvc.c | 2 +- > include/linux/sunrpc/svc.h | 3 --- > net/sunrpc/svc.c | 3 --- > 4 files changed, 3 insertions(+), 10 deletions(-) > > diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c > index 3a05af873625..f5b688a844aa 100644 > --- a/fs/lockd/svc.c > +++ b/fs/lockd/svc.c > @@ -249,6 +249,7 @@ static int make_socks(struct svc_serv *serv, struct net *net, > printk(KERN_WARNING > "lockd_up: makesock failed, error=%d\n", err); > svc_shutdown_net(serv, net); > + svc_rpcb_cleanup(serv, net); > return err; > } > > @@ -287,8 +288,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net) > cancel_delayed_work_sync(&ln->grace_period_end); > locks_end_grace(&ln->lockd_manager); > svc_shutdown_net(serv, net); > - dprintk("%s: per-net data destroyed; net=%x\n", > - __func__, net->ns.inum); > + svc_rpcb_cleanup(serv, net); > } > } else { > pr_err("%s: no users! net=%x\n", > @@ -351,7 +351,6 @@ static struct notifier_block lockd_inet6addr_notifier = { > #endif > > static const struct svc_serv_ops lockd_sv_ops = { > - .svo_shutdown = svc_rpcb_cleanup, > .svo_function = lockd, > .svo_module = THIS_MODULE, > }; > diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c > index aeeac6de1f0a..0c6b216e439e 100644 > --- a/fs/nfsd/nfssvc.c > +++ b/fs/nfsd/nfssvc.c > @@ -613,7 +613,6 @@ static int nfsd_get_default_max_blksize(void) > } > > static const struct svc_serv_ops nfsd_thread_sv_ops = { > - .svo_shutdown = nfsd_last_thread, > .svo_function = nfsd, > .svo_module = THIS_MODULE, > }; > @@ -724,6 +723,7 @@ void nfsd_put(struct net *net) > > if (kref_put(&nn->nfsd_serv->sv_refcnt, nfsd_noop)) { > svc_shutdown_net(nn->nfsd_serv, net); > + nfsd_last_thread(nn->nfsd_serv, net); > svc_destroy(&nn->nfsd_serv->sv_refcnt); > spin_lock(&nfsd_notifier_lock); > nn->nfsd_serv = NULL; > diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h > index 6ef9c1cafd0b..63794d772eb3 100644 > --- a/include/linux/sunrpc/svc.h > +++ b/include/linux/sunrpc/svc.h > @@ -55,9 +55,6 @@ struct svc_pool { > struct svc_serv; > > struct svc_serv_ops { > - /* Callback to use when last thread exits. */ > - void (*svo_shutdown)(struct svc_serv *, struct net *); > - > /* function for service threads to run */ > int (*svo_function)(void *); > > diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c > index 2aabec2b4bec..74a75a22da9a 100644 > --- a/net/sunrpc/svc.c > +++ b/net/sunrpc/svc.c > @@ -539,9 +539,6 @@ EXPORT_SYMBOL_GPL(svc_create_pooled); > void svc_shutdown_net(struct svc_serv *serv, struct net *net) > { > svc_close_net(serv, net); > - > - if (serv->sv_ops->svo_shutdown) > - serv->sv_ops->svo_shutdown(serv, net); > } > EXPORT_SYMBOL_GPL(svc_shutdown_net); Could we rename svc_close_net() to svc_shutdown_net() and drop this function? Either way: Reviewed-by: NeilBrown <neilb@suse.de> Thanks, NeilBrown
> On Jan 25, 2022, at 4:53 PM, NeilBrown <neilb@suse.de> wrote: > > On Wed, 26 Jan 2022, Chuck Lever wrote: >> Clean up. Neil observed that "any code that calls svc_shutdown_net() >> knows what the shutdown function should be, and so can call it >> directly." >> >> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> >> --- >> fs/lockd/svc.c | 5 ++--- >> fs/nfsd/nfssvc.c | 2 +- >> include/linux/sunrpc/svc.h | 3 --- >> net/sunrpc/svc.c | 3 --- >> 4 files changed, 3 insertions(+), 10 deletions(-) >> >> diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c >> index 3a05af873625..f5b688a844aa 100644 >> --- a/fs/lockd/svc.c >> +++ b/fs/lockd/svc.c >> @@ -249,6 +249,7 @@ static int make_socks(struct svc_serv *serv, struct net *net, >> printk(KERN_WARNING >> "lockd_up: makesock failed, error=%d\n", err); >> svc_shutdown_net(serv, net); >> + svc_rpcb_cleanup(serv, net); >> return err; >> } >> >> @@ -287,8 +288,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net) >> cancel_delayed_work_sync(&ln->grace_period_end); >> locks_end_grace(&ln->lockd_manager); >> svc_shutdown_net(serv, net); >> - dprintk("%s: per-net data destroyed; net=%x\n", >> - __func__, net->ns.inum); >> + svc_rpcb_cleanup(serv, net); >> } >> } else { >> pr_err("%s: no users! net=%x\n", >> @@ -351,7 +351,6 @@ static struct notifier_block lockd_inet6addr_notifier = { >> #endif >> >> static const struct svc_serv_ops lockd_sv_ops = { >> - .svo_shutdown = svc_rpcb_cleanup, >> .svo_function = lockd, >> .svo_module = THIS_MODULE, >> }; >> diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c >> index aeeac6de1f0a..0c6b216e439e 100644 >> --- a/fs/nfsd/nfssvc.c >> +++ b/fs/nfsd/nfssvc.c >> @@ -613,7 +613,6 @@ static int nfsd_get_default_max_blksize(void) >> } >> >> static const struct svc_serv_ops nfsd_thread_sv_ops = { >> - .svo_shutdown = nfsd_last_thread, >> .svo_function = nfsd, >> .svo_module = THIS_MODULE, >> }; >> @@ -724,6 +723,7 @@ void nfsd_put(struct net *net) >> >> if (kref_put(&nn->nfsd_serv->sv_refcnt, nfsd_noop)) { >> svc_shutdown_net(nn->nfsd_serv, net); >> + nfsd_last_thread(nn->nfsd_serv, net); >> svc_destroy(&nn->nfsd_serv->sv_refcnt); >> spin_lock(&nfsd_notifier_lock); >> nn->nfsd_serv = NULL; >> diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h >> index 6ef9c1cafd0b..63794d772eb3 100644 >> --- a/include/linux/sunrpc/svc.h >> +++ b/include/linux/sunrpc/svc.h >> @@ -55,9 +55,6 @@ struct svc_pool { >> struct svc_serv; >> >> struct svc_serv_ops { >> - /* Callback to use when last thread exits. */ >> - void (*svo_shutdown)(struct svc_serv *, struct net *); >> - >> /* function for service threads to run */ >> int (*svo_function)(void *); >> >> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c >> index 2aabec2b4bec..74a75a22da9a 100644 >> --- a/net/sunrpc/svc.c >> +++ b/net/sunrpc/svc.c >> @@ -539,9 +539,6 @@ EXPORT_SYMBOL_GPL(svc_create_pooled); >> void svc_shutdown_net(struct svc_serv *serv, struct net *net) >> { >> svc_close_net(serv, net); >> - >> - if (serv->sv_ops->svo_shutdown) >> - serv->sv_ops->svo_shutdown(serv, net); >> } >> EXPORT_SYMBOL_GPL(svc_shutdown_net); > > Could we rename svc_close_net() to svc_shutdown_net() and drop this > function? I considered that, but svc_close_net() seems to be transport-related, whereas svc_shutdown_net() seems to be generic to the NFS server, so I left them separate. A better rationale might push me into merging them. :-) > Either way: > Reviewed-by: NeilBrown <neilb@suse.de> > > Thanks, > NeilBrown -- Chuck Lever
On Wed, 26 Jan 2022, Chuck Lever III wrote: > > > On Jan 25, 2022, at 4:53 PM, NeilBrown <neilb@suse.de> wrote: > > > > > > Could we rename svc_close_net() to svc_shutdown_net() and drop this > > function? > > I considered that, but svc_close_net() seems to be transport-related, > whereas svc_shutdown_net() seems to be generic to the NFS server, so > I left them separate. A better rationale might push me into merging > them. :-) > svc_close_net() is effectively the inverse of svc_create_xprt(), though the later can be called several times, and the former cleans up them all. So maybe rename svc_close_net() to svc_close_xprts() (plural), and call it from the places which currently call svc_close_net(). Those places (nfsd, lockd, nfs/callback) already call svc_create_xprt(). Having them explicitly call svc_close_xprts() to balance that would arguably make the code clearer. Thanks, NeilBrown
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 3a05af873625..f5b688a844aa 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -249,6 +249,7 @@ static int make_socks(struct svc_serv *serv, struct net *net, printk(KERN_WARNING "lockd_up: makesock failed, error=%d\n", err); svc_shutdown_net(serv, net); + svc_rpcb_cleanup(serv, net); return err; } @@ -287,8 +288,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net) cancel_delayed_work_sync(&ln->grace_period_end); locks_end_grace(&ln->lockd_manager); svc_shutdown_net(serv, net); - dprintk("%s: per-net data destroyed; net=%x\n", - __func__, net->ns.inum); + svc_rpcb_cleanup(serv, net); } } else { pr_err("%s: no users! net=%x\n", @@ -351,7 +351,6 @@ static struct notifier_block lockd_inet6addr_notifier = { #endif static const struct svc_serv_ops lockd_sv_ops = { - .svo_shutdown = svc_rpcb_cleanup, .svo_function = lockd, .svo_module = THIS_MODULE, }; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index aeeac6de1f0a..0c6b216e439e 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -613,7 +613,6 @@ static int nfsd_get_default_max_blksize(void) } static const struct svc_serv_ops nfsd_thread_sv_ops = { - .svo_shutdown = nfsd_last_thread, .svo_function = nfsd, .svo_module = THIS_MODULE, }; @@ -724,6 +723,7 @@ void nfsd_put(struct net *net) if (kref_put(&nn->nfsd_serv->sv_refcnt, nfsd_noop)) { svc_shutdown_net(nn->nfsd_serv, net); + nfsd_last_thread(nn->nfsd_serv, net); svc_destroy(&nn->nfsd_serv->sv_refcnt); spin_lock(&nfsd_notifier_lock); nn->nfsd_serv = NULL; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 6ef9c1cafd0b..63794d772eb3 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -55,9 +55,6 @@ struct svc_pool { struct svc_serv; struct svc_serv_ops { - /* Callback to use when last thread exits. */ - void (*svo_shutdown)(struct svc_serv *, struct net *); - /* function for service threads to run */ int (*svo_function)(void *); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 2aabec2b4bec..74a75a22da9a 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -539,9 +539,6 @@ EXPORT_SYMBOL_GPL(svc_create_pooled); void svc_shutdown_net(struct svc_serv *serv, struct net *net) { svc_close_net(serv, net); - - if (serv->sv_ops->svo_shutdown) - serv->sv_ops->svo_shutdown(serv, net); } EXPORT_SYMBOL_GPL(svc_shutdown_net);
Clean up. Neil observed that "any code that calls svc_shutdown_net() knows what the shutdown function should be, and so can call it directly." Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- fs/lockd/svc.c | 5 ++--- fs/nfsd/nfssvc.c | 2 +- include/linux/sunrpc/svc.h | 3 --- net/sunrpc/svc.c | 3 --- 4 files changed, 3 insertions(+), 10 deletions(-)