Commit 7960aa9e authored by Olga Kornievskaia's avatar Olga Kornievskaia Committed by Trond Myklebust

SUNRPC restructure rpc_clnt_setup_test_and_add_xprt

In preparation for code re-use, pull out the part of the
rpc_clnt_setup_test_and_add_xprt() portion that sends a NULL rpc
and then calls a session trunking function into a helper function.

Re-organize the end of the function for code re-use.
Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent e818bd08
...@@ -2874,6 +2874,30 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt, ...@@ -2874,6 +2874,30 @@ int rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
} }
EXPORT_SYMBOL_GPL(rpc_clnt_test_and_add_xprt); EXPORT_SYMBOL_GPL(rpc_clnt_test_and_add_xprt);
static int rpc_clnt_add_xprt_helper(struct rpc_clnt *clnt,
struct rpc_xprt *xprt,
struct rpc_add_xprt_test *data)
{
struct rpc_task *task;
int status = -EADDRINUSE;
/* Test the connection */
task = rpc_call_null_helper(clnt, xprt, NULL, 0, NULL, NULL);
if (IS_ERR(task))
return PTR_ERR(task);
status = task->tk_status;
rpc_put_task(task);
if (status < 0)
return status;
/* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */
data->add_xprt_test(clnt, xprt, data->data);
return 0;
}
/** /**
* rpc_clnt_setup_test_and_add_xprt() * rpc_clnt_setup_test_and_add_xprt()
* *
...@@ -2897,8 +2921,6 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, ...@@ -2897,8 +2921,6 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt,
struct rpc_xprt *xprt, struct rpc_xprt *xprt,
void *data) void *data)
{ {
struct rpc_task *task;
struct rpc_add_xprt_test *xtest = (struct rpc_add_xprt_test *)data;
int status = -EADDRINUSE; int status = -EADDRINUSE;
xprt = xprt_get(xprt); xprt = xprt_get(xprt);
...@@ -2907,31 +2929,19 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt, ...@@ -2907,31 +2929,19 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt,
if (rpc_xprt_switch_has_addr(xps, (struct sockaddr *)&xprt->addr)) if (rpc_xprt_switch_has_addr(xps, (struct sockaddr *)&xprt->addr))
goto out_err; goto out_err;
/* Test the connection */ status = rpc_clnt_add_xprt_helper(clnt, xprt, data);
task = rpc_call_null_helper(clnt, xprt, NULL, 0, NULL, NULL);
if (IS_ERR(task)) {
status = PTR_ERR(task);
goto out_err;
}
status = task->tk_status;
rpc_put_task(task);
if (status < 0) if (status < 0)
goto out_err; goto out_err;
/* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */ status = 1;
xtest->add_xprt_test(clnt, xprt, xtest->data);
xprt_put(xprt);
xprt_switch_put(xps);
/* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */
return 1;
out_err: out_err:
xprt_put(xprt); xprt_put(xprt);
xprt_switch_put(xps); xprt_switch_put(xps);
pr_info("RPC: rpc_clnt_test_xprt failed: %d addr %s not added\n", if (status < 0)
status, xprt->address_strings[RPC_DISPLAY_ADDR]); pr_info("RPC: rpc_clnt_test_xprt failed: %d addr %s not "
"added\n", status,
xprt->address_strings[RPC_DISPLAY_ADDR]);
/* so that rpc_clnt_add_xprt does not call rpc_xprt_switch_add_xprt */
return status; return status;
} }
EXPORT_SYMBOL_GPL(rpc_clnt_setup_test_and_add_xprt); EXPORT_SYMBOL_GPL(rpc_clnt_setup_test_and_add_xprt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment