Skip to content

Commit

Permalink
sunrpc: Add xprt after nfs4_test_session_trunk()
Browse files Browse the repository at this point in the history
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 in nfs4_test_session_trunk() only when
nfs4_detect_session_trunking() returns success. Also release refcount
hold by rpc_clnt_setup_test_and_add_xprt().

Signed-off-by: Santosh kumar pradhan <[email protected]>
Tested-by: Suresh Jayaraman <[email protected]>
Reported-by: Aditya Agnihotri <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
Santosh kumar pradhan authored and amschuma-ntap committed Jan 2, 2019
1 parent cb24e35 commit 10e037d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
6 changes: 3 additions & 3 deletions fs/nfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ extern int nfs40_walk_client_list(struct nfs_client *clp,
extern int nfs41_walk_client_list(struct nfs_client *clp,
struct nfs_client **result,
const struct cred *cred);
extern int nfs4_test_session_trunk(struct rpc_clnt *,
struct rpc_xprt *,
void *);
extern void nfs4_test_session_trunk(struct rpc_clnt *clnt,
struct rpc_xprt *xprt,
void *data);

static inline struct inode *nfs_igrab_and_active(struct inode *inode)
{
Expand Down
3 changes: 2 additions & 1 deletion fs/nfs/nfs4_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ struct nfs4_minor_version_ops {
nfs4_stateid *, const struct cred *);
struct nfs_seqid *
(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *);
void (*session_trunk)(struct rpc_clnt *clnt,
struct rpc_xprt *xprt, void *data);
const struct rpc_call_ops *call_sync_ops;
const struct nfs4_state_recovery_ops *reboot_recovery_ops;
const struct nfs4_state_recovery_ops *nograce_recovery_ops;
Expand Down
8 changes: 5 additions & 3 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8082,7 +8082,7 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, const struct cred *cred)
* @xprt: the rpc_xprt to test
* @data: call data for _nfs4_proc_exchange_id.
*/
int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
void nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
void *data)
{
struct nfs4_add_xprt_data *adata = (struct nfs4_add_xprt_data *)data;
Expand All @@ -8099,15 +8099,17 @@ int nfs4_test_session_trunk(struct rpc_clnt *clnt, struct rpc_xprt *xprt,
/* Test connection for session trunking. Async exchange_id call */
task = nfs4_run_exchange_id(adata->clp, adata->cred, sp4_how, xprt);
if (IS_ERR(task))
return PTR_ERR(task);
return;

status = task->tk_status;
if (status == 0)
status = nfs4_detect_session_trunking(adata->clp,
task->tk_msg.rpc_resp, xprt);

if (status == 0)
rpc_clnt_xprt_switch_add_xprt(clnt, xprt);

rpc_put_task(task);
return status;
}
EXPORT_SYMBOL_GPL(nfs4_test_session_trunk);

Expand Down
4 changes: 2 additions & 2 deletions include/linux/sunrpc/clnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ struct rpc_create_args {
};

struct rpc_add_xprt_test {
int (*add_xprt_test)(struct rpc_clnt *,
struct rpc_xprt *,
void (*add_xprt_test)(struct rpc_clnt *clnt,
struct rpc_xprt *xprt,
void *calldata);
void *data;
};
Expand Down
3 changes: 3 additions & 0 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2661,6 +2661,9 @@ int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *clnt,
/* rpc_xprt_switch and rpc_xprt are deferrenced by add_xprt_test() */
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:
Expand Down

0 comments on commit 10e037d

Please sign in to comment.