Skip to content

Commit 15001e5

Browse files
committed
SUNRPC: Make NFS swap work with multipath
Signed-off-by: Trond Myklebust <[email protected]>
1 parent 3227886 commit 15001e5

File tree

1 file changed

+24
-42
lines changed

1 file changed

+24
-42
lines changed

net/sunrpc/clnt.c

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,57 +2554,39 @@ void rpc_show_tasks(struct net *net)
25542554
#endif
25552555

25562556
#if IS_ENABLED(CONFIG_SUNRPC_SWAP)
2557+
static int
2558+
rpc_clnt_swap_activate_callback(struct rpc_clnt *clnt,
2559+
struct rpc_xprt *xprt,
2560+
void *dummy)
2561+
{
2562+
return xprt_enable_swap(xprt);
2563+
}
2564+
25572565
int
25582566
rpc_clnt_swap_activate(struct rpc_clnt *clnt)
25592567
{
2560-
int ret = 0;
2561-
struct rpc_xprt *xprt;
2562-
2563-
if (atomic_inc_return(&clnt->cl_swapper) == 1) {
2564-
retry:
2565-
rcu_read_lock();
2566-
xprt = xprt_get(rcu_dereference(clnt->cl_xprt));
2567-
rcu_read_unlock();
2568-
if (!xprt) {
2569-
/*
2570-
* If we didn't get a reference, then we likely are
2571-
* racing with a migration event. Wait for a grace
2572-
* period and try again.
2573-
*/
2574-
synchronize_rcu();
2575-
goto retry;
2576-
}
2577-
2578-
ret = xprt_enable_swap(xprt);
2579-
xprt_put(xprt);
2580-
}
2581-
return ret;
2568+
if (atomic_inc_return(&clnt->cl_swapper) == 1)
2569+
return rpc_clnt_iterate_for_each_xprt(clnt,
2570+
rpc_clnt_swap_activate_callback, NULL);
2571+
return 0;
25822572
}
25832573
EXPORT_SYMBOL_GPL(rpc_clnt_swap_activate);
25842574

2575+
static int
2576+
rpc_clnt_swap_deactivate_callback(struct rpc_clnt *clnt,
2577+
struct rpc_xprt *xprt,
2578+
void *dummy)
2579+
{
2580+
xprt_disable_swap(xprt);
2581+
return 0;
2582+
}
2583+
25852584
void
25862585
rpc_clnt_swap_deactivate(struct rpc_clnt *clnt)
25872586
{
2588-
struct rpc_xprt *xprt;
2589-
2590-
if (atomic_dec_if_positive(&clnt->cl_swapper) == 0) {
2591-
retry:
2592-
rcu_read_lock();
2593-
xprt = xprt_get(rcu_dereference(clnt->cl_xprt));
2594-
rcu_read_unlock();
2595-
if (!xprt) {
2596-
/*
2597-
* If we didn't get a reference, then we likely are
2598-
* racing with a migration event. Wait for a grace
2599-
* period and try again.
2600-
*/
2601-
synchronize_rcu();
2602-
goto retry;
2603-
}
2604-
2605-
xprt_disable_swap(xprt);
2606-
xprt_put(xprt);
2607-
}
2587+
if (atomic_dec_if_positive(&clnt->cl_swapper) == 0)
2588+
rpc_clnt_iterate_for_each_xprt(clnt,
2589+
rpc_clnt_swap_deactivate_callback, NULL);
26082590
}
26092591
EXPORT_SYMBOL_GPL(rpc_clnt_swap_deactivate);
26102592
#endif /* CONFIG_SUNRPC_SWAP */

0 commit comments

Comments
 (0)