pNFS file layout session trunking
Subsystems (3)
cover pNFS file layout session trunking
From: Andy Adamson <[email protected]>
RESEND: added put_rpccred to to _nfs4_pnfs_v4_ds_connect in "NFS pnfs data server multipath session trunking"
Responded to Version-8 comments
- renamed rpc_clnt_xprt_switch_find_addr
- spelling nits
- moved rpc_cnt_xprt_switch_add_xprt into
nfs4_detect_session_trunking
*** BLURB HERE ***
Andy Adamson (12):
NFS setup async exchange_id
NFS refactor nfs4_match_clientids
NFS refactor nfs4_check_serverowner_major_id
NFS detect session trunking
SUNRPC remove rpc_task_release_client from rpc_task_set_client SUNRPC rpc_clnt_xprt_switch_put
SUNRPC rpc_clnt_xprt_switch_add_xprt
SUNRPC search xprt switch for sockaddr
SUNRPC: rpc_clnt_add_xprt setup function for NFS layer NFS add xprt switch addrs test to match client
NFS test session trunking with exchange id
NFS pnfs data server multipath session trunking
fs/nfs/client.c | 5 +- fs/nfs/internal.h | 3 + fs/nfs/nfs4_fs.h | 8 + fs/nfs/nfs4client.c | 117 ++++++++++++-- fs/nfs/nfs4proc.c | 287 ++++++++++++++++++++++++----------- fs/nfs/pnfs_nfs.c | 58 +++++-- include/linux/sunrpc/clnt.h | 17 +++ include/linux/sunrpc/xprtmultipath.h | 2 + net/sunrpc/clnt.c | 93 +++++++++++- net/sunrpc/xprtmultipath.c | 24 ++- 10 files changed, 500 insertions(+), 114 deletions(-)
Signature · 1 line
1.8.3.1
PATCH RESEND 1/12 NFS setup async exchange_id
From: Andy Adamson <[email protected]>
Testing an rpc_xprt for session trunking should not delay application progress over already established transports.
Setup exchange_id to be able to be an async call to test an rpc_xprt for session trunking use.
--- fs/nfs/nfs4proc.c | 215 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 134 insertions(+), 81 deletions(-)
fs/nfs/nfs4proc.c +134 -81
@@ -7051,6 +7051,80 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp,return 0 ; } +struct nfs41_exchange_id_data { +struct nfs41_exchange_id_res res; +struct nfs41_exchange_id_args args; +int rpc_status; +}; + +static void nfs4_exchange_id_done (struct rpc_task *task,void *data) +{ +struct nfs41_exchange_id_data *cdata = + (struct nfs41_exchange_id_data *)data; +struct nfs_client *clp = cdata->args.client; +int status = task->tk_status; + +trace_nfs4_exchange_id (clp, status); + +if (status ==0 ) + status =nfs4_check_cl_exchange_flags (cdata->res.flags); +if (status ==0 ) + status =nfs4_sp4_select_mode (clp, &cdata->res.state_protect); + +if (status ==0 ) { + clp->cl_clientid = cdata->res.clientid; + clp->cl_exchange_flags = cdata->res.flags; +/* Client ID is not confirmed */ +if (!(cdata->res.flags &EXCHGID4_FLAG_CONFIRMED_R )) { +clear_bit (NFS4_SESSION_ESTABLISHED , + &clp->cl_session->session_state); + clp->cl_seqid = cdata->res.seqid; + } + +kfree (clp->cl_serverowner); + clp->cl_serverowner = cdata->res.server_owner; + cdata->res.server_owner =NULL ; + +/* use the most recent implementation id */ +kfree (clp->cl_implid); + clp->cl_implid = cdata->res.impl_id; + cdata->res.impl_id =NULL ; + +if (clp->cl_serverscope !=NULL && + !nfs41_same_server_scope (clp->cl_serverscope, + cdata->res.server_scope)) { +dprintk ("%s: server_scope mismatch detected\n" , + __func__); +set_bit (NFS4CLNT_SERVER_SCOPE_MISMATCH , &clp->cl_state); +kfree (clp->cl_serverscope); + clp->cl_serverscope =NULL ; + } + +if (clp->cl_serverscope ==NULL ) { + clp->cl_serverscope = cdata->res.server_scope; + cdata->res.server_scope =NULL ; + } + } + cdata->rpc_status = status; +} + +static void nfs4_exchange_id_release (void *data) +{ +struct nfs41_exchange_id_data *cdata = + (struct nfs41_exchange_id_data *)data; + +nfs_put_client (cdata->args.client); +kfree (cdata->res.impl_id); +kfree (cdata->res.server_scope); +kfree (cdata->res.server_owner); +kfree (cdata); +} + +static const struct rpc_call_ops nfs4_exchange_id_call_ops = { + .rpc_call_done = nfs4_exchange_id_done, + .rpc_release = nfs4_exchange_id_release, +}; +/* * _nfs4_proc_exchange_id() *
@@ -7060,66 +7134,60 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, u32 sp4_how) {nfs4_verifier verifier; -struct nfs41_exchange_id_args args = { - .verifier = &verifier, - .client = clp, -#ifdef CONFIG_NFS_V4_1_MIGRATION - .flags =EXCHGID4_FLAG_SUPP_MOVED_REFER | -EXCHGID4_FLAG_BIND_PRINC_STATEID | -EXCHGID4_FLAG_SUPP_MOVED_MIGR , -#else - .flags =EXCHGID4_FLAG_SUPP_MOVED_REFER | -EXCHGID4_FLAG_BIND_PRINC_STATEID , -#endif - }; -struct nfs41_exchange_id_res res = { -0 - }; -int status;struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_EXCHANGE_ID ], - .rpc_argp = &args, - .rpc_resp = &res, .rpc_cred = cred, }; +struct rpc_task_setup task_setup_data = { + .rpc_client = clp->cl_rpcclient, + .callback_ops = &nfs4_exchange_id_call_ops, + .rpc_message = &msg, + .flags =RPC_TASK_ASYNC |RPC_TASK_TIMEOUT , + }; +struct nfs41_exchange_id_data *calldata; +struct rpc_task *task; +int status = -EIO ; + +if (!atomic_inc_not_zero (&clp->cl_count)) + goto out; + + status = -ENOMEM ; + calldata =kzalloc (sizeof (*calldata),GFP_NOFS ); +if (!calldata) + goto out;nfs4_init_boot_verifier (clp, &verifier); status =nfs4_init_uniform_client_string (clp);if (status) - goto out; + goto out_calldata;dprintk ("NFS call exchange_id auth=%s, '%s'\n" , clp->cl_rpcclient->cl_auth->au_ops->au_name, clp->cl_owner_id); - res.server_owner =kzalloc (sizeof (struct nfs41_server_owner ), -GFP_NOFS ); -if (unlikely (res.server_owner ==NULL )) { - status = -ENOMEM ; - goto out; - } + calldata->res.server_owner =kzalloc (sizeof (struct nfs41_server_owner ), +GFP_NOFS ); + status = -ENOMEM ; +if (unlikely (calldata->res.server_owner ==NULL )) + goto out_calldata; - res.server_scope =kzalloc (sizeof (struct nfs41_server_scope ), + calldata->res.server_scope =kzalloc (sizeof (struct nfs41_server_scope ),GFP_NOFS ); -if (unlikely (res.server_scope ==NULL )) { - status = -ENOMEM ; +if (unlikely (calldata->res.server_scope ==NULL )) goto out_server_owner; - } - res.impl_id =kzalloc (sizeof (struct nfs41_impl_id ),GFP_NOFS ); -if (unlikely (res.impl_id ==NULL )) { - status = -ENOMEM ; + calldata->res.impl_id =kzalloc (sizeof (struct nfs41_impl_id ),GFP_NOFS ); +if (unlikely (calldata->res.impl_id ==NULL )) goto out_server_scope; - }switch (sp4_how) {case SP4_NONE : - args.state_protect.how =SP4_NONE ; + calldata->args.state_protect.how =SP4_NONE ;break ;case SP4_MACH_CRED : - args.state_protect = nfs4_sp4_mach_cred_request; + calldata->args.state_protect = nfs4_sp4_mach_cred_request;break ;default :
@@ -7129,55 +7197,30 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, goto out_impl_id; } - status =rpc_call_sync (clp->cl_rpcclient, &msg,RPC_TASK_TIMEOUT ); -trace_nfs4_exchange_id (clp, status); -if (status ==0 ) - status =nfs4_check_cl_exchange_flags (res.flags); - -if (status ==0 ) - status =nfs4_sp4_select_mode (clp, &res.state_protect); - -if (status ==0 ) { - clp->cl_clientid = res.clientid; - clp->cl_exchange_flags = res.flags; -/* Client ID is not confirmed */ -if (!(res.flags &EXCHGID4_FLAG_CONFIRMED_R )) { -clear_bit (NFS4_SESSION_ESTABLISHED , - &clp->cl_session->session_state); - clp->cl_seqid = res.seqid; - } - -kfree (clp->cl_serverowner); - clp->cl_serverowner = res.server_owner; - res.server_owner =NULL ; - -/* use the most recent implementation id */ -kfree (clp->cl_implid); - clp->cl_implid = res.impl_id; - res.impl_id =NULL ; - -if (clp->cl_serverscope !=NULL && - !nfs41_same_server_scope (clp->cl_serverscope, - res.server_scope)) { -dprintk ("%s: server_scope mismatch detected\n" , - __func__); -set_bit (NFS4CLNT_SERVER_SCOPE_MISMATCH , &clp->cl_state); -kfree (clp->cl_serverscope); - clp->cl_serverscope =NULL ; - } + calldata->args.verifier = &verifier; + calldata->args.client = clp; +#ifdef CONFIG_NFS_V4_1_MIGRATION + calldata->args.flags =EXCHGID4_FLAG_SUPP_MOVED_REFER | +EXCHGID4_FLAG_BIND_PRINC_STATEID | +EXCHGID4_FLAG_SUPP_MOVED_MIGR , +#else + calldata->args.flags =EXCHGID4_FLAG_SUPP_MOVED_REFER | +EXCHGID4_FLAG_BIND_PRINC_STATEID , +#endif + msg.rpc_argp = &calldata->args; + msg.rpc_resp = &calldata->res; + task_setup_data.callback_data = calldata; -if (clp->cl_serverscope ==NULL ) { - clp->cl_serverscope = res.server_scope; - res.server_scope =NULL ; - } + task =rpc_run_task (&task_setup_data); +if (IS_ERR (task)) { + status =PTR_ERR (task); + goto out_impl_id; } -out_impl_id: -kfree (res.impl_id); -out_server_scope: -kfree (res.server_scope); -out_server_owner: -kfree (res.server_owner); + status =rpc_wait_for_completion_task (task); +if (!status) + status = calldata->rpc_status; +rpc_put_task (task); out:if (clp->cl_implid !=NULL ) dprintk("NFS reply exchange_id: Server Implementation ID: "
@@ -7187,6 +7230,16 @@ out: clp->cl_implid->date.nseconds);dprintk ("NFS reply exchange_id: %d\n" , status);return status; + +out_impl_id: +kfree (calldata->res.impl_id); +out_server_scope: +kfree (calldata->res.server_scope); +out_server_owner: +kfree (calldata->res.server_owner); +out_calldata: +kfree (calldata); + goto out; }/*
Signature · 1 line
1.8.3.1
PATCH RESEND 2/12 NFS refactor nfs4_match_clientids
In reply to [email protected]From: Andy Adamson <[email protected]>
For session trunking, to compare nfs41_exchange_id_res with exiting nfs_client.
--- fs/nfs/nfs4client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/nfs/nfs4client.c +5 -5
@@ -562,15 +562,15 @@ out:/* * Returns true if the client IDs match */ -static bool nfs4_match_clientids (struct nfs_client *a,struct nfs_client *b) +static bool nfs4_match_clientids (u64 a,u64 b) { -if (a->cl_clientid != b->cl_clientid) { +if (a != b) {dprintk ("NFS: --> %s client ID %llx does not match %llx\n" , - __func__, a->cl_clientid, b->cl_clientid); + __func__, a, b);return false; }dprintk ("NFS: --> %s client ID %llx matches %llx\n" , - __func__, a->cl_clientid, b->cl_clientid); + __func__, a, b);return true; }
@@ -650,7 +650,7 @@ int nfs41_walk_client_list(struct nfs_client *new,if (pos->cl_cons_state !=NFS_CS_READY )continue ; -if (!nfs4_match_clientids (pos, new)) +if (!nfs4_match_clientids (pos->cl_clientid, new->cl_clientid))continue ;/*
Signature · 1 line
1.8.3.1
PATCH RESEND 3/12 NFS refactor nfs4_check_serverowner_major_id
In reply to [email protected]From: Andy Adamson <[email protected]>
For session trunking, to compare nfs41_exchange_id_res with existing nfs_client
--- fs/nfs/nfs4client.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
fs/nfs/nfs4client.c +5 -6
@@ -578,17 +578,15 @@ static bool nfs4_match_clientids(u64 a, u64 b)* Returns true if the server major ids match */ static bool -nfs4_check_clientid_trunking (struct nfs_client *a,struct nfs_client *b) +nfs4_check_serverowner_major_id (struct nfs41_server_owner *o1, +struct nfs41_server_owner *o2) { -struct nfs41_server_owner *o1 = a->cl_serverowner; -struct nfs41_server_owner *o2 = b->cl_serverowner; -if (o1->major_id_sz != o2->major_id_sz) goto out_major_mismatch;if (memcmp (o1->major_id, o2->major_id, o1->major_id_sz) !=0 ) goto out_major_mismatch; -dprintk ("NFS: --> %s server owners match\n" , __func__); +dprintk ("NFS: --> %s server owner major IDs match\n" , __func__);return true; out_major_mismatch:
@@ -658,7 +656,8 @@ int nfs41_walk_client_list(struct nfs_client *new,* client id trunking. In either case, we want to fall back * to using the existing nfs_client. */ -if (!nfs4_check_clientid_trunking (pos, new)) +if (!nfs4_check_serverowner_major_id (pos->cl_serverowner, + new->cl_serverowner))continue ;/* Unlike NFSv4.0, we know that NFSv4.1 always uses the
Signature · 1 line
1.8.3.1
PATCH RESEND 4/12 NFS detect session trunking
In reply to [email protected]From: Andy Adamson <[email protected]>
--- fs/nfs/nfs4_fs.h | 2 ++ fs/nfs/nfs4client.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)
fs/nfs/nfs4_fs.h +2 -0
@@ -277,6 +277,8 @@ extern int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo);extern int nfs4_proc_layoutcommit (struct nfs4_layoutcommit_data *data,bool sync); +extern int nfs4_detect_session_trunking (struct nfs_client *clp, +struct nfs41_exchange_id_res *res,struct rpc_xprt *xprt);static inline bool is_ds_only_client (struct nfs_client *clp)
fs/nfs/nfs4client.c +93 -0
99 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH Version 9 RESEND 04/12] NFS detect session trunking
Hi Andy,
Quoted 108 lines · On 09/01/2016 11:44 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4_fs.h | 2 ++ fs/nfs/nfs4client.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+)fs/nfs/nfs4_fs.h +2
-0@@ -277,6 +277,8 @@ extern int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo);extern int nfs4_proc_layoutcommit (struct nfs4_layoutcommit_data *data,bool sync); +extern int nfs4_detect_session_trunking (struct nfs_client *clp, +struct nfs41_exchange_id_res *res,struct rpc_xprt *xprt);static inline bool is_ds_only_client (struct nfs_client *clp)fs/nfs/nfs4client.c +79
-0@@ -595,6 +595,99 @@ out_major_mismatch:return false; } +/* +* Returns true if server minor ids match +*/ +static bool +nfs4_check_serverowner_minor_id (struct nfs41_server_owner *o1, +struct nfs41_server_owner *o2) +{ +/* Check eir_server_owner so_minor_id */ +if (o1->minor_id != o2->minor_id) + goto out_minor_mismatch; + +dprintk ("NFS: --> %s server owner minor IDs match\n" , __func__); +return true; + +out_minor_mismatch: +dprintk ("NFS: --> %s server owner minor IDs do not match\n" , __func__); +return false; +} + +/* +* Returns true if the server scopes match +*/ +static bool +nfs4_check_server_scope (struct nfs41_server_scope *s1, +struct nfs41_server_scope *s2) +{ +if (s1->server_scope_sz != s2->server_scope_sz) + goto out_scope_mismatch; +if (memcmp (s1->server_scope, s2->server_scope, + s1->server_scope_sz) !=0 ) + goto out_scope_mismatch; + +dprintk ("NFS: --> %s server scopes match\n" , __func__); +return true; + +out_scope_mismatch: +dprintk ("NFS: --> %s server scopes do not match\n" , + __func__); +return false; +} + +/** +* nfs4_detect_session_trunking - Checks for session trunking called +* after a successful EXCHANGE_ID testing a multi-addr connection to be +* potentially added as a session trunk +* +* @clp: original mount nfs_client +* @res: result structure from an exchange_id using the original mount +* nfs_client with a new multi_addr transport +* +* Returns zero on success, otherwise -EINVAL +* +* Note: since the exchange_id for the new multi_addr transport uses the +* same nfs_client from the original mount, the cl_owner_id is reused, +* so eir_clientowner is the same. +*/ +int nfs4_detect_session_trunking (struct nfs_client *clp, +struct nfs41_exchange_id_res *res, +struct rpc_xprt *xprt) +{ +int status = -EINVAL ; +/* Check eir_clientid */ +if (!nfs4_match_clientids (clp->cl_clientid, res->clientid)) + goto out; + +/* Check eir_server_owner so_major_id */ +if (!nfs4_check_serverowner_major_id (clp->cl_serverowner, + res->server_owner)) + goto out; + +/* Check eir_server_owner so_minor_id */ +if (!nfs4_check_serverowner_minor_id (clp->cl_serverowner, + res->server_owner)) + goto out; + +/* Check eir_server_scope */ +if (!nfs4_check_server_scope (clp->cl_serverscope, res->server_scope)) + goto out; +
fs/nfs/nfs4client.c out_major_mismatch: · line 686
Quoted 10 lines
fs/nfs/nfs4client.c +10
-0+ status =0 ; +out: +if (status) +pr_info ("NFS: %s: Session trunking failed for %s status %d\n" , + clp->cl_hostname, + xprt->address_strings[RPC_DISPLAY_ADDR ], status); +else +pr_info ("NFS: %s: Session trunking succeeded for %s\n" , + clp->cl_hostname, + xprt->address_strings[RPC_DISPLAY_ADDR ]);
I'm not a fan of the if/else status check here. I think it might be cleaner if you match the style of nfs4_check_server_scope() and create an out_err label that prints the failed message and returns -EINVAL directly. Then you can get rid of the "status" variable all together and avoid the if/else check at the end.
Thanks,
Anna
Quoted 8 lines
fs/nfs/nfs4client.c +4
-0+ +return status; +} +/** * nfs41_walk_client_list - Find nfs_client that matches a client/server owner *
PATCH RESEND 5/12 SUNRPC remove rpc_task_release_client from rpc_task_set_client
In reply to [email protected]From: Andy Adamson <[email protected]>
rpc_task_set_client is only called from rpc_run_task after rpc_new_task and rpc_task_release_client is not needed as the task is new.
When called from rpc_new_task, rpc_task_set_client also removed the assigned rpc_xprt which is not desired.
--- net/sunrpc/clnt.c | 1 - 1 file changed, 1 deletion(-)
net/sunrpc/clnt.c +0 -1
@@ -988,7 +988,6 @@ void rpc_task_set_client(struct rpc_task *task, struct rpc_clnt *clnt) {if (clnt !=NULL ) { -rpc_task_release_client (task);if (task->tk_xprt ==NULL ) task->tk_xprt =xprt_iter_get_next (&clnt->cl_xpi); task->tk_client = clnt;
Signature · 1 line
1.8.3.1
PATCH RESEND 6/12 SUNRPC rpc_clnt_xprt_switch_put
In reply to [email protected]From: Andy Adamson <[email protected]>
Give the NFS layer access to the xprt_switch_put function
--- include/linux/sunrpc/clnt.h | 2 ++ net/sunrpc/clnt.c | 6 ++++++ 2 files changed, 8 insertions(+)
include/linux/sunrpc/clnt.h +2 -0
@@ -197,5 +197,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *, void *data);const char *rpc_proc_name (const struct rpc_task *task); + +void rpc_clnt_xprt_switch_put (struct rpc_clnt *);#endif /* __KERNEL__ */ #endif /* _LINUX_SUNRPC_CLNT_H */
net/sunrpc/clnt.c +6 -0
@@ -2672,6 +2672,12 @@ out_put_switch: }EXPORT_SYMBOL_GPL (rpc_clnt_add_xprt); +void rpc_clnt_xprt_switch_put (struct rpc_clnt *clnt) +{ +xprt_switch_put (rcu_dereference (clnt->cl_xpi.xpi_xpswitch)); +} +EXPORT_SYMBOL_GPL (rpc_clnt_xprt_switch_put); +#if IS_ENABLED (CONFIG_SUNRPC_DEBUG )static void rpc_show_header (void ) {
Signature · 1 line
1.8.3.1
PATCH RESEND 7/12 SUNRPC rpc_clnt_xprt_switch_add_xprt
In reply to [email protected]From: Andy Adamson <[email protected]>
Give the NFS layer access to the rpc_xprt_switch_add_xprt function
--- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 7 +++++++ 2 files changed, 8 insertions(+)
include/linux/sunrpc/clnt.h +1 -0
@@ -199,5 +199,6 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,const char *rpc_proc_name (const struct rpc_task *task);void rpc_clnt_xprt_switch_put (struct rpc_clnt *); +void rpc_clnt_xprt_switch_add_xprt (struct rpc_clnt *,struct rpc_xprt *);#endif /* __KERNEL__ */ #endif /* _LINUX_SUNRPC_CLNT_H */
net/sunrpc/clnt.c +7 -0
@@ -2678,6 +2678,13 @@ void rpc_clnt_xprt_switch_put(struct rpc_clnt *clnt) }EXPORT_SYMBOL_GPL (rpc_clnt_xprt_switch_put); +void rpc_clnt_xprt_switch_add_xprt (struct rpc_clnt *clnt,struct rpc_xprt *xprt) +{ +rpc_xprt_switch_add_xprt (rcu_dereference (clnt->cl_xpi.xpi_xpswitch), + xprt); +} +EXPORT_SYMBOL_GPL (rpc_clnt_xprt_switch_add_xprt); +#if IS_ENABLED (CONFIG_SUNRPC_DEBUG )static void rpc_show_header (void ) {
Signature · 1 line
1.8.3.1
PATCH RESEND 8/12 SUNRPC search xprt switch for sockaddr
In reply to [email protected]From: Andy Adamson <[email protected]>
--- include/linux/sunrpc/clnt.h | 2 ++ include/linux/sunrpc/xprtmultipath.h | 2 ++ net/sunrpc/clnt.c | 15 +++++++++++++++ net/sunrpc/xprtmultipath.c | 24 +++++++++++++++++++++++- 4 files changed, 42 insertions(+), 1 deletion(-)
include/linux/sunrpc/clnt.h +2 -0
@@ -200,5 +200,7 @@ const char *rpc_proc_name(const struct rpc_task *task);void rpc_clnt_xprt_switch_put (struct rpc_clnt *);void rpc_clnt_xprt_switch_add_xprt (struct rpc_clnt *,struct rpc_xprt *); +bool rpc_clnt_xprt_switch_has_addr (struct rpc_clnt *clnt, +const struct sockaddr *sap);#endif /* __KERNEL__ */ #endif /* _LINUX_SUNRPC_CLNT_H */
include/linux/sunrpc/xprtmultipath.h +2 -0
@@ -66,4 +66,6 @@ extern struct rpc_xprt *xprt_iter_xprt(struct rpc_xprt_iter *xpi);extern struct rpc_xprt *xprt_iter_get_xprt (struct rpc_xprt_iter *xpi);extern struct rpc_xprt *xprt_iter_get_next (struct rpc_xprt_iter *xpi); +extern bool rpc_xprt_switch_has_addr (struct rpc_xprt_switch *xps, +const struct sockaddr *sap);#endif
net/sunrpc/clnt.c +15 -0
@@ -2685,6 +2685,21 @@ void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) }EXPORT_SYMBOL_GPL (rpc_clnt_xprt_switch_add_xprt); +bool rpc_clnt_xprt_switch_has_addr (struct rpc_clnt *clnt, +const struct sockaddr *sap) +{ +struct rpc_xprt_switch *xps; +bool ret; + + xps =rcu_dereference (clnt->cl_xpi.xpi_xpswitch); + +rcu_read_lock (); + ret =rpc_xprt_switch_has_addr (xps, sap); +rcu_read_unlock (); +return ret; +} +EXPORT_SYMBOL_GPL (rpc_clnt_xprt_switch_has_addr); +#if IS_ENABLED (CONFIG_SUNRPC_DEBUG )static void rpc_show_header (void ) {
net/sunrpc/xprtmultipath.c +23 -1
@@ -15,6 +15,7 @@#include <asm/cmpxchg.h> #include <linux/spinlock.h> #include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/addr.h> #include <linux/sunrpc/xprtmultipath.h> typedef struct rpc_xprt *(*xprt_switch_find_xprt_t)(struct list_head *head,
@@ -49,7 +50,8 @@ void rpc_xprt_switch_add_xprt(struct rpc_xprt_switch *xps,if (xprt ==NULL )return ;spin_lock (&xps->xps_lock); -if (xps->xps_net == xprt->xprt_net || xps->xps_net ==NULL ) +if ((xps->xps_net == xprt->xprt_net || xps->xps_net ==NULL ) && + !rpc_xprt_switch_has_addr (xps, (struct sockaddr *)&xprt->addr))xprt_switch_add_xprt_locked (xps, xprt);spin_unlock (&xps->xps_lock); }
@@ -232,6 +234,26 @@ struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi)return xprt_switch_find_current_entry (head, xpi->xpi_cursor); } +bool rpc_xprt_switch_has_addr (struct rpc_xprt_switch *xps, +const struct sockaddr *sap) +{ +struct list_head *head; +struct rpc_xprt *pos; + +if (xps ==NULL || sap ==NULL ) +return false; + + head = &xps->xps_xprt_list; +list_for_each_entry_rcu (pos, head, xprt_switch) { +if (rpc_cmp_addr_port (sap, (struct sockaddr *)&pos->addr)) { +pr_info ("RPC: addr %s already in xprt switch\n" , + pos->address_strings[RPC_DISPLAY_ADDR ]); +return true; + } + } +return false; +} +static struct rpc_xprt *xprt_switch_find_next_entry (struct list_head *head,const struct rpc_xprt *cur)
Signature · 1 line
1.8.3.1
PATCH RESEND 9/12 SUNRPC: rpc_clnt_add_xprt setup function for NFS layer
In reply to [email protected]From: Andy Adamson <[email protected]>
Use a setup function to call into the NFS layer to test an rpc_xprt for session trunking so as to not leak the rpc_xprt_switch into the nfs layer.
Search for the address in the rpc_xprt_switch first so as not to put an unnecessary EXCHANGE_ID on the wire.
--- include/linux/sunrpc/clnt.h | 12 +++++++++ net/sunrpc/clnt.c | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)
include/linux/sunrpc/clnt.h +12 -0
@@ -125,6 +125,13 @@ struct rpc_create_args {struct svc_xprt *bc_xprt;/* NFSv4.1 backchannel */ }; +struct rpc_add_xprt_test { +int (*add_xprt_test)(struct rpc_clnt *, +struct rpc_xprt *, +void *calldata); +void *data; +}; +/* Values for "flags" field */ #define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
@@ -196,6 +203,11 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *, void *), void *data); +int rpc_clnt_setup_test_and_add_xprt (struct rpc_clnt *, +struct rpc_xprt_switch *, +struct rpc_xprt *, +void *); +const char *rpc_proc_name (const struct rpc_task *task);void rpc_clnt_xprt_switch_put (struct rpc_clnt *);
net/sunrpc/clnt.c +64 -0
70 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH RESEND 10/12 NFS add xprt switch addrs test to match client
In reply to [email protected]From: Andy Adamson <[email protected]>
--- fs/nfs/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfs/client.c +4 -1
@@ -313,7 +313,10 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *datcontinue ;/* Match the full socket address */ if (!rpc_cmp_addr_port (sap, clap)) -continue ; +/* Match all xprt_switch full socket addresses */ +if (!rpc_clnt_xprt_switch_has_addr (clp->cl_rpcclient, + sap)) +continue ;atomic_inc (&clp->cl_count);return clp;
Signature · 1 line
1.8.3.1
PATCH RESEND 11/12 NFS test session trunking with exchange id
In reply to [email protected]From: Andy Adamson <[email protected]>
Use an async exchange id call to test for session trunking
To conform with RFC 5661 section 18.35.4, the Non-Update on Existing Clientid case, save the exchange id verifier in cl_confirm and use it for the session trunking exhange id test.
--- fs/nfs/nfs4_fs.h | 5 +++++ fs/nfs/nfs4client.c | 7 +++++-- fs/nfs/nfs4proc.c | 45 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 10 deletions(-)
fs/nfs/nfs4_fs.h +5 -0
@@ -203,6 +203,11 @@ struct nfs4_state_recovery_ops { struct rpc_cred *); }; +struct nfs4_add_xprt_data { +struct nfs_client *clp; +struct rpc_cred *cred; +}; +struct nfs4_state_maintenance_ops {int (*sched_state_renewal)(struct nfs_client *,struct rpc_cred *,unsigned );struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
fs/nfs/nfs4client.c +5 -2
@@ -638,8 +638,8 @@ out_scope_mismatch:/** * nfs4_detect_session_trunking - Checks for session trunking called -* after a successful EXCHANGE_ID testing a multi-addr connection to be -* potentially added as a session trunk +* after a successful EXCHANGE_ID testing a multi-addr connection. +* Upon success, add the transport. * * @clp: original mount nfs_client * @res: result structure from an exchange_id using the original mount
@@ -674,6 +674,9 @@ int nfs4_detect_session_trunking(struct nfs_client *clp,if (!nfs4_check_server_scope (clp->cl_serverscope, res->server_scope)) goto out; +/* Session trunking passed, add the xprt */ +rpc_clnt_xprt_switch_add_xprt (clp->cl_rpcclient, xprt); + status =0 ; out:if (status)
fs/nfs/nfs4proc.c +37 -8
107 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Re: [PATCH Version 9 RESEND 11/12] NFS test session trunking with exchange id
Hi Andy,
Quoted 20 lines · On 09/01/2016 11:44 AM, [email protected] wrote:
From: Andy Adamson <[email protected]>
Use an async exchange id call to test for session trunking
To conform with RFC 5661 section 18.35.4, the Non-Update on Existing Clientid case, save the exchange id verifier in
cl_confirmand use it for the session trunking exhange id test.Signed-off-by Andy Adamson <[email protected]>--- fs/nfs/nfs4_fs.h | 5 +++++ fs/nfs/nfs4client.c | 7 +++++-- fs/nfs/nfs4proc.c | 45 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 10 deletions(-)fs/nfs/nfs4_fs.h +0
-0
fs/nfs/nfs4_fs.h struct nfs4_state_recovery_ops { · line 209
Quoted 7 lines
fs/nfs/nfs4_fs.h +4
-0@@ -203,6 +203,11 @@ struct nfs4_state_recovery_ops { struct rpc_cred *); }; +struct nfs4_add_xprt_data { +struct nfs_client *clp; +struct rpc_cred *cred; +};
Looks like this doesn't get used until the next patch. Can you add it there instead of here?
Thanks,
Anna
Quoted 150 lines
fs/nfs/nfs4_fs.h +1
-0+struct nfs4_state_maintenance_ops {int (*sched_state_renewal)(struct nfs_client *,struct rpc_cred *,unsigned );struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);fs/nfs/nfs4client.c +5
-2@@ -638,8 +638,8 @@ out_scope_mismatch:/** * nfs4_detect_session_trunking - Checks for session trunking called -* after a successful EXCHANGE_ID testing a multi-addr connection to be -* potentially added as a session trunk +* after a successful EXCHANGE_ID testing a multi-addr connection. +* Upon success, add the transport. * * @clp: original mount nfs_client * @res: result structure from an exchange_id using the original mount @@ -674,6 +674,9 @@ int nfs4_detect_session_trunking(struct nfs_client *clp,if (!nfs4_check_server_scope (clp->cl_serverscope, res->server_scope)) goto out; +/* Session trunking passed, add the xprt */ +rpc_clnt_xprt_switch_add_xprt (clp->cl_rpcclient, xprt); + status =0 ; out:if (status)fs/nfs/nfs4proc.c +37
-8@@ -7054,6 +7054,7 @@ static int nfs4_sp4_select_mode(struct nfs_client *clp,struct nfs41_exchange_id_data {struct nfs41_exchange_id_res res;struct nfs41_exchange_id_args args; +struct rpc_xprt *xprt;int rpc_status; };@@ -7068,6 +7069,13 @@ static void nfs4_exchange_id_done(struct rpc_task *task, void *data)if (status ==0 ) status =nfs4_check_cl_exchange_flags (cdata->res.flags); + +if (cdata->xprt && status ==0 ) { + status =nfs4_detect_session_trunking (clp, &cdata->res, + cdata->xprt); + goto out; + } +if (status ==0 ) status =nfs4_sp4_select_mode (clp, &cdata->res.state_protect);@@ -7104,8 +7112,13 @@ static void nfs4_exchange_id_done(struct rpc_task *task, void *data) clp->cl_serverscope = cdata->res.server_scope; cdata->res.server_scope =NULL ; } +/* Save the EXCHANGE_ID verifier session trunk tests */ +memcpy (clp->cl_confirm.data, cdata->args.verifier->data, +sizeof (clp->cl_confirm.data)); } +out: cdata->rpc_status = status; +return ; }static void nfs4_exchange_id_release (void *data)@@ -7114,6 +7127,10 @@ static void nfs4_exchange_id_release(void *data) (struct nfs41_exchange_id_data *)data;nfs_put_client (cdata->args.client); +if (cdata->xprt) { +xprt_put (cdata->xprt); +rpc_clnt_xprt_switch_put (cdata->args.client->cl_rpcclient); + }kfree (cdata->res.impl_id);kfree (cdata->res.server_scope);kfree (cdata->res.server_owner);@@ -7131,7 +7148,7 @@ static const struct rpc_call_ops nfs4_exchange_id_call_ops = {* Wrapper for EXCHANGE_ID operation. */ static int _nfs4_proc_exchange_id (struct nfs_client *clp,struct rpc_cred *cred, -u32 sp4_how) +u32 sp4_how,struct rpc_xprt *xprt) {nfs4_verifier verifier;struct rpc_message msg = {@@ -7156,7 +7173,8 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,if (!calldata) goto out; -nfs4_init_boot_verifier (clp, &verifier); +if (!xprt) +nfs4_init_boot_verifier (clp, &verifier); status =nfs4_init_uniform_client_string (clp);if (status)@@ -7196,8 +7214,15 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, status = -EINVAL ; goto out_impl_id; } - - calldata->args.verifier = &verifier; +if (xprt) { + calldata->xprt = xprt; + task_setup_data.rpc_xprt = xprt; + task_setup_data.flags = +RPC_TASK_SOFT |RPC_TASK_SOFTCONN |RPC_TASK_ASYNC ; + calldata->args.verifier = &clp->cl_confirm; + }else { + calldata->args.verifier = &verifier; + } calldata->args.client = clp;#ifdef CONFIG_NFS_V4_1_MIGRATION calldata->args.flags = EXCHGID4_FLAG_SUPP_MOVED_REFER |@@ -7217,9 +7242,13 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred, goto out_impl_id; } - status =rpc_wait_for_completion_task (task); -if (!status) +if (!xprt) { + status =rpc_wait_for_completion_task (task); +if (!status) + status = calldata->rpc_status; + }else /* session trunking test */ status = calldata->rpc_status; +rpc_put_task (task); out:if (clp->cl_implid !=NULL )@@ -7262,13 +7291,13 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)/* try SP4_MACH_CRED if krb5i/p */ if (authflavor ==RPC_AUTH_GSS_KRB5I || authflavor ==RPC_AUTH_GSS_KRB5P ) { - status =_nfs4_proc_exchange_id (clp, cred,SP4_MACH_CRED ); + status =_nfs4_proc_exchange_id (clp, cred,SP4_MACH_CRED ,NULL );if (!status)return 0 ; }/* try SP4_NONE */ -return _nfs4_proc_exchange_id (clp, cred,SP4_NONE ); +return _nfs4_proc_exchange_id (clp, cred,SP4_NONE ,NULL ); } static int _nfs4_proc_destroy_clientid(struct nfs_client *clp,
PATCH RESEND 12/12 NFS pnfs data server multipath session trunking
In reply to [email protected]From: Andy Adamson <[email protected]>
Try all multipath addresses for a data server. The first address that successfully connects and creates a session is the DS mount address. All subsequent addresses are tested for session trunking and added as aliases.
--- fs/nfs/internal.h | 3 +++ fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4proc.c | 33 +++++++++++++++++++++++++++++++ fs/nfs/pnfs_nfs.c | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 81 insertions(+), 14 deletions(-)
fs/nfs/internal.h +3 -0
@@ -569,6 +569,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,struct rpc_cred *cred); +extern int nfs4_test_session_trunk (struct rpc_clnt *, +struct rpc_xprt *, +void *);static inline struct inode *nfs_igrab_and_active (struct inode *inode) {
fs/nfs/nfs4_fs.h +1 -0
@@ -59,6 +59,7 @@ struct nfs4_minor_version_ops { struct nfs4_lock_state *);struct nfs_seqid * (*alloc_seqid)(struct nfs_seqid_counter *,gfp_t ); +int (*session_trunk)(struct rpc_clnt *,struct rpc_xprt *,void *);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;
fs/nfs/nfs4proc.c +33 -0
@@ -7300,6 +7300,37 @@ int nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred)return _nfs4_proc_exchange_id (clp, cred,SP4_NONE ,NULL ); } +/** +* nfs4_test_session_trunk +* +* This is an add_xprt_test() test function called from +* rpc_clnt_setup_test_and_add_xprt. +* +* The rpc_xprt_switch is referrenced by rpc_clnt_setup_test_and_add_xprt +* and is dereferrenced in nfs4_exchange_id_release +* +* Upon success, add the new transport to the rpc_clnt +* +* @clnt: struct rpc_clnt to get new transport +* @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 *data) +{ +struct nfs4_add_xprt_data *adata = (struct nfs4_add_xprt_data *)data; +u32 sp4_how; + +dprintk ("--> %s try %s\n" , __func__, + xprt->address_strings[RPC_DISPLAY_ADDR ]); + + sp4_how = (adata->clp->cl_sp4_flags ==0 ?SP4_NONE :SP4_MACH_CRED ); + +/* Test connection for session trunking. Async exchange_id call */ +return _nfs4_proc_exchange_id (adata->clp, adata->cred, sp4_how, xprt); +} +EXPORT_SYMBOL_GPL (nfs4_test_session_trunk); +static int _nfs4_proc_destroy_clientid (struct nfs_client *clp,struct rpc_cred *cred) {
@@ -8878,6 +8909,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { .find_root_sec = nfs41_find_root_sec, .free_lock_state = nfs41_free_lock_state, .alloc_seqid = nfs_alloc_no_seqid, + .session_trunk = nfs4_test_session_trunk, .call_sync_ops = &nfs41_call_sync_ops, .reboot_recovery_ops = &nfs41_reboot_recovery_ops, .nograce_recovery_ops = &nfs41_nograce_recovery_ops,
@@ -8907,6 +8939,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { .free_lock_state = nfs41_free_lock_state, .call_sync_ops = &nfs41_call_sync_ops, .alloc_seqid = nfs_alloc_no_seqid, + .session_trunk = nfs4_test_session_trunk, .reboot_recovery_ops = &nfs41_reboot_recovery_ops, .nograce_recovery_ops = &nfs41_nograce_recovery_ops, .state_renewal_ops = &nfs41_state_renewal_ops,
fs/nfs/pnfs_nfs.c +44 -14
75 lines not on this page · raw message
Signature · 1 line
1.8.3.1