svc_bind() creates the local rpcbind client, and svc_register() then makes one synchronous call for each program and version. Both run under the caller's mutex. A caller that registers from userland needs neither.
Add sv_no_rpcbind to struct svc_serv, and fix up the code to honor it. No caller sets the flag yet, so behaviour does not change. Assisted-by: LLM Signed-off-by: Jeff Layton <[email protected]> --- include/linux/sunrpc/svc.h | 2 ++ net/sunrpc/svc.c | 5 +++++ net/sunrpc/svc_xprt.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 5fa9417e034d..7f09db6a360c 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -87,6 +87,8 @@ struct svc_serv { char * sv_name; /* service name */ bool sv_is_pooled; /* is this a pooled service? */ + /* Caller registers with rpcbind itself. Set before svc_bind(). */ + bool sv_no_rpcbind; struct svc_pool * sv_pools; /* array of thread pools */ int (*sv_threadfn)(void *data); diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index f73412e123a1..7e23af94a719 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -337,6 +337,8 @@ static int svc_uses_rpcbind(struct svc_serv *serv) int svc_bind(struct svc_serv *serv, struct net *net) { + if (serv->sv_no_rpcbind) + return 0; if (!svc_uses_rpcbind(serv)) return 0; return svc_rpcb_setup(serv, net); @@ -1235,6 +1237,9 @@ int svc_register(struct svc_serv *serv, struct net *net, if (proto == 0 && port == 0) return -EINVAL; + if (serv->sv_no_rpcbind) + return 0; + for (p = 0; p < serv->sv_nprogs; p++) { struct svc_program *progp = &serv->sv_programs[p]; diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index d5634dd6d6cc..1a2c87e4d951 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -1266,7 +1266,7 @@ void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net, msleep(delay++); } - if (unregister) + if (unregister && !serv->sv_no_rpcbind) svc_rpcb_cleanup(serv, net); } EXPORT_SYMBOL_GPL(svc_xprt_destroy_all); -- 2.55.0

