From: Santosh Kumar Pradhan <santoshkumar.pradhan@xxxxxxx> Multipathing: In case of NFSv3, rpc_clnt_test_and_add_xprt() adds the xprt to xprt switch (i.e. xps) if rpc_call_null_helper() returns success. But in case of NFSv4.1, it needs to do EXCHANGEID to verify the path along with check for session trunking. Add the xprt once nfs4_test_session_trunk() returns success. Also release refcount hold by rpc_clnt_setup_test_and_add_xprt(). Signed-off-by: Santosh Kumar Pradhan <santoshkumar.pradhan@xxxxxxx> Tested-by: Suresh Jayaraman <suresh.jayaraman@xxxxxxx> --- net/sunrpc/clnt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index d839c33ae7d9..053f594cc144 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2654,10 +2654,14 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, goto out_err; /* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */ - xtest->add_xprt_test(clnt, xprt, xtest->data); + status = xtest->add_xprt_test(clnt, xprt, xtest->data); + if (status != 0) + goto out_err; - /* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */ - return 1; + xprt_put(xprt); + xprt_switch_put(xps); + /* so that rpc_clnt_add_xprt calls rpc_xprt_switch_add_xprt */ + return 0; out_err: xprt_put(xprt); xprt_switch_put(xps); -- 2.17.1