SUNRPC: Move the svc_rpcb_cleanup() call sites

Clean up: because svc_rpcb_cleanup() and svc_xprt_destroy_all()
are always invoked in pairs, we can deduplicate code by moving
the svc_rpcb_cleanup() call sites into svc_xprt_destroy_all().

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Tested-by: Olga Kornievskaia <okorniev@redhat.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
This commit is contained in:
Chuck Lever 2025-08-20 10:27:28 -04:00 committed by Anna Schumaker
parent c231cea10d
commit 62c0c0e749
7 changed files with 14 additions and 14 deletions

View File

@ -216,8 +216,7 @@ out_err:
if (warned++ == 0) if (warned++ == 0)
printk(KERN_WARNING printk(KERN_WARNING
"lockd_up: makesock failed, error=%d\n", err); "lockd_up: makesock failed, error=%d\n", err);
svc_xprt_destroy_all(serv, net); svc_xprt_destroy_all(serv, net, true);
svc_rpcb_cleanup(serv, net);
return err; return err;
} }
@ -255,8 +254,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net)
nlm_shutdown_hosts_net(net); nlm_shutdown_hosts_net(net);
cancel_delayed_work_sync(&ln->grace_period_end); cancel_delayed_work_sync(&ln->grace_period_end);
locks_end_grace(&ln->lockd_manager); locks_end_grace(&ln->lockd_manager);
svc_xprt_destroy_all(serv, net); svc_xprt_destroy_all(serv, net, true);
svc_rpcb_cleanup(serv, net);
} }
} else { } else {
pr_err("%s: no users! net=%x\n", pr_err("%s: no users! net=%x\n",

View File

@ -136,7 +136,7 @@ static void nfs_callback_down_net(u32 minorversion, struct svc_serv *serv, struc
return; return;
dprintk("NFS: destroy per-net callback data; net=%x\n", net->ns.inum); dprintk("NFS: destroy per-net callback data; net=%x\n", net->ns.inum);
svc_xprt_destroy_all(serv, net); svc_xprt_destroy_all(serv, net, false);
} }
static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,

View File

@ -1993,7 +1993,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info)
* remaining listeners and recreate the list. * remaining listeners and recreate the list.
*/ */
if (delete) if (delete)
svc_xprt_destroy_all(serv, net); svc_xprt_destroy_all(serv, net, false);
/* walk list of addrs again, open any that still don't exist */ /* walk list of addrs again, open any that still don't exist */
nlmsg_for_each_attr_type(attr, NFSD_A_SERVER_SOCK_ADDR, info->nlhdr, nlmsg_for_each_attr_type(attr, NFSD_A_SERVER_SOCK_ADDR, info->nlhdr,

View File

@ -535,16 +535,13 @@ void nfsd_destroy_serv(struct net *net)
#endif #endif
} }
svc_xprt_destroy_all(serv, net);
/* /*
* write_ports can create the server without actually starting * write_ports can create the server without actually starting
* any threads--if we get shut down before any threads are * any threads. If we get shut down before any threads are
* started, then nfsd_destroy_serv will be run before any of this * started, then nfsd_destroy_serv will be run before any of this
* other initialization has been done except the rpcb information. * other initialization has been done except the rpcb information.
*/ */
svc_rpcb_cleanup(serv, net); svc_xprt_destroy_all(serv, net, true);
nfsd_shutdown_net(net); nfsd_shutdown_net(net);
svc_destroy(&serv); svc_destroy(&serv);
} }

View File

@ -165,7 +165,8 @@ int svc_xprt_create(struct svc_serv *serv, const char *xprt_name,
struct net *net, const int family, struct net *net, const int family,
const unsigned short port, int flags, const unsigned short port, int flags,
const struct cred *cred); const struct cred *cred);
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net); void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net,
bool unregister);
void svc_xprt_received(struct svc_xprt *xprt); void svc_xprt_received(struct svc_xprt *xprt);
void svc_xprt_enqueue(struct svc_xprt *xprt); void svc_xprt_enqueue(struct svc_xprt *xprt);
void svc_xprt_put(struct svc_xprt *xprt); void svc_xprt_put(struct svc_xprt *xprt);

View File

@ -436,7 +436,6 @@ void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net)
svc_unregister(serv, net); svc_unregister(serv, net);
rpcb_put_local(net); rpcb_put_local(net);
} }
EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
static int svc_uses_rpcbind(struct svc_serv *serv) static int svc_uses_rpcbind(struct svc_serv *serv)
{ {

View File

@ -1102,6 +1102,7 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)
* svc_xprt_destroy_all - Destroy transports associated with @serv * svc_xprt_destroy_all - Destroy transports associated with @serv
* @serv: RPC service to be shut down * @serv: RPC service to be shut down
* @net: target network namespace * @net: target network namespace
* @unregister: true if it is OK to unregister the destroyed xprts
* *
* Server threads may still be running (especially in the case where the * Server threads may still be running (especially in the case where the
* service is still running in other network namespaces). * service is still running in other network namespaces).
@ -1114,7 +1115,8 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)
* threads, we may need to wait a little while and then check again to * threads, we may need to wait a little while and then check again to
* see if they're done. * see if they're done.
*/ */
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net) void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net,
bool unregister)
{ {
int delay = 0; int delay = 0;
@ -1124,6 +1126,9 @@ void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net)
svc_clean_up_xprts(serv, net); svc_clean_up_xprts(serv, net);
msleep(delay++); msleep(delay++);
} }
if (unregister)
svc_rpcb_cleanup(serv, net);
} }
EXPORT_SYMBOL_GPL(svc_xprt_destroy_all); EXPORT_SYMBOL_GPL(svc_xprt_destroy_all);