Skip to content

Commit d73d06d

Browse files
committed
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(). Tested-by: Olga Kornievskaia <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent dd9adfa commit d73d06d

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

fs/lockd/svc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ static int make_socks(struct svc_serv *serv, struct net *net,
216216
if (warned++ == 0)
217217
printk(KERN_WARNING
218218
"lockd_up: makesock failed, error=%d\n", err);
219-
svc_xprt_destroy_all(serv, net);
220-
svc_rpcb_cleanup(serv, net);
219+
svc_xprt_destroy_all(serv, net, true);
221220
return err;
222221
}
223222

@@ -255,8 +254,7 @@ static void lockd_down_net(struct svc_serv *serv, struct net *net)
255254
nlm_shutdown_hosts_net(net);
256255
cancel_delayed_work_sync(&ln->grace_period_end);
257256
locks_end_grace(&ln->lockd_manager);
258-
svc_xprt_destroy_all(serv, net);
259-
svc_rpcb_cleanup(serv, net);
257+
svc_xprt_destroy_all(serv, net, true);
260258
}
261259
} else {
262260
pr_err("%s: no users! net=%x\n",

fs/nfs/callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static void nfs_callback_down_net(u32 minorversion, struct svc_serv *serv, struc
136136
return;
137137

138138
dprintk("NFS: destroy per-net callback data; net=%x\n", net->ns.inum);
139-
svc_xprt_destroy_all(serv, net);
139+
svc_xprt_destroy_all(serv, net, false);
140140
}
141141

142142
static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,

fs/nfsd/nfsctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ int nfsd_nl_listener_set_doit(struct sk_buff *skb, struct genl_info *info)
19931993
* remaining listeners and recreate the list.
19941994
*/
19951995
if (delete)
1996-
svc_xprt_destroy_all(serv, net);
1996+
svc_xprt_destroy_all(serv, net, false);
19971997

19981998
/* walk list of addrs again, open any that still don't exist */
19991999
nlmsg_for_each_attr_type(attr, NFSD_A_SERVER_SOCK_ADDR, info->nlhdr,

fs/nfsd/nfssvc.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,16 +535,13 @@ void nfsd_destroy_serv(struct net *net)
535535
#endif
536536
}
537537

538-
svc_xprt_destroy_all(serv, net);
539-
540538
/*
541539
* write_ports can create the server without actually starting
542-
* any threads--if we get shut down before any threads are
540+
* any threads. If we get shut down before any threads are
543541
* started, then nfsd_destroy_serv will be run before any of this
544542
* other initialization has been done except the rpcb information.
545543
*/
546-
svc_rpcb_cleanup(serv, net);
547-
544+
svc_xprt_destroy_all(serv, net, true);
548545
nfsd_shutdown_net(net);
549546
svc_destroy(&serv);
550547
}

include/linux/sunrpc/svc_xprt.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ int svc_xprt_create(struct svc_serv *serv, const char *xprt_name,
168168
struct net *net, const int family,
169169
const unsigned short port, int flags,
170170
const struct cred *cred);
171-
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net);
171+
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net,
172+
bool unregister);
172173
void svc_xprt_received(struct svc_xprt *xprt);
173174
void svc_xprt_enqueue(struct svc_xprt *xprt);
174175
void svc_xprt_put(struct svc_xprt *xprt);

net/sunrpc/svc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,6 @@ void svc_rpcb_cleanup(struct svc_serv *serv, struct net *net)
436436
svc_unregister(serv, net);
437437
rpcb_put_local(net);
438438
}
439-
EXPORT_SYMBOL_GPL(svc_rpcb_cleanup);
440439

441440
static int svc_uses_rpcbind(struct svc_serv *serv)
442441
{

net/sunrpc/svc_xprt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,7 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)
11151115
* svc_xprt_destroy_all - Destroy transports associated with @serv
11161116
* @serv: RPC service to be shut down
11171117
* @net: target network namespace
1118+
* @unregister: true if it is OK to unregister the destroyed xprts
11181119
*
11191120
* Server threads may still be running (especially in the case where the
11201121
* service is still running in other network namespaces).
@@ -1127,7 +1128,8 @@ static void svc_clean_up_xprts(struct svc_serv *serv, struct net *net)
11271128
* threads, we may need to wait a little while and then check again to
11281129
* see if they're done.
11291130
*/
1130-
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net)
1131+
void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net,
1132+
bool unregister)
11311133
{
11321134
int delay = 0;
11331135

@@ -1137,6 +1139,9 @@ void svc_xprt_destroy_all(struct svc_serv *serv, struct net *net)
11371139
svc_clean_up_xprts(serv, net);
11381140
msleep(delay++);
11391141
}
1142+
1143+
if (unregister)
1144+
svc_rpcb_cleanup(serv, net);
11401145
}
11411146
EXPORT_SYMBOL_GPL(svc_xprt_destroy_all);
11421147

0 commit comments

Comments
 (0)