pNFS file layout session trunking
Subsystems (3)
cover pNFS file layout session trunking
From: Andy Adamson <[email protected]>
version-10:
- rebased to Anna's linux-next branch
- responded to Anna's version-9 cleanup review comments which effects these patches:
NFS detect session trunking
NFS test session trunking with exchange id
NFS pnfs data server multipath session trunking
version-9 RESEND:
- added put_rpccred to to _nfs4_pnfs_v4_ds_connect in "NFS pnfs data server multipath session trunking"
version-9:
- renamed rpc_clnt_xprt_switch_find_addr
- spelling nits
- moved rpc_cnt_xprt_switch_add_xprt into nfs4_detect_session_trunking
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 | 115 ++++++++++++-- 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, 498 insertions(+), 114 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 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
@@ -7048,6 +7048,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() *
@@ -7057,66 +7131,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 :
@@ -7126,55 +7194,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: "
@@ -7184,6 +7227,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 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 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 | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+)
fs/nfs/nfs4_fs.h +2 -0
@@ -278,6 +278,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 +90 -0
96 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 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
@@ -987,7 +987,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 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
@@ -199,5 +199,7 @@ void rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, unsigned long timeo);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
@@ -2695,6 +2695,12 @@ rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, unsigned long timeo) }EXPORT_SYMBOL_GPL (rpc_cap_max_reconnect_timeout); +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 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
@@ -201,5 +201,6 @@ void rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt,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
@@ -2701,6 +2701,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 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
@@ -202,5 +202,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
@@ -2708,6 +2708,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 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)
@@ -198,6 +205,11 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,void rpc_cap_max_reconnect_timeout (struct rpc_clnt *clnt,unsigned long timeo); +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 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/nfs4client.c | 10 +++++++--- fs/nfs/nfs4proc.c | 45 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 44 insertions(+), 11 deletions(-)
fs/nfs/nfs4client.c +7 -3
@@ -637,9 +637,10 @@ 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 +* nfs4_detect_session_trunking - Checks for session trunking. +* +* Called after a successful EXCHANGE_ID on 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
@@ -673,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_err; +/* Session trunking passed, add the xprt */ +rpc_clnt_xprt_switch_add_xprt (clp->cl_rpcclient, xprt); +pr_info ("NFS: %s: Session trunking succeeded for %s\n" , clp->cl_hostname, xprt->address_strings[RPC_DISPLAY_ADDR ]);
fs/nfs/nfs4proc.c +37 -8
107 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 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 | 6 ++++++ fs/nfs/nfs4proc.c | 33 +++++++++++++++++++++++++++++++ fs/nfs/pnfs_nfs.c | 58 +++++++++++++++++++++++++++++++++++++++++-------------- 4 files changed, 86 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 +6 -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;
@@ -203,6 +204,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/nfs4proc.c +33 -0
@@ -7297,6 +7297,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) {
@@ -8874,6 +8905,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,
@@ -8903,6 +8935,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
PATCH 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 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