nfs41 client backchannel for 2.6.31
Subsystems (3)
cover nfs41 client backchannel for 2.6.31
Trond,
Please review the following patchset and consider for 2.6.31.
It is also available ongit://linux-nfs.org/~bhalevy/linux-pnfs.git nfs41-for-2.6.31 which is based ontogit://git.linux-nfs.org/~trondmy/nfs-2.6.git nfsv41
Thanks,
Benny
[RFC 01/39] nfs41: Add ability to read RPC call direction on TCP stream.
[RFC 02/39] nfs41: Skip past the RPC call direction
[RFC 03/39] nfs41: Refactor nfs4_{init,destroy}_callback for nfs4.0
[RFC 04/39] nfs41: minorversion support for nfs4_{init,destroy}_callback
[RFC 05/39] nfs41: client callback structures
[RFC 06/39] nfs41: Initialize new rpc_xprt callback related fields
[RFC 07/39] nfs41: New backchannel helper routines
[RFC 08/39] nfs41: New include/linux/sunrpc/bc_xprt.h
[RFC 09/39] nfs41: New xs_tcp_read_data()
[RFC 10/39] nfs41: Add backchannel processing support to RPC state machine
[RFC 11/39] nfs41: Backchannel callback service helper routines
[RFC 12/39] nfs41: Refactor svc_process()
[RFC 13/39] nfs41: Backchannel bc_svc_process()
[RFC 14/39] nfs41: Implement NFSv4.1 callback service process.
[RFC 15/39] nfs41: sunrpc: provide functions to create and destroy a svc_xprt for backchannel use [RFC 16/39] nfs41: sunrpc: add a struct svc_xprt pointer to struct svc_serv for backchannel use [RFC 17/39] nfs41: create a svc_xprt for nfs41 callback thread and use for incoming callbacks [RFC 18/39] nfs41: save svc_serv in nfs_callback_info
[RFC 19/39] nfs41: Allow NFSv4 and NFSv4.1 callback services to coexist
[RFC 20/39] nfs41: Setup the backchannel
[RFC 21/39] nfs41: Client indicates presence of NFSv4.1 callback channel.
[RFC 22/39] nfs41: Get the rpc_xprt * from the rpc_rqst instead of the rpc_clnt. [RFC 23/39] nfs41: Release backchannel resources associated with session
[RFC 24/39] nfs41: store minorversion in cb_compound_hdr_arg
[RFC 25/39] nfs41: decode minorversion 1 cb_compound header
[RFC 26/39] nfs41: callback numbers definitions
[RFC 27/39] nfs41: consider minorversion in callback_xdr:process_op
[RFC 28/39] nfs41: define CB_NOTIFY_DEVICEID as not supported
[RFC 29/39] nfs41: cb_sequence protocol level data structures
[RFC 30/39] nfs41: cb_sequence proc implementation
[RFC 31/39] nfs41: cb_sequence xdr implementation
[RFC 32/39] nfs41: verify CB_SEQUENCE position in callback compound
[RFC 33/39] nfs41: Rename rq_received to rq_reply_bytes_recvd
[RFC 34/39] nfs41: Backchannel: update cb_sequence args and results
[RFC 35/39] nfs41: Backchannel: Refactor nfs4_reset_slot_table()
[RFC 36/39] nfs41: Backchannel: Refactor nfs4_init_slot_table()
[RFC 37/39] nfs41: Backchannel: Add a backchannel slot table to the session
[RFC 38/39] nfs41: Backchannel: New find_client_with_session()
[RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation
RFC 1/39 nfs41: Add ability to read RPC call direction on TCP stream.
From: Ricardo Labiaga <[email protected]>
NFSv4.1 callbacks can arrive over an existing connection. This patch adds the logic to read the RPC call direction (call or reply). It does this by updating the state machine to look for the call direction invoking xs_tcp_read_calldir(...) after reading the XID.
[nfs41: Keep track of RPC call/reply direction with a flag]
As per 11/14/08 review of RFC 53/85.
Add a new flag to track whether the incoming message is an RPC call or an RPC reply. TCP_RPC_REPLY is set in the 'struct sock_xprt' tcp_flags in xs_tcp_read_calldir() if the message is an RPC reply sent on the forechannel. It is cleared if the message is an RPC request sent on the back channel.
--- net/sunrpc/xprtsock.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 49 insertions(+), 3 deletions(-)
net/sunrpc/xprtsock.c +49 -3
@@ -270,6 +270,12 @@ struct sock_xprt {#define TCP_RCV_COPY_FRAGHDR (1UL << 1)#define TCP_RCV_COPY_XID (1UL << 2)#define TCP_RCV_COPY_DATA (1UL << 3) +#define TCP_RCV_COPY_CALLDIR (1UL << 4) + +/* +* TCP RPC flags +*/ +#define TCP_RPC_REPLY (1UL << 5)static inline struct sockaddr *xs_addr (struct rpc_xprt *xprt) {
@@ -945,7 +951,7 @@ static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_rea transport->tcp_offset =0 ;/* Sanity check of the record length */ -if (unlikely (transport->tcp_reclen <4 )) { +if (unlikely (transport->tcp_reclen <8 )) {dprintk ("RPC: invalid TCP record fragment length\n" );xprt_force_disconnect (xprt);return ;
@@ -980,13 +986,48 @@ static inline void xs_tcp_read_xid(struct sock_xprt *transport, struct xdr_skb_rif (used != len)return ; transport->tcp_flags &= ~TCP_RCV_COPY_XID ; - transport->tcp_flags |=TCP_RCV_COPY_DATA ; + transport->tcp_flags |=TCP_RCV_COPY_CALLDIR ; transport->tcp_copied =4 ; -dprintk ("RPC: reading reply for XID %08x\n" , +dprintk ("RPC: reading %s XID %08x\n" , + (transport->tcp_flags &TCP_RPC_REPLY ) ?"reply for" + :"request with" ,ntohl (transport->tcp_xid));xs_tcp_check_fraghdr (transport); } +static inline void xs_tcp_read_calldir (struct sock_xprt *transport, +struct xdr_skb_reader *desc) +{ +size_t len, used; +u32 offset; +__be32 calldir; + +/* +* We want transport->tcp_offset to be 8 at the end of this routine +* (4 bytes for the xid and 4 bytes for the call/reply flag). +* When this function is called for the first time, +* transport->tcp_offset is 4 (after having already read the xid). +*/ + offset = transport->tcp_offset -sizeof (transport->tcp_xid); + len =sizeof (calldir) - offset; +dprintk ("RPC: reading CALL/REPLY flag (%Zu bytes)\n" , len); + used =xdr_skb_read_bits (desc, &calldir, len); + transport->tcp_offset += used; +if (used != len) +return ; + transport->tcp_flags &= ~TCP_RCV_COPY_CALLDIR ; + transport->tcp_flags |=TCP_RCV_COPY_DATA ; + transport->tcp_copied +=4 ; +if (ntohl (calldir) ==RPC_REPLY ) + transport->tcp_flags |=TCP_RPC_REPLY ; +else + transport->tcp_flags &= ~TCP_RPC_REPLY ; +dprintk ("RPC: reading %s CALL/REPLY flag %08x\n" , + (transport->tcp_flags &TCP_RPC_REPLY ) ? +"reply for" :"request with" , calldir); +xs_tcp_check_fraghdr (transport); +} +static inline void xs_tcp_read_request (struct rpc_xprt *xprt,struct xdr_skb_reader *desc) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -1103,6 +1144,11 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, unsxs_tcp_read_xid (transport, &desc);continue ; } +/* Read in the call/reply flag */ +if (transport->tcp_flags &TCP_RCV_COPY_CALLDIR ) { +xs_tcp_read_calldir (transport, &desc); +continue ; + }/* Read in the request data */ if (transport->tcp_flags &TCP_RCV_COPY_DATA ) {xs_tcp_read_request (xprt, &desc);
Signature · 1 line
1.6.2.1
RFC 2/39 nfs41: Skip past the RPC call direction
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
xs_tcp_read_calldir() is now responsible for reading the RPC call direction and determining whether it is a reply or a callback request. The call to xdr_skb_read_bits() inside xs_tcp_read_calldir() moves the xdr_skb_reader offset past the RPC call direction (offset should be equal to 8). Therefore xs_tcp_read_common() called from xs_tcp_ready_reply() should be copying the TCP buffer starting past the RPC call direction. It is now necessary to read the RPC call direction earlier to determine whether to call the reply handler or the callback handler.
call_verify() should therefore skip past the XID and call/reply flag.
--- net/sunrpc/clnt.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
net/sunrpc/clnt.c +7 -6
@@ -1390,13 +1390,14 @@ rpc_verify_header(struct rpc_task *task) }if ((len -=3 ) <0 ) goto out_overflow; - p +=1 ;/* skip XID */ -if ((n =ntohl (*p++)) !=RPC_REPLY ) { -dprintk ("RPC: %5u %s: not an RPC reply: %x\n" , - task->tk_pid, __func__, n); - goto out_garbage; - } +/* +* Skip the XID and call direction. +* The underlying transport has read the XID and RPC call direction +* to determine this is an RPC reply. +*/ + p +=2 ; +if ((n =ntohl (*p++)) !=RPC_MSG_ACCEPTED ) {if (--len <0 ) goto out_overflow;
Signature · 1 line
1.6.2.1
RFC 3/39 nfs41: Refactor nfs4_{init,destroy}_callback for nfs4.0
In reply to Benny HalevyRefactor-out code to bring the callback service up and down.
--- fs/nfs/client.c | 46 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 37 insertions(+), 9 deletions(-)
fs/nfs/client.c +37 -9
@@ -47,6 +47,9 @@#include "internal.h" #include "fscache.h" +static int nfs4_init_callback (struct nfs_client *); +static void nfs4_destroy_callback (struct nfs_client *); +#define NFSDBG_FACILITY NFSDBG_CLIENTstatic DEFINE_SPINLOCK (nfs_client_lock);
@@ -121,11 +124,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ clp->rpc_ops = cl_init->rpc_ops; -if (cl_init->rpc_ops->version ==4 ) { -if (nfs_callback_up () <0 ) - goto error_2; -__set_bit (NFS_CS_CALLBACK , &clp->cl_res_state); - } +if (nfs4_init_callback (clp) <0 ) + goto error_2;atomic_set (&clp->cl_count,1 ); clp->cl_cons_state =NFS_CS_INITING ;
@@ -162,8 +162,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_return clp; error_3: -if (__test_and_clear_bit (NFS_CS_CALLBACK , &clp->cl_res_state)) -nfs_callback_down (); +nfs4_destroy_callback (clp); error_2:kfree (clp); error_0:
@@ -184,6 +183,17 @@ static void nfs4_shutdown_client(struct nfs_client *clp) }/* +* Destroy the NFS4 callback service +*/ +static void nfs4_destroy_callback (struct nfs_client *clp) +{ +#ifdef CONFIG_NFS_V4 +if (__test_and_clear_bit (NFS_CS_CALLBACK , &clp->cl_res_state)) +nfs_callback_down (); +#endif /* CONFIG_NFS_V4 */ +} + +/* * Clears/puts all minor version specific parts from an nfs_client struct * reverting it to minorversion 0. */
@@ -215,8 +225,7 @@ static void nfs_free_client(struct nfs_client *clp)if (!IS_ERR (clp->cl_rpcclient))rpc_shutdown_client (clp->cl_rpcclient); -if (__test_and_clear_bit (NFS_CS_CALLBACK , &clp->cl_res_state)) -nfs_callback_down (); +nfs4_destroy_callback (clp);if (clp->cl_machine_cred !=NULL )put_rpccred (clp->cl_machine_cred);
@@ -1088,6 +1097,25 @@ error:#ifdef CONFIG_NFS_V4 /* +* Initialize the NFS4 callback service +*/ +static int nfs4_init_callback (struct nfs_client *clp) +{ +int error; + +if (clp->rpc_ops->version ==4 ) { + error =nfs_callback_up (); +if (error <0 ) { +dprintk ("%s: failed to start callback. Error = %d\n" , + __func__, error); +return error; + } +__set_bit (NFS_CS_CALLBACK , &clp->cl_res_state); + } +return 0 ; +} + +/* * Initialize the minor version specific parts of an NFS4 client record */ static int nfs4_init_client_minor_version (struct nfs_client *clp)
Signature · 1 line
1.6.2.1
RFC 4/39 nfs41: minorversion support for nfs4_{init,destroy}_callback
In reply to Benny Halevymove nfs4_init_callback into nfs4_init_client_minor_version and nfs4_destroy_callback into nfs4_clear_client_minor_version
as these need to happen also when auto-negotiating the minorversion once the callback service for nfs41 becomes different than for nfs4.0
--- fs/nfs/callback.c | 67 ++++++++++++++++++++++++++++++++++++++--------------- fs/nfs/callback.h | 2 +- fs/nfs/client.c | 21 +++++----------- 3 files changed, 56 insertions(+), 34 deletions(-)
fs/nfs/callback.c +48 -19
@@ -59,7 +59,7 @@ module_param_call(callback_tcpport, param_set_port, param_get_int,* This is the callback kernel thread. */ static int -nfs_callback_svc (void *vrqstp) +nfs4_callback_svc (void *vrqstp) {int err, preverr =0 ;struct svc_rqst *rqstp = vrqstp;
@@ -97,20 +97,12 @@ nfs_callback_svc(void *vrqstp) }/* -* Bring up the callback thread if it is not already up. +* Prepare to bring up the NFSv4 callback service */ -int nfs_callback_up (void ) +struct svc_rqst * +nfs4_callback_up (struct svc_serv *serv) { -struct svc_serv *serv =NULL ; -int ret =0 ; - -mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) - goto out; - serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL ); - ret = -ENOMEM ; -if (!serv) - goto out_err; +int ret; ret =svc_create_xprt (serv,"tcp" ,PF_INET , nfs_callback_set_tcpport,SVC_SOCK_ANONYMOUS );
@@ -131,18 +123,55 @@ int nfs_callback_up(void) goto out_err;#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ - nfs_callback_info.rqst =svc_prepare_thread (serv, &serv->sv_pools[0 ]); -if (IS_ERR (nfs_callback_info.rqst)) { - ret =PTR_ERR (nfs_callback_info.rqst); - nfs_callback_info.rqst =NULL ; +return svc_prepare_thread (serv, &serv->sv_pools[0 ]); + +out_err: +if (ret ==0 ) + ret = -ENOMEM ; +return ERR_PTR (ret); +} + +/* +* Bring up the callback thread if it is not already up. +*/ +int nfs_callback_up (u32 minorversion,void *args) +{ +struct svc_serv *serv =NULL ; +struct svc_rqst *rqstp; +int (*callback_svc)(void *vrqstp); +char svc_name[12 ]; +int ret =0 ; + +mutex_lock (&nfs_callback_mutex); +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) + goto out; + serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL ); +if (!serv) { + ret = -ENOMEM ; + goto out_err; + } + +/* FIXME: either 4.0 or 4.1 callback service can be up at a time +* need to monitor and control them both */ +if (!minorversion) { + rqstp =nfs4_callback_up (serv); + callback_svc = nfs4_callback_svc; + }else { +BUG ();/* for now */ + } + +if (IS_ERR (rqstp)) { + ret =PTR_ERR (rqstp); goto out_err; }svc_sock_update_bufs (serv); - nfs_callback_info.task =kthread_run (nfs_callback_svc, +sprintf (svc_name,"nfsv4.%u-svc" , minorversion); + nfs_callback_info.rqst = rqstp; + nfs_callback_info.task =kthread_run (callback_svc, nfs_callback_info.rqst, -"nfsv4-svc" ); + svc_name);if (IS_ERR (nfs_callback_info.task)) { ret =PTR_ERR (nfs_callback_info.task);svc_exit_thread (nfs_callback_info.rqst);
fs/nfs/callback.h +1 -1
@@ -63,7 +63,7 @@ extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getatextern __be32 nfs4_callback_recall (struct cb_recallargs *args,void *dummy);#ifdef CONFIG_NFS_V4 -extern int nfs_callback_up (void ); +extern int nfs_callback_up (u32 minorversion,void *args);extern void nfs_callback_down (void );#else #define nfs_callback_up () (0)
fs/nfs/client.c +7 -14
@@ -47,9 +47,6 @@#include "internal.h" #include "fscache.h" -static int nfs4_init_callback (struct nfs_client *); -static void nfs4_destroy_callback (struct nfs_client *); -#define NFSDBG_FACILITY NFSDBG_CLIENTstatic DEFINE_SPINLOCK (nfs_client_lock);
@@ -124,9 +121,6 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ clp->rpc_ops = cl_init->rpc_ops; -if (nfs4_init_callback (clp) <0 ) - goto error_2; -atomic_set (&clp->cl_count,1 ); clp->cl_cons_state =NFS_CS_INITING ;
@@ -136,7 +130,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_if (cl_init->hostname) { clp->cl_hostname =kstrdup (cl_init->hostname,GFP_KERNEL );if (!clp->cl_hostname) - goto error_3; + goto error_cleanup; }INIT_LIST_HEAD (&clp->cl_superblocks);
@@ -161,9 +155,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_return clp; -error_3: -nfs4_destroy_callback (clp); -error_2: +error_cleanup:kfree (clp); error_0:return NULL ;
@@ -207,6 +199,8 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp) clp->cl_call_sync = _nfs4_call_sync;#endif /* CONFIG_NFS_V4_1 */ + +nfs4_destroy_callback (clp); }/*
@@ -225,8 +219,6 @@ static void nfs_free_client(struct nfs_client *clp)if (!IS_ERR (clp->cl_rpcclient))rpc_shutdown_client (clp->cl_rpcclient); -nfs4_destroy_callback (clp); -if (clp->cl_machine_cred !=NULL )put_rpccred (clp->cl_machine_cred);
@@ -1104,7 +1096,8 @@ static int nfs4_init_callback(struct nfs_client *clp)int error;if (clp->rpc_ops->version ==4 ) { - error =nfs_callback_up (); + error =nfs_callback_up (clp->cl_minorversion, + clp->cl_rpcclient->cl_xprt);if (error <0 ) {dprintk ("%s: failed to start callback. Error = %d\n" , __func__, error);
@@ -1139,7 +1132,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) }#endif /* CONFIG_NFS_V4_1 */ -return 0 ; +return nfs4_init_callback (clp); }/*
Signature · 1 line
1.6.2.1
RFC 5/39 nfs41: client callback structures
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Adds new list of rpc_xprt structures, and a readers/writers lock to protect the list. The list is used to preallocate resources for the backchannel during backchannel requests. Callbacks are not expected to cause significant latency, so only one callback will be allowed at this time.
It also adds a pointer to the NFS callback service so that requests can be directed to it for processing.
New callback members added to svc_serv. The NFSv4.1 callback service will sleep on the svc_serv->svc_cb_waitq until new callback requests arrive. The request will be queued in svc_serv->svc_cb_list. This patch adds this list, the sleep queue and spinlock to svc_serv.
--- include/linux/sunrpc/svc.h | 8 ++++++++ include/linux/sunrpc/xprt.h | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)
include/linux/sunrpc/svc.h +8 -0
@@ -96,6 +96,14 @@ struct svc_serv {svc_thread_fn sv_function;/* main function for threads */ unsigned int sv_drc_max_pages;/* Total pages for DRC */ unsigned int sv_drc_pages_used;/* DRC pages used */ +#if defined(CONFIG_NFS_V4_1 ) +struct list_head sv_cb_list;/* queue for callback requests +* that arrive over the same +* connection */ +spinlock_t sv_cb_lock;/* protects the svc_cb_list */ +wait_queue_head_t sv_cb_waitq;/* sleep here if there are no +* entries in the svc_cb_list */ +#endif /* CONFIG_NFS_V4_1 */ };/*
include/linux/sunrpc/xprt.h +22 -0
@@ -97,6 +97,12 @@ struct rpc_rqst {unsigned long rq_xtime;/* when transmitted */ int rq_ntrans; + +#if defined(CONFIG_NFS_V4_1 ) +struct list_head rq_bc_list;/* Callback service list */ +unsigned long rq_bc_pa_state;/* Backchannel prealloc state */ +struct list_head rq_bc_pa_list;/* Backchannel prealloc list */ +#endif /* CONFIG_NFS_V4_1 */ };#define rq_svec rq_snd_buf.head#define rq_slen rq_snd_buf.len
@@ -174,6 +180,14 @@ struct rpc_xprt {spinlock_t reserve_lock;/* lock slot table */ u32 xid;/* Next XID value to use */ struct rpc_task * snd_task;/* Task blocked in send */ +#if defined(CONFIG_NFS_V4_1 ) +struct svc_serv *bc_serv;/* The RPC service which will */ +/* process the callback */ +spinlock_t bc_pa_lock;/* Protects the preallocated +* items */ +struct list_head bc_pa_list;/* List of preallocated +* backchannel rpc_rqst's */ +#endif /* CONFIG_NFS_V4_1 */ struct list_head recv;struct {
@@ -192,6 +206,14 @@ struct rpc_xprt {const char *address_strings[RPC_DISPLAY_MAX ]; }; +#if defined(CONFIG_NFS_V4_1 ) +/* +* Backchannel flags +*/ +#define RPC_BC_PA_IN_USE 0x0001/* Preallocated backchannel */ +/* buffer in use */ +#endif /* CONFIG_NFS_V4_1 */ +struct xprt_create {int ident;/* XPRT_TRANSPORT identifier */ struct sockaddr * srcaddr;/* optional local address */
Signature · 1 line
1.6.2.1
RFC 6/39 nfs41: Initialize new rpc_xprt callback related fields
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
--- net/sunrpc/xprt.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
net/sunrpc/xprt.c +5 -0
@@ -1051,6 +1051,11 @@ found:INIT_LIST_HEAD (&xprt->free);INIT_LIST_HEAD (&xprt->recv); +#if defined(CONFIG_NFS_V4_1 ) +spin_lock_init (&xprt->bc_pa_lock); +INIT_LIST_HEAD (&xprt->bc_pa_list); +#endif /* CONFIG_NFS_V4_1 */ +INIT_WORK (&xprt->task_cleanup, xprt_autoclose);setup_timer (&xprt->timer, xprt_init_autodisconnect, (unsigned long )xprt);
Signature · 1 line
1.6.2.1
RFC 7/39 nfs41: New backchannel helper routines
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
This patch introduces support to setup the callback xprt on the client side. It allocates/ destroys the preallocated memory structures used to process backchannel requests.
At setup time, xprt_setup_backchannel() is invoked to allocate one or more rpc_rqst structures and substructures. This ensures that they are available when an RPC callback arrives. The rpc_rqst structures are maintained in a linked list attached to the rpc_xprt structure. We keep track of the number of allocations so that they can be correctly removed when the channel is destroyed.
When an RPC callback arrives, xprt_alloc_bc_request() is invoked to obtain a preallocated rpc_rqst structure. An rpc_xprt structure is returned, and its RPC_BC_PREALLOC_IN_USE bit is set in rpc_xprt->bc_flags. The structure is removed from the the list since it is now in use, and it will be later added back when its user is done with it.
After the RPC callback replies, the rpc_rqst structure is returned by invoking xprt_free_bc_request(). This clears the RPC_BC_PREALLOC_IN_USE bit and adds it back to the list, allowing it to be reused by a subsequent RPC callback request.
To be consistent with the reception of RPC messages, the backchannel requests should be placed into the 'struct rpc_rqst' rq_rcv_buf, which is then in turn copied to the 'struct rpc_rqst' rq_private_buf.
--- include/linux/sunrpc/xprt.h | 1 + net/sunrpc/Makefile | 1 + net/sunrpc/backchannel_rqst.c | 270 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 272 insertions(+), 0 deletions(-) create mode 100644 net/sunrpc/backchannel_rqst.c
include/linux/sunrpc/xprt.h +1 -0
@@ -183,6 +183,7 @@ struct rpc_xprt {#if defined(CONFIG_NFS_V4_1 )struct svc_serv *bc_serv;/* The RPC service which will */ /* process the callback */ +unsigned int bc_alloc_count;/* Total number of preallocs */ spinlock_t bc_pa_lock;/* Protects the preallocated * items */ struct list_head bc_pa_list;/* List of preallocated
net/sunrpc/Makefile +1 -0
@@ -13,5 +13,6 @@ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ rpcb_clnt.o timer.o xdr.o \ sunrpc_syms.o cache.o rpc_pipe.o \ svc_xprt.o +sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.o
net/sunrpc/backchannel_rqst.c new file +270 -0
270 lines not on this page · raw message
Signature · 1 line
1.6.2.1
RFC 8/39 nfs41: New include/linux/sunrpc/bc_xprt.h
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Contains prototype for backchannel helper routines.
Fix compile error when CONFIG_NFS_V4_1 is not set.
--- include/linux/sunrpc/bc_xprt.h | 44 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 include/linux/sunrpc/bc_xprt.h
include/linux/sunrpc/bc_xprt.h new file +44 -0
@@ -0,0 +1,44 @@ +/****************************************************************************** + +(c) 2008 Network Appliance, Inc. All Rights Reserved. + +Network Appliance provides this source code under the GPL v2 License. +The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ + +/* +* Functions to create and manage the backchannel +*/ + +#ifndef _LINUX_SUNRPC_BC_XPRT_H +#define _LINUX_SUNRPC_BC_XPRT_H + +#include <linux/sunrpc/svcsock.h> +#include <linux/sunrpc/xprt.h> + +#ifdef CONFIG_NFS_V4_1 +struct rpc_rqst *xprt_alloc_bc_request (struct rpc_xprt *xprt); +void xprt_free_bc_request (struct rpc_rqst *req); +int xprt_setup_backchannel (struct rpc_xprt *,unsigned int min_reqs); +void xprt_destroy_backchannel (struct rpc_xprt *,int max_reqs); +#else /* CONFIG_NFS_V4_1 */ +static inline int xprt_setup_backchannel (struct rpc_xprt *xprt, +unsigned int min_reqs) +{return 0 ; } +#endif /* CONFIG_NFS_V4_1 */ +#endif /* _LINUX_SUNRPC_BC_XPRT_H */ +
Signature · 1 line
1.6.2.1
RFC 9/39 nfs41: New xs_tcp_read_data()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Handles RPC replies and backchannel callbacks. Traditionally the NFS client has expected only RPC replies on its open connections. With NFSv4.1, callbacks can arrive over an existing open connection.
This patch refactors the old xs_tcp_read_request() into an RPC reply handler:xs_tcp_read_reply(), a new backchannel callback handler: xs_tcp_read_callback(), and a common routine to read the data off the transport: xs_tcp_read_common(). The new xs_tcp_read_callback() queues callback requests onto a queue where the callback service (a separate thread) is listening for the processing.
This patch incorporates work and suggestions from Rahul Iyer ([email protected]) and Benny Halevy ([email protected]).
--- net/sunrpc/xprtsock.c | 141 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 123 insertions(+), 18 deletions(-)
net/sunrpc/xprtsock.c +123 -18
@@ -34,6 +34,9 @@#include <linux/sunrpc/sched.h> #include <linux/sunrpc/xprtsock.h> #include <linux/file.h> +#ifdef CONFIG_NFS_V4_1 +#include <linux/sunrpc/bc_xprt.h> +#endif #include <net/sock.h> #include <net/checksum.h>
@@ -1028,25 +1031,16 @@ static inline void xs_tcp_read_calldir(struct sock_xprt *transport,xs_tcp_check_fraghdr (transport); } -static inline void xs_tcp_read_request (struct rpc_xprt *xprt,struct xdr_skb_reader *desc) +static inline void xs_tcp_read_common (struct rpc_xprt *xprt, +struct xdr_skb_reader *desc, +struct rpc_rqst *req) { - struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); -struct rpc_rqst *req; +struct sock_xprt *transport = + container_of(xprt, struct sock_xprt, xprt);struct xdr_buf *rcvbuf;size_t len;ssize_t r; -/* Find and lock the request corresponding to this xid */ -spin_lock (&xprt->transport_lock); - req =xprt_lookup_rqst (xprt, transport->tcp_xid); -if (!req) { - transport->tcp_flags &= ~TCP_RCV_COPY_DATA ; -dprintk ("RPC: XID %08x request not found!\n" , -ntohl (transport->tcp_xid)); -spin_unlock (&xprt->transport_lock); -return ; - } - rcvbuf = &req->rq_private_buf; len = desc->count;if (len > transport->tcp_reclen - transport->tcp_offset) {
@@ -1084,7 +1078,7 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, struct xdr_skb_rea"tcp_offset = %u, tcp_reclen = %u\n" , xprt, transport->tcp_copied, transport->tcp_offset, transport->tcp_reclen); - goto out; +return ; } dprintk("RPC: XID %08x read %Zd bytes\n",
@@ -1100,11 +1094,122 @@ static inline void xs_tcp_read_request(struct rpc_xprt *xprt, struct xdr_skb_rea transport->tcp_flags &= ~TCP_RCV_COPY_DATA ; } -out: +return ; +} + +/* +* Finds the request corresponding to the RPC xid and invokes the common +* tcp read code to read the data. +*/ +static inline int xs_tcp_read_reply (struct rpc_xprt *xprt, +struct xdr_skb_reader *desc) +{ +struct sock_xprt *transport = + container_of(xprt, struct sock_xprt, xprt); +struct rpc_rqst *req; + +dprintk ("RPC: read reply XID %08x\n" ,ntohl (transport->tcp_xid)); + +/* Find and lock the request corresponding to this xid */ +spin_lock (&xprt->transport_lock); + req =xprt_lookup_rqst (xprt, transport->tcp_xid); +if (!req) { +dprintk ("RPC: XID %08x request not found!\n" , +ntohl (transport->tcp_xid)); +spin_unlock (&xprt->transport_lock); +return -1 ; + } + +xs_tcp_read_common (xprt, desc, req); +if (!(transport->tcp_flags &TCP_RCV_COPY_DATA ))xprt_complete_rqst (req->rq_task, transport->tcp_copied); +spin_unlock (&xprt->transport_lock); -xs_tcp_check_fraghdr (transport); +return 0 ; +} + +#if defined(CONFIG_NFS_V4_1 ) +/* +* Obtains an rpc_rqst previously allocated and invokes the common +* tcp read code to read the data. The result is placed in the callback +* queue. +* If we're unable to obtain the rpc_rqst we schedule the closing of the +* connection and return -1. +*/ +static inline int xs_tcp_read_callback (struct rpc_xprt *xprt, +struct xdr_skb_reader *desc) +{ +struct sock_xprt *transport = + container_of(xprt, struct sock_xprt, xprt); +struct rpc_rqst *req; + + req =xprt_alloc_bc_request (xprt); +if (req ==NULL ) { +/* +* Schedule an autoclose RPC call +*/ +printk (KERN_WARNING "Callback slot table overflowed\n" ); +set_bit (XPRT_CLOSE_WAIT , &xprt->state); +if (test_and_set_bit (XPRT_LOCKED , &xprt->state) ==0 ) +queue_work (rpciod_workqueue, &xprt->task_cleanup); +return -1 ; + } + + req->rq_xid = transport->tcp_xid; +dprintk ("RPC: read callback XID %08x\n" ,ntohl (req->rq_xid)); +xs_tcp_read_common (xprt, desc, req); + +if (!(transport->tcp_flags &TCP_RCV_COPY_DATA )) { +struct svc_serv *bc_serv = xprt->bc_serv; + +/* +* Add callback request to callback list. The callback +* service sleeps on the sv_cb_waitq waiting for new +* requests. Wake it up after adding enqueing the +* request. +*/ +dprintk ("RPC: add callback request to list\n" ); +spin_lock (&bc_serv->sv_cb_lock); +list_add (&req->rq_bc_list, &bc_serv->sv_cb_list); +spin_unlock (&bc_serv->sv_cb_lock); +wake_up (&bc_serv->sv_cb_waitq); + } + + req->rq_private_buf.len = transport->tcp_copied; + +return 0 ; +} +#endif /* CONFIG_NFS_V4_1 */ + +/* +* Read data off the transport. This can be either an RPC_CALL or an +* RPC_REPLY. Relay the processing to helper functions. +*/ +static void xs_tcp_read_data (struct rpc_xprt *xprt, +struct xdr_skb_reader *desc) +{ +struct sock_xprt *transport = + container_of(xprt, struct sock_xprt, xprt); +int status; + +#if defined(CONFIG_NFS_V4_1 ) + status = (transport->tcp_flags &TCP_RPC_REPLY ) ? +xs_tcp_read_reply (xprt, desc) : +xs_tcp_read_callback (xprt, desc); +#else + status =xs_tcp_read_reply (xprt, desc); +#endif /* CONFIG_NFS_V4_1 */ + +if (status ==0 ) +xs_tcp_check_fraghdr (transport); +else { +/* +* The transport_lock protects the request handling. +* There's no need to hold it to update the tcp_flags. +*/ + transport->tcp_flags &= ~TCP_RCV_COPY_DATA ; + } }static inline void xs_tcp_read_discard (struct sock_xprt *transport,struct xdr_skb_reader *desc)
@@ -1151,7 +1256,7 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns }/* Read in the request data */ if (transport->tcp_flags &TCP_RCV_COPY_DATA ) { -xs_tcp_read_request (xprt, &desc); +xs_tcp_read_data (xprt, &desc);continue ; }/* Skip over any trailing bytes on short reads */
Signature · 1 line
1.6.2.1
RFC 10/39 nfs41: Add backchannel processing support to RPC state machine
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Adds rpc_run_bc_task() which is called by the NFS callback service to process backchannel requests. It performs similar work to rpc_run_task() though "schedules" the backchannel task to be executed starting at the call_trasmit state in the RPC state machine.
It also introduces some miscellaneous updates to the argument validation, call_transmit, and transport cleanup functions to take into account that there are now forechannel and backchannel tasks.
Backchannel requests do not carry an RPC message structure, since the payload has already been XDR encoded using the existing NFSv4 callback mechanism.
Introduce a new transmit state for the client to reply on to backchannel requests. This new state simply reserves the transport and issues the reply. In case of a connection related error, disconnects the transport and drops the reply. It requires the forechannel to re-establish the connection and the server to retransmit the request, as stated in NFSv4.1 section 2.9.2 "Client and Server Transport Behavior".
Note: There is no need to loop attempting to reserve the transport. If EAGAIN is returned by xprt_prepare_transmit(), return with tk_status == 0, setting tk_action to call_bc_transmit. rpc_execute() will invoke it again after the task is taken off the sleep queue.
--- include/linux/sunrpc/sched.h | 2 + include/linux/sunrpc/xprt.h | 12 ++++ net/sunrpc/clnt.c | 117 +++++++++++++++++++++++++++++++++++++++++- net/sunrpc/stats.c | 6 ++- net/sunrpc/sunrpc.h | 35 +++++++++++++ net/sunrpc/xprt.c | 36 +++++++++++-- 6 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 net/sunrpc/sunrpc.h
include/linux/sunrpc/sched.h +2 -0
@@ -210,6 +210,8 @@ struct rpc_wait_queue {*/ struct rpc_task *rpc_new_task (const struct rpc_task_setup *);struct rpc_task *rpc_run_task (const struct rpc_task_setup *); +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, +const struct rpc_call_ops *ops);void rpc_put_task (struct rpc_task *);void rpc_exit_task (struct rpc_task *);void rpc_release_calldata (const struct rpc_call_ops *,void *);
include/linux/sunrpc/xprt.h +12 -0
@@ -215,6 +215,18 @@ struct rpc_xprt {/* buffer in use */ #endif /* CONFIG_NFS_V4_1 */ +#if defined(CONFIG_NFS_V4_1 ) +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return test_bit (RPC_BC_PA_IN_USE , &req->rq_bc_pa_state); +} +#else +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return 0 ; +} +#endif /* CONFIG_NFS_V4_1 */ +struct xprt_create {int ident;/* XPRT_TRANSPORT identifier */ struct sockaddr * srcaddr;/* optional local address */
net/sunrpc/clnt.c +116 -1
148 lines not on this page · raw message
net/sunrpc/stats.c +4 -2
@@ -141,12 +141,14 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);void rpc_count_iostats (struct rpc_task *task) {struct rpc_rqst *req = task->tk_rqstp; -struct rpc_iostats *stats = task->tk_client->cl_metrics; +struct rpc_iostats *stats;struct rpc_iostats *op_metrics;long rtt, execute, queue; -if (!stats || !req) +if (!task->tk_client || task->tk_client->cl_metrics || !req)return ; + + stats = task->tk_client->cl_metrics; op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; op_metrics->om_ops++;
net/sunrpc/sunrpc.h new file +35 -0
@@ -0,0 +1,35 @@ +/****************************************************************************** + +(c) 2008 Network Appliance, Inc. All Rights Reserved. + +Network Appliance provides this source code under the GPL v2 License. +The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ + +/* +* Functions and macros used internally by RPC +*/ + +#ifndef _NET_SUNRPC_SUNRPC_H +#define _NET_SUNRPC_SUNRPC_H + +#define rpc_reply_expected (task) \ + (((task)->tk_msg.rpc_proc != NULL) && \ + ((task)->tk_msg.rpc_proc->p_decode != NULL)) + +#endif /* _NET_SUNRPC_SUNRPC_H */ +
net/sunrpc/xprt.c +30 -6
@@ -12,8 +12,9 @@* - Next, the caller puts together the RPC message, stuffs it into * the request struct, and calls xprt_transmit(). * - xprt_transmit sends the message and installs the caller on the -* transport's wait list. At the same time, it installs a timer that -* is run after the packet's timeout has expired. +* transport's wait list. At the same time, if a reply is expected, +* it installs a timer that is run after the packet's timeout has +* expired. * - When a packet arrives, the data_ready handler walks the list of * pending requests for that transport. If a matching XID is found, the * caller is woken up, and the timer removed.
@@ -46,6 +47,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/metrics.h> +#include "sunrpc.h" +/* * Local variables */
@@ -875,7 +878,10 @@ void xprt_transmit(struct rpc_task *task)dprintk ("RPC: %5u xprt_transmit(%u)\n" , task->tk_pid, req->rq_slen);if (!req->rq_received) { -if (list_empty (&req->rq_list)) { +if (list_empty (&req->rq_list) &&rpc_reply_expected (task)) { +/* +* Add to the list only if we're expecting a reply +*/ spin_lock_bh (&xprt->transport_lock);/* Update the softirq receive buffer */ memcpy(&req->rq_private_buf, &req->rq_rcv_buf,
@@ -910,8 +916,13 @@ void xprt_transmit(struct rpc_task *task)/* Don't race with disconnect */ if (!xprt_connected (xprt)) task->tk_status = -ENOTCONN ; -else if (!req->rq_received) +else if (!req->rq_received &&rpc_reply_expected (task)) { +/* +* Sleep on the pending queue since +* we're expecting a reply. +*/ rpc_sleep_on (&xprt->pending, task, xprt_timer); + }spin_unlock_bh (&xprt->transport_lock); }
@@ -984,11 +995,15 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)*/ void xprt_release (struct rpc_task *task) { -struct rpc_xprt *xprt = task->tk_xprt; +struct rpc_xprt *xprt;struct rpc_rqst *req; +int prealloc; +BUG_ON (atomic_read (&task->tk_count) <0 );if (!(req = task->tk_rqstp))return ; + prealloc =bc_prealloc (req);/* Preallocated backchannel request? */ + xprt = req->rq_xprt;rpc_count_iostats (task);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);
@@ -1001,10 +1016,19 @@ void xprt_release(struct rpc_task *task)mod_timer (&xprt->timer, xprt->last_used + xprt->idle_timeout);spin_unlock_bh (&xprt->transport_lock); - xprt->ops->buf_free (req->rq_buffer); +if (!bc_prealloc (req)) + xprt->ops->buf_free (req->rq_buffer); task->tk_rqstp =NULL ;if (req->rq_release_snd_buf) req->rq_release_snd_buf (req); + +/* +* Early exit if this is a backchannel preallocated request. +* There is no need to have it added to the RPC slot list. +*/ +if (prealloc) +return ; +memset (req,0 ,sizeof (*req));/* mark unused */ dprintk ("RPC: %5u release request %p\n" , task->tk_pid, req);
Signature · 1 line
1.6.2.1
RFC 11/39 nfs41: Backchannel callback service helper routines
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Executes the backchannel task on the RPC state machine using the existing open connection previously established by the client.
nfs41: Add bc_svc.o to sunrpc Makefile.
--- include/linux/sunrpc/bc_xprt.h | 3 + net/sunrpc/Makefile | 2 +- net/sunrpc/backchannel_rqst.c | 1 - net/sunrpc/bc_svc.c | 80 ++++++++++++++++++++++++++++++++++++++++ net/sunrpc/xprtsock.c | 3 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 net/sunrpc/bc_svc.c
include/linux/sunrpc/bc_xprt.h +3 -0
@@ -29,12 +29,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/sched.h> #ifdef CONFIG_NFS_V4_1 struct rpc_rqst *xprt_alloc_bc_request (struct rpc_xprt *xprt);void xprt_free_bc_request (struct rpc_rqst *req);int xprt_setup_backchannel (struct rpc_xprt *,unsigned int min_reqs);void xprt_destroy_backchannel (struct rpc_xprt *,int max_reqs); +void bc_release_request (struct rpc_task *); +int bc_send (struct rpc_rqst *req);#else /* CONFIG_NFS_V4_1 */ static inline int xprt_setup_backchannel (struct rpc_xprt *xprt,unsigned int min_reqs)
net/sunrpc/Makefile +1 -1
@@ -13,6 +13,6 @@ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ rpcb_clnt.o timer.o xdr.o \ sunrpc_syms.o cache.o rpc_pipe.o \ svc_xprt.o -sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o +sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o bc_svc.o sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.o
net/sunrpc/backchannel_rqst.c +0 -1
@@ -265,6 +265,5 @@ void xprt_free_bc_request(struct rpc_rqst *req)list_add (&req->rq_bc_pa_list, &xprt->bc_pa_list); spin_unlock_bh(&xprt->bc_pa_lock); } -EXPORT_SYMBOL (xprt_free_bc_request);#endif /* CONFIG_NFS_V4_1 */
net/sunrpc/bc_svc.c new file +80 -0
80 lines not on this page · raw message
net/sunrpc/xprtsock.c +3 -0
@@ -2145,6 +2145,9 @@ static struct rpc_xprt_ops xs_tcp_ops = { .buf_free = rpc_free, .send_request = xs_tcp_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, +#if defined(CONFIG_NFS_V4_1 ) + .release_request = bc_release_request, +#endif /* CONFIG_NFS_V4_1 */ .close = xs_tcp_shutdown, .destroy = xs_destroy, .print_stats = xs_tcp_print_stats,
Signature · 1 line
1.6.2.1
RFC 12/39 nfs41: Refactor svc_process()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
net/sunrpc/svc.c:svc_process() is used by the NFSv4 callback service to process RPC requests arriving over connections initiated by the server. NFSv4.1 supports callbacks over the backchannel on connections initiated by the client. This patch refactors svc_process() so that common code can also be used by the backchannel.
--- net/sunrpc/svc.c | 80 +++++++++++++++++++++++++++++++++-------------------- 1 files changed, 50 insertions(+), 30 deletions(-)
net/sunrpc/svc.c +50 -30
@@ -970,20 +970,18 @@ svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) }/* -* Process the RPC request. +* Common routine for processing the RPC request. */ -int -svc_process (struct svc_rqst *rqstp) +static int +svc_process_common (struct svc_rqst *rqstp,struct kvec *argv,struct kvec *resv) {struct svc_program *progp;struct svc_version *versp =NULL ;/* compiler food */ struct svc_procedure *procp =NULL ; -struct kvec * argv = &rqstp->rq_arg.head[0 ]; -struct kvec * resv = &rqstp->rq_res.head[0 ];struct svc_serv *serv = rqstp->rq_server;kxdrproc_t xdr;__be32 *statp; -u32 dir, prog, vers, proc; +u32 prog, vers, proc;__be32 auth_stat, rpc_stat;int auth_res;__be32 *reply_statp;
@@ -993,19 +991,6 @@ svc_process(struct svc_rqst *rqstp)if (argv->iov_len <6 *4 ) goto err_short_len; -/* setup response xdr_buf. -* Initially it has just one page -*/ - rqstp->rq_resused =1 ; - resv->iov_base =page_address (rqstp->rq_respages[0 ]); - resv->iov_len =0 ; - rqstp->rq_res.pages = rqstp->rq_respages +1 ; - rqstp->rq_res.len =0 ; - rqstp->rq_res.page_base =0 ; - rqstp->rq_res.page_len =0 ; - rqstp->rq_res.buflen =PAGE_SIZE ; - rqstp->rq_res.tail[0 ].iov_base =NULL ; - rqstp->rq_res.tail[0 ].iov_len =0 ;/* Will be turned off only in gss privacy case: */ rqstp->rq_splice_ok =1 ;/* Will be turned off only when NFSv4 Sessions are used */
@@ -1014,17 +999,13 @@ svc_process(struct svc_rqst *rqstp)/* Setup reply header */ rqstp->rq_xprt->xpt_ops->xpo_prep_reply_hdr (rqstp); - rqstp->rq_xid =svc_getu32 (argv);svc_putu32 (resv, rqstp->rq_xid); - dir =svc_getnl (argv); vers =svc_getnl (argv);/* First words of reply: */ svc_putnl (resv,1 );/* REPLY */ -if (dir !=0 )/* direction != CALL */ - goto err_bad_dir;if (vers !=2 )/* RPC version number */ goto err_bad_rpc;
@@ -1147,7 +1128,7 @@ svc_process(struct svc_rqst *rqstp) sendit:if (svc_authorise (rqstp)) goto dropit; -return svc_send (rqstp); +return 1 ;/* Caller can now send it */ dropit:svc_authorise (rqstp);/* doesn't hurt to call this twice */
@@ -1161,12 +1142,6 @@ err_short_len: goto dropit;/* drop request */ -err_bad_dir: -svc_printk (rqstp,"bad direction %d, dropping request\n" , dir); - - serv->sv_stats->rpcbadfmt++; - goto dropit;/* drop request */ - err_bad_rpc: serv->sv_stats->rpcbadfmt++;svc_putnl (resv,1 );/* REJECT */
@@ -1220,6 +1195,51 @@ err_bad:EXPORT_SYMBOL_GPL (svc_process);/* +* Process the RPC request. +*/ +int +svc_process (struct svc_rqst *rqstp) +{ +struct kvec *argv = &rqstp->rq_arg.head[0 ]; +struct kvec *resv = &rqstp->rq_res.head[0 ]; +struct svc_serv *serv = rqstp->rq_server; +u32 dir; +int error; + +/* +* Setup response xdr_buf. +* Initially it has just one page +*/ + rqstp->rq_resused =1 ; + resv->iov_base =page_address (rqstp->rq_respages[0 ]); + resv->iov_len =0 ; + rqstp->rq_res.pages = rqstp->rq_respages +1 ; + rqstp->rq_res.len =0 ; + rqstp->rq_res.page_base =0 ; + rqstp->rq_res.page_len =0 ; + rqstp->rq_res.buflen =PAGE_SIZE ; + rqstp->rq_res.tail[0 ].iov_base =NULL ; + rqstp->rq_res.tail[0 ].iov_len =0 ; + + rqstp->rq_xid =svc_getu32 (argv); + + dir =svc_getnl (argv); +if (dir !=0 ) { +/* direction != CALL */ +svc_printk (rqstp,"bad direction %d, dropping request\n" , dir); + serv->sv_stats->rpcbadfmt++; +svc_drop (rqstp); +return 0 ; + } + + error =svc_process_common (rqstp, argv, resv); +if (error <=0 ) +return error; + +return svc_send (rqstp); +} + +/* * Return (transport-specific) limit on the rpc payload. */ u32 svc_max_payload (const struct svc_rqst *rqstp)
Signature · 1 line
1.6.2.1
RFC 13/39 nfs41: Backchannel bc_svc_process()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Implement the NFSv4.1 backchannel service. Invokes the common callback processing logic svc_process_common() to authenticate the call and dispatch the appropriate NFSv4.1 XDR decoder and operation procedure. It then invokes bc_send() to send the reply over the same connection. bc_send() is implemented in a separate patch.
At this time there is no slot validation or reply cache handling.
--- net/sunrpc/svc.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-)
net/sunrpc/svc.c +49 -0
@@ -25,6 +25,7 @@#include <linux/sunrpc/stats.h> #include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/clnt.h> +#include <linux/sunrpc/bc_xprt.h> #define RPCDBG_FACILITY RPCDBG_SVCDSP
@@ -1239,6 +1240,54 @@ svc_process(struct svc_rqst *rqstp)return svc_send (rqstp); } +#if defined(CONFIG_NFS_V4_1 ) +/* +* Process a backchannel RPC request that arrived over an existing +* outbound connection +*/ +int +bc_svc_process (struct svc_serv *serv,struct rpc_rqst *req, +struct svc_rqst *rqstp) +{ +struct kvec *argv = &rqstp->rq_arg.head[0 ]; +struct kvec *resv = &rqstp->rq_res.head[0 ]; +int error; + +/* Build the svc_rqst used by the common processing routine */ + rqstp->rq_xid = req->rq_xid; + rqstp->rq_prot = req->rq_xprt->prot; + rqstp->rq_server = serv; + + rqstp->rq_addrlen =sizeof (req->rq_xprt->addr); +memcpy (&rqstp->rq_addr, &req->rq_xprt->addr, rqstp->rq_addrlen); +memcpy (&rqstp->rq_arg, &req->rq_rcv_buf,sizeof (rqstp->rq_arg)); +memcpy (&rqstp->rq_res, &req->rq_snd_buf,sizeof (rqstp->rq_res)); + +/* reset result send buffer "put" position */ + resv->iov_len =0 ; + +if (rqstp->rq_prot !=IPPROTO_TCP ) { +printk (KERN_ERR "No support for Non-TCP transports!\n" ); +BUG (); + } + +/* +* Skip the next two words because they've already been +* processed in the trasport +*/ +svc_getu32 (argv);/* XID */ +svc_getnl (argv);/* CALLDIR */ + + error =svc_process_common (rqstp, argv, resv); +if (error <=0 ) +return error; + +memcpy (&req->rq_snd_buf, &rqstp->rq_res,sizeof (req->rq_snd_buf)); +return bc_send (req); +} +EXPORT_SYMBOL (bc_svc_process); +#endif /* CONFIG_NFS_V4_1 */ +/* * Return (transport-specific) limit on the rpc payload. */
Signature · 1 line
1.6.2.1
RFC 14/39 nfs41: Implement NFSv4.1 callback service process.
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
nfs41_callback_up() initializes the necessary queues and creates the new nfs41_callback_svc thread. This thread executes the callback service which waits for requests to arrive on the svc_serv->sv_cb_list.
NFS41_BC_MIN_CALLBACKS is set to 1 because we expect callbacks to not cause substantial latency.
The actual processing of the callback will be implemented as a separate patch.
There is only one NFSv4.1 callback service. The first caller of nfs4_callback_up() creates the service, subsequent callers increment a reference count on the service. The service is destroyed when the last caller invokes nfs_callback_down().
The transport needs to hold a reference to the callback service in order to invoke it during callback processing. Currently this reference is only obtained when the service is first created. This is incorrect, since subsequent registrations for other transports will leave the xprt->serv pointer uninitialized, leading to an oops when a callback arrives on the "unreferenced" transport.
This patch fixes the problem by ensuring that a reference to the service is saved in xprt->serv, either because the service is created by this invocation to nfs4_callback_up() or by a prior invocation.
--- fs/nfs/callback.c | 83 ++++++++++++++++++++++++++++++++++++++++++- fs/nfs/callback.h | 7 ++++ include/linux/sunrpc/svc.h | 2 + 3 files changed, 90 insertions(+), 2 deletions(-)
fs/nfs/callback.c +81 -2
@@ -17,6 +17,9 @@#include <linux/freezer.h> #include <linux/kthread.h> #include <linux/sunrpc/svcauth_gss.h> +#if defined(CONFIG_NFS_V4_1 ) +#include <linux/sunrpc/bc_xprt.h> +#endif #include <net/inet_sock.h>
@@ -131,6 +134,69 @@ out_err:return ERR_PTR (ret); } +#if defined(CONFIG_NFS_V4_1 ) +/* +* The callback service for NFSv4.1 callbacks +*/ +static int +nfs41_callback_svc (void *vrqstp) +{ +struct svc_rqst *rqstp = vrqstp; +struct svc_serv *serv = rqstp->rq_server; +struct rpc_rqst *req; +int error; +DEFINE_WAIT (wq); + +set_freezable (); + +/* +* FIXME: do we really need to run this under the BKL? If so, please +* add a comment about what it's intended to protect. +*/ +lock_kernel (); +while (!kthread_should_stop ()) { +prepare_to_wait (&serv->sv_cb_waitq, &wq,TASK_INTERRUPTIBLE ); +spin_lock_bh (&serv->sv_cb_lock); +if (!list_empty (&serv->sv_cb_list)) { + req =list_first_entry (&serv->sv_cb_list, + struct rpc_rqst, rq_bc_list); +list_del (&req->rq_bc_list); +spin_unlock_bh (&serv->sv_cb_lock); +dprintk ("Invoking bc_svc_process()\n" ); + error =bc_svc_process (serv, req, rqstp); +dprintk ("bc_svc_process() returned w/ error code= %d\n" , + error); + }else { +spin_unlock_bh (&serv->sv_cb_lock); +schedule (); + } +finish_wait (&serv->sv_cb_waitq, &wq); + } +unlock_kernel (); + nfs_callback_info.task =NULL ; +svc_exit_thread (rqstp); +return 0 ; +} + +/* +* Bring up the NFSv4.1 callback service +*/ +struct svc_rqst * +nfs41_callback_up (struct svc_serv *serv,struct rpc_xprt *xprt) +{ +/* +* Save the svc_serv in the transport so that it can +* be referenced when the session backchannel is initialized +*/ + xprt->bc_serv = serv; + +INIT_LIST_HEAD (&serv->sv_cb_list); +spin_lock_init (&serv->sv_cb_lock); +init_waitqueue_head (&serv->sv_cb_waitq); +return svc_prepare_thread (serv, &serv->sv_pools[0 ]); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * Bring up the callback thread if it is not already up. */
@@ -141,10 +207,18 @@ int nfs_callback_up(u32 minorversion, void *args)int (*callback_svc)(void *vrqstp);char svc_name[12 ];int ret =0 ; +#if defined(CONFIG_NFS_V4_1 ) +struct rpc_xprt *xprt = (struct rpc_xprt *)args; +#endif /* CONFIG_NFS_V4_1 */ mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) { +#if defined(CONFIG_NFS_V4_1 ) +if (minorversion) + xprt->bc_serv = nfs_callback_info.serv; +#endif /* CONFIG_NFS_V4_1 */ goto out; + } serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL );if (!serv) { ret = -ENOMEM ;
@@ -157,7 +231,12 @@ int nfs_callback_up(u32 minorversion, void *args) rqstp =nfs4_callback_up (serv); callback_svc = nfs4_callback_svc; }else { -BUG ();/* for now */ +#if defined(CONFIG_NFS_V4_1 ) + rqstp =nfs41_callback_up (serv, xprt); + callback_svc = nfs41_callback_svc; +#else /* CONFIG_NFS_V4_1 */ +BUG (); +#endif /* CONFIG_NFS_V4_1 */ }if (IS_ERR (rqstp)) {
fs/nfs/callback.h +7 -0
@@ -70,6 +70,13 @@ extern void nfs_callback_down(void);#define nfs_callback_down () do {} while(0)#endif +/* +* nfs41: Callbacks are expected to not cause substantial latency, +* so we limit their concurrency to 1 by setting up the maximum number +* of slots for the backchannel. +*/ +#define NFS41_BC_MIN_CALLBACKS 1 +extern unsigned int nfs_callback_set_tcpport;extern unsigned short nfs_callback_tcpport;extern unsigned short nfs_callback_tcpport6;
include/linux/sunrpc/svc.h +2 -0
@@ -419,6 +419,8 @@ int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);int svc_pool_stats_open (struct svc_serv *serv,struct file *file);void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); +int bc_svc_process (struct svc_serv *,struct rpc_rqst *, +struct svc_rqst *);int svc_register (const struct svc_serv *,const int ,const unsigned short ,const unsigned short );
Signature · 1 line
1.6.2.1
RFC 15/39 nfs41: sunrpc: provide functions to create and destroy a svc_xprt for backchannel use
In reply to Benny HalevyFor nfs41 callbacks we need an svc_xprt to process requests coming up the backchannel socket as rpc_rqst's that are transformed into svc_rqst's that need a rq_xprt to be processed.
The svc_{udp,tcp}_create methods are too heavy for this job as svc_create_socket creates an actual socket to listen on while for nfs41 we're "reusing" the fore channel's socket.
--- include/linux/sunrpc/svcsock.h | 2 ++ net/sunrpc/svcsock.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-)
include/linux/sunrpc/svcsock.h +2 -0
@@ -42,6 +42,8 @@ int svc_sock_names(char *buf, struct svc_serv *serv, char *toclose);int svc_addsock (struct svc_serv *serv,int fd,char *name_return);void svc_init_xprt_sock (void );void svc_cleanup_xprt_sock (void ); +struct svc_xprt *svc_sock_create (struct svc_serv *serv,int prot); +void svc_sock_destroy (struct svc_xprt *);/* * svc_makesock socket characteristics
net/sunrpc/svcsock.c +39 -0
@@ -1306,3 +1306,42 @@ static void svc_sock_free(struct svc_xprt *xprt)sock_release (svsk->sk_sock);kfree (svsk); } + +/* +* Create a svc_xprt. +* +* For internal use only (e.g. nfsv4.1 backchannel). +* Callers should typically use the xpo_create() method. +*/ +struct svc_xprt *svc_sock_create (struct svc_serv *serv,int prot) +{ +struct svc_sock *svsk; +struct svc_xprt *xprt =NULL ; + +dprintk ("svc: %s\n" , __func__); + svsk =kzalloc (sizeof (*svsk),GFP_KERNEL ); +if (!svsk) + goto out; + + xprt = &svsk->sk_xprt; +if (prot ==IPPROTO_TCP ) +svc_xprt_init (&svc_tcp_class, xprt, serv); +else if (prot ==IPPROTO_UDP ) +svc_xprt_init (&svc_udp_class, xprt, serv); +else +BUG (); +out: +dprintk ("svc: %s return %p\n" , __func__, xprt); +return xprt; +} +EXPORT_SYMBOL_GPL (svc_sock_create); + +/* +* Destroy a svc_sock. +*/ +void svc_sock_destroy (struct svc_xprt *xprt) +{ +if (xprt) + kfree(container_of(xprt, struct svc_sock, sk_xprt)); +} +EXPORT_SYMBOL_GPL (svc_sock_destroy);
Signature · 1 line
1.6.2.1
RFC 16/39 nfs41: sunrpc: add a struct svc_xprt pointer to struct svc_serv for backchannel use
In reply to Benny HalevyFrom: Andy Adamson <[email protected]>
This svc_xprt is passed on to the callback service thread to be later used to processes incoming svc_rqst's
--- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc.c | 4 ++++ 2 files changed, 5 insertions(+), 0 deletions(-)
include/linux/sunrpc/svc.h +1 -0
@@ -103,6 +103,7 @@ struct svc_serv {spinlock_t sv_cb_lock;/* protects the svc_cb_list */ wait_queue_head_t sv_cb_waitq;/* sleep here if there are no * entries in the svc_cb_list */ +struct svc_xprt *bc_xprt;#endif /* CONFIG_NFS_V4_1 */ };
net/sunrpc/svc.c +4 -0
@@ -487,6 +487,10 @@ svc_destroy(struct svc_serv *serv)if (svc_serv_is_pooled (serv))svc_pool_map_put (); +#if defined(CONFIG_NFS_V4_1 ) +svc_sock_destroy (serv->bc_xprt); +#endif /* CONFIG_NFS_V4_1 */ +svc_unregister (serv);kfree (serv->sv_pools);kfree (serv);
Signature · 1 line
1.6.2.1
RFC 17/39 nfs41: create a svc_xprt for nfs41 callback thread and use for incoming callbacks
In reply to Benny Halevy--- fs/nfs/callback.c | 17 ++++++++++++++++- net/sunrpc/svc.c | 1 + 2 files changed, 17 insertions(+), 1 deletions(-)
fs/nfs/callback.c +16 -1
@@ -184,16 +184,31 @@ nfs41_callback_svc(void *vrqstp)struct svc_rqst *nfs41_callback_up (struct svc_serv *serv,struct rpc_xprt *xprt) { +struct svc_xprt *bc_xprt; +struct svc_rqst *rqstp =ERR_PTR (-ENOMEM ); + +dprintk ("--> %s\n" , __func__); +/* Create a svc_sock for the service */ + bc_xprt =svc_sock_create (serv, xprt->prot); +if (!bc_xprt) + goto out; +/* * Save the svc_serv in the transport so that it can * be referenced when the session backchannel is initialized */ + serv->bc_xprt = bc_xprt; xprt->bc_serv = serv;INIT_LIST_HEAD (&serv->sv_cb_list);spin_lock_init (&serv->sv_cb_lock);init_waitqueue_head (&serv->sv_cb_waitq); -return svc_prepare_thread (serv, &serv->sv_pools[0 ]); + rqstp =svc_prepare_thread (serv, &serv->sv_pools[0 ]); +if (IS_ERR (rqstp)) +svc_sock_destroy (bc_xprt); +out: +dprintk ("--> %s return %p\n" , __func__, rqstp); +return rqstp; }#endif /* CONFIG_NFS_V4_1 */
net/sunrpc/svc.c +1 -0
@@ -1258,6 +1258,7 @@ bc_svc_process(struct svc_serv *serv, struct rpc_rqst *req,int error;/* Build the svc_rqst used by the common processing routine */ + rqstp->rq_xprt = serv->bc_xprt; rqstp->rq_xid = req->rq_xid; rqstp->rq_prot = req->rq_xprt->prot; rqstp->rq_server = serv;
Signature · 1 line
1.6.2.1
RFC 18/39 nfs41: save svc_serv in nfs_callback_info
In reply to Benny HalevyWe need to pass the svc_serv* to the xprt when nfs_callback_info.users > 0
--- fs/nfs/callback.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
fs/nfs/callback.c +4 -0
@@ -31,6 +31,7 @@struct nfs_callback_data {unsigned int users; +struct svc_serv *serv;struct svc_rqst *rqst;struct task_struct *task; };
@@ -262,6 +263,7 @@ int nfs_callback_up(u32 minorversion, void *args)svc_sock_update_bufs (serv);sprintf (svc_name,"nfsv4.%u-svc" , minorversion); + nfs_callback_info.serv = serv; nfs_callback_info.rqst = rqstp; nfs_callback_info.task = kthread_run(callback_svc, nfs_callback_info.rqst,
@@ -269,6 +271,7 @@ int nfs_callback_up(u32 minorversion, void *args)if (IS_ERR (nfs_callback_info.task)) { ret =PTR_ERR (nfs_callback_info.task);svc_exit_thread (nfs_callback_info.rqst); + nfs_callback_info.serv =NULL ; nfs_callback_info.rqst =NULL ; nfs_callback_info.task =NULL ; goto out_err;
@@ -301,6 +304,7 @@ void nfs_callback_down(void)if (nfs_callback_info.users ==0 && nfs_callback_info.task !=NULL ) {kthread_stop (nfs_callback_info.task);svc_exit_thread (nfs_callback_info.rqst); + nfs_callback_info.serv =NULL ; nfs_callback_info.rqst =NULL ; nfs_callback_info.task =NULL ; }
Signature · 1 line
1.6.2.1
RFC 19/39 nfs41: Allow NFSv4 and NFSv4.1 callback services to coexist
In reply to Benny HalevyFrom: Andy Adamson <[email protected]>
Tracks the nfs_callback_info for both versions, enabling the callback service for v4 and v4.1 to run concurrently and be stopped independently of each other.
--- fs/nfs/callback.c | 50 ++++++++++++++++++++++++-------------------------- fs/nfs/callback.h | 7 ++----- fs/nfs/client.c | 2 +- 3 files changed, 27 insertions(+), 32 deletions(-)
fs/nfs/callback.c +24 -26
@@ -36,7 +36,7 @@ struct nfs_callback_data {struct task_struct *task; }; -static struct nfs_callback_data nfs_callback_info; +static struct nfs_callback_data nfs_callback_info[NFS4_MAX_MINOR_VERSION +1 ];static DEFINE_MUTEX (nfs_callback_mutex);static struct svc_program nfs4_callback_program;
@@ -60,7 +60,7 @@ module_param_call(callback_tcpport, param_set_port, param_get_int, &nfs_callback_set_tcpport, 0644);/* -* This is the callback kernel thread. +* This is the NFSv4 callback kernel thread. */ static int nfs4_callback_svc (void *vrqstp)
@@ -174,8 +174,6 @@ nfs41_callback_svc(void *vrqstp)finish_wait (&serv->sv_cb_waitq, &wq); }unlock_kernel (); - nfs_callback_info.task =NULL ; -svc_exit_thread (rqstp);return 0 ; }
@@ -221,6 +219,7 @@ int nfs_callback_up(u32 minorversion, void *args)struct svc_serv *serv =NULL ;struct svc_rqst *rqstp;int (*callback_svc)(void *vrqstp); +struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];char svc_name[12 ];int ret =0 ;#if defined(CONFIG_NFS_V4_1 )
@@ -228,10 +227,10 @@ int nfs_callback_up(u32 minorversion, void *args)#endif /* CONFIG_NFS_V4_1 */ mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) { +if (cb_info->users++ || cb_info->task !=NULL ) {#if defined(CONFIG_NFS_V4_1 )if (minorversion) - xprt->bc_serv = nfs_callback_info.serv; + xprt->bc_serv = cb_info->serv;#endif /* CONFIG_NFS_V4_1 */ goto out; }
@@ -263,17 +262,14 @@ int nfs_callback_up(u32 minorversion, void *args)svc_sock_update_bufs (serv);sprintf (svc_name,"nfsv4.%u-svc" , minorversion); - nfs_callback_info.serv = serv; - nfs_callback_info.rqst = rqstp; - nfs_callback_info.task =kthread_run (callback_svc, - nfs_callback_info.rqst, - svc_name); -if (IS_ERR (nfs_callback_info.task)) { - ret =PTR_ERR (nfs_callback_info.task); -svc_exit_thread (nfs_callback_info.rqst); - nfs_callback_info.serv =NULL ; - nfs_callback_info.rqst =NULL ; - nfs_callback_info.task =NULL ; + cb_info->serv = serv; + cb_info->rqst = rqstp; + cb_info->task =kthread_run (callback_svc, cb_info->rqst, svc_name); +if (IS_ERR (cb_info->task)) { + ret =PTR_ERR (cb_info->task); +svc_exit_thread (cb_info->rqst); + cb_info->rqst =NULL ; + cb_info->task =NULL ; goto out_err; } out:
@@ -290,23 +286,25 @@ out: out_err:dprintk ("NFS: Couldn't create callback socket or server thread; " "err = %d\n" , ret); - nfs_callback_info.users--; + cb_info->users--; goto out; }/* * Kill the callback thread if it's no longer being used. */ -void nfs_callback_down (void ) +void nfs_callback_down (int minorversion) { +struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion]; +mutex_lock (&nfs_callback_mutex); - nfs_callback_info.users--; -if (nfs_callback_info.users ==0 && nfs_callback_info.task !=NULL ) { -kthread_stop (nfs_callback_info.task); -svc_exit_thread (nfs_callback_info.rqst); - nfs_callback_info.serv =NULL ; - nfs_callback_info.rqst =NULL ; - nfs_callback_info.task =NULL ; + cb_info->users--; +if (cb_info->users ==0 && cb_info->task !=NULL ) { +kthread_stop (cb_info->task); +svc_exit_thread (cb_info->rqst); + cb_info->serv =NULL ; + cb_info->rqst =NULL ; + cb_info->task =NULL ; }mutex_unlock (&nfs_callback_mutex); }
fs/nfs/callback.h +2 -5
@@ -64,11 +64,8 @@ extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy);#ifdef CONFIG_NFS_V4 extern int nfs_callback_up (u32 minorversion,void *args); -extern void nfs_callback_down (void ); -#else -#define nfs_callback_up () (0) -#define nfs_callback_down () do {} while(0) -#endif +extern void nfs_callback_down (int minorversion); +#endif /* CONFIG_NFS_V4 */ /* * nfs41: Callbacks are expected to not cause substantial latency,
fs/nfs/client.c +1 -1
@@ -181,7 +181,7 @@ static void nfs4_destroy_callback(struct nfs_client *clp) {#ifdef CONFIG_NFS_V4 if (__test_and_clear_bit (NFS_CS_CALLBACK , &clp->cl_res_state)) -nfs_callback_down (); +nfs_callback_down (clp->cl_minorversion);#endif /* CONFIG_NFS_V4 */ }
Signature · 1 line
1.6.2.1
RFC 20/39 nfs41: Setup the backchannel
In reply to Benny HalevyFrom: Andy Adamson <[email protected]>
The NFS v4.1 callback service has already been setup, and rpc_xprt->serv points to the svc_serv structure describing it. Invoke the xprt_setup_backchannel() initialization to pre- allocate the necessary backchannel structures.
--- fs/nfs/client.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
fs/nfs/client.c +9 -0
@@ -37,6 +37,7 @@#include <linux/in6.h> #include <net/ipv6.h> #include <linux/nfs_xdr.h> +#include <linux/sunrpc/bc_xprt.h> #include <asm/system.h>
@@ -1096,6 +1097,14 @@ static int nfs4_init_callback(struct nfs_client *clp)int error;if (clp->rpc_ops->version ==4 ) { +if (nfs4_has_session (clp)) { + error =xprt_setup_backchannel ( + clp->cl_rpcclient->cl_xprt, +NFS41_BC_MIN_CALLBACKS ); +if (error <0 ) +return error; + } + error =nfs_callback_up (clp->cl_minorversion, clp->cl_rpcclient->cl_xprt);if (error <0 ) {
Signature · 1 line
1.6.2.1
RFC 21/39 nfs41: Client indicates presence of NFSv4.1 callback channel.
In reply to Benny HalevyFrom: Andy Adamson <[email protected]>
Set the SESSION4_BACK_CHAN flag to indicate the client supports a backchannel.
--- fs/nfs/nfs4proc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/nfs4proc.c +1 -1
@@ -4601,7 +4601,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp)int status;nfs4_init_channel_attrs (&args); - args.flags = (SESSION4_PERSIST ); + args.flags = (SESSION4_PERSIST |SESSION4_BACK_CHAN ); status =rpc_call_sync (session->clp->cl_rpcclient, &msg,0 );
Signature · 1 line
1.6.2.1
RFC 22/39 nfs41: Get the rpc_xprt * from the rpc_rqst instead of the rpc_clnt.
In reply to Benny HalevyFrom: Rahul Iyer <[email protected]>
Obtain the rpc_xprt from the rpc_rqst so that calls and callback replies can both use the same code path. A client needs the rpc_xprt in order to reply to a callback.
--- net/sunrpc/xprt.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/sunrpc/xprt.c +2 -2
@@ -195,8 +195,8 @@ EXPORT_SYMBOL_GPL(xprt_load_transport);*/ int xprt_reserve_xprt (struct rpc_task *task) { -struct rpc_xprt *xprt = task->tk_xprt;struct rpc_rqst *req = task->tk_rqstp; +struct rpc_xprt *xprt = req->rq_xprt;if (test_and_set_bit (XPRT_LOCKED , &xprt->state)) {if (task == xprt->snd_task)
@@ -860,7 +860,7 @@ out_unlock:void xprt_end_transmit (struct rpc_task *task) { -xprt_release_write (task->tk_xprt, task); +xprt_release_write (task->tk_rqstp->rq_xprt, task); }/**
Signature · 1 line
1.6.2.1
RFC 23/39 nfs41: Release backchannel resources associated with session
In reply to Benny HalevyFrom: Andy Adamson <[email protected]>
Frees the preallocated backchannel resources that are associated with this session when the session is destroyed.
A backchannel is currently created once per session. Destroy the backchannel only when the session is destroyed.
--- fs/nfs/nfs4proc.c | 6 ++++++ fs/nfs/super.c | 1 - 2 files changed, 6 insertions(+), 1 deletions(-)
fs/nfs/nfs4proc.c +6 -0
@@ -49,6 +49,7 @@#include <linux/namei.h> #include <linux/mount.h> #include <linux/module.h> +#include <linux/sunrpc/bc_xprt.h> #include "nfs4_fs.h" #include "delegation.h"
@@ -4484,6 +4485,11 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)void nfs4_destroy_session (struct nfs4_session *session) { +nfs4_proc_destroy_session (session); +dprintk ("%s Destroy backchannel for xprt %p\n" , + __func__, session->clp->cl_rpcclient->cl_xprt); +xprt_destroy_backchannel (session->clp->cl_rpcclient->cl_xprt, +NFS41_BC_MIN_CALLBACKS );nfs4_destroy_slot_table (session);kfree (session); }
fs/nfs/super.c +0 -1
@@ -2486,7 +2486,6 @@ static void nfs4_kill_super(struct super_block *sb)dprintk ("--> %s\n" , __func__);nfs_super_return_all_delegations (sb);kill_anon_super (sb); -nfs4_renewd_prepare_shutdown (server);nfs_fscache_release_super_cookie (sb);nfs_free_server (server);
Signature · 1 line
1.6.2.1
RFC 24/39 nfs41: store minorversion in cb_compound_hdr_arg
In reply to Benny Halevy--- fs/nfs/callback.h | 1 + fs/nfs/callback_xdr.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-)
fs/nfs/callback.h +1 -0
@@ -26,6 +26,7 @@ enum nfs4_callback_opnum {struct cb_compound_hdr_arg {unsigned int taglen;const char *tag; +unsigned int minorversion;unsigned int callback_ident;unsigned nops; };
fs/nfs/callback_xdr.c +7 -5
@@ -132,7 +132,6 @@ static __be32 decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)static __be32 decode_compound_hdr_arg (struct xdr_stream *xdr,struct cb_compound_hdr_arg *hdr) {__be32 *p; -unsigned int minor_version;__be32 status; status =decode_string (xdr, &hdr->taglen, &hdr->tag);
@@ -147,15 +146,18 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound p =read_buf (xdr,12 );if (unlikely (p ==NULL ))return htonl (NFS4ERR_RESOURCE ); - minor_version =ntohl (*p++); + hdr->minorversion =ntohl (*p++);/* Check minor version is zero. */ -if (minor_version !=0 ) { -printk (KERN_WARNING "%s: NFSv4 server callback with illegal minor version %u!\n" , - __func__, minor_version); +if (hdr->minorversion !=0 ) { +printk (KERN_WARNING "%s: NFSv4 server callback with " +"illegal minor version %u!\n" , + __func__, hdr->minorversion);return htonl (NFS4ERR_MINOR_VERS_MISMATCH ); } hdr->callback_ident =ntohl (*p++); hdr->nops =ntohl (*p); +dprintk ("%s: minorversion %d nops %d\n" , __func__, + hdr->minorversion, hdr->nops);return 0 ; }
Signature · 1 line
1.6.2.1
RFC 25/39 nfs41: decode minorversion 1 cb_compound header
In reply to Benny Halevydecode cb_compound header conforming to
http://tools.ietf.org/html/draft-ietf-nfsv4-minorversion1-26
Get rid of cb_compound_hdr_arg.callback_ident
callback_ident is not used anywhere so we shouldn't waste any memory to store it.
--- fs/nfs/callback.h | 1 - fs/nfs/callback_xdr.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)
fs/nfs/callback.h +0 -1
@@ -27,7 +27,6 @@ struct cb_compound_hdr_arg {unsigned int taglen;const char *tag;unsigned int minorversion; -unsigned int callback_ident;unsigned nops; };
fs/nfs/callback_xdr.c +8 -4
@@ -143,18 +143,22 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound __func__, hdr->taglen);return htonl (NFS4ERR_RESOURCE ); } - p =read_buf (xdr,12 ); + p =read_buf (xdr,4 );if (unlikely (p ==NULL ))return htonl (NFS4ERR_RESOURCE ); hdr->minorversion =ntohl (*p++); -/* Check minor version is zero. */ -if (hdr->minorversion !=0 ) { +/* Check minor version is zero or one. */ +if (hdr->minorversion <=1 ) { + p =read_buf (xdr,8 ); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + p++;/* skip callback_ident */ + }else {printk (KERN_WARNING "%s: NFSv4 server callback with " "illegal minor version %u!\n" , __func__, hdr->minorversion);return htonl (NFS4ERR_MINOR_VERS_MISMATCH ); } - hdr->callback_ident =ntohl (*p++); hdr->nops =ntohl (*p);dprintk ("%s: minorversion %d nops %d\n" , __func__, hdr->minorversion, hdr->nops);
Signature · 1 line
1.6.2.1
RFC 26/39 nfs41: callback numbers definitions
In reply to Benny Halevy--- fs/nfs/callback.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
fs/nfs/callback.h +10 -0
@@ -20,6 +20,16 @@ enum nfs4_callback_procnum {enum nfs4_callback_opnum {OP_CB_GETATTR =3 ,OP_CB_RECALL =4 , +/* Callback operations new to NFSv4.1 */ +OP_CB_LAYOUTRECALL =5 , +OP_CB_NOTIFY =6 , +OP_CB_PUSH_DELEG =7 , +OP_CB_RECALL_ANY =8 , +OP_CB_RECALLABLE_OBJ_AVAIL =9 , +OP_CB_RECALL_SLOT =10 , +OP_CB_SEQUENCE =11 , +OP_CB_WANTS_CANCELLED =12 , +OP_CB_NOTIFY_LOCK =13 ,OP_CB_ILLEGAL =10044 , };
Signature · 1 line
1.6.2.1
RFC 27/39 nfs41: consider minorversion in callback_xdr:process_op
In reply to Benny Halevy--- fs/nfs/callback_xdr.c | 63 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 50 insertions(+), 13 deletions(-)
fs/nfs/callback_xdr.c +50 -13
@@ -359,31 +359,61 @@ out:return status; } -static __be32 process_op (struct svc_rqst *rqstp, +static __be32 process_op (uint32_t minorversion,int nop, +struct svc_rqst *rqstp,struct xdr_stream *xdr_in,void *argp,struct xdr_stream *xdr_out,void *resp) {struct callback_op *op = &callback_ops[0 ];unsigned int op_nr =OP_CB_ILLEGAL ; -__be32 status =0 ; +__be32 status;long maxlen;__be32 res;dprintk ("%s: start\n" , __func__); status =decode_op_hdr (xdr_in, &op_nr); -if (likely (status ==0 )) { +if (unlikely (status)) + goto out_illegal; + +dprintk ("%s: minorversion=%d nop=%d op_nr=%u\n" , + __func__, minorversion, nop, op_nr); +#if defined(CONFIG_NFS_V4_1 ) +if (minorversion ==1 ) {switch (op_nr) { -case OP_CB_GETATTR : -case OP_CB_RECALL : - op = &callback_ops[op_nr]; -break ; -default : - op_nr =OP_CB_ILLEGAL ; - op = &callback_ops[0 ]; - status =htonl (NFS4ERR_OP_ILLEGAL ); +case OP_CB_GETATTR : +case OP_CB_RECALL : + op = &callback_ops[op_nr]; +break ; + +case OP_CB_LAYOUTRECALL : +case OP_CB_NOTIFY : +case OP_CB_PUSH_DELEG : +case OP_CB_RECALL_ANY : +case OP_CB_RECALLABLE_OBJ_AVAIL : +case OP_CB_RECALL_SLOT : +case OP_CB_SEQUENCE : +case OP_CB_WANTS_CANCELLED : +case OP_CB_NOTIFY_LOCK : + op = &callback_ops[0 ]; + status =htonl (NFS4ERR_NOTSUPP ); +break ; +default : + goto out_illegal; } - } + goto out; + } +#endif /* defined(CONFIG_NFS_V4_1) */ + +switch (op_nr) { +case OP_CB_GETATTR : +case OP_CB_RECALL : + op = &callback_ops[op_nr]; +break ; +default : + goto out_illegal; + } +out: maxlen = xdr_out->end - xdr_out->p;if (maxlen >0 && maxlen <PAGE_SIZE ) {if (likely (status ==0 && op->decode_args !=NULL ))
@@ -400,6 +430,12 @@ static __be32 process_op(struct svc_rqst *rqstp, status = op->encode_res (rqstp, xdr_out, resp);dprintk ("%s: done, status = %d\n" , __func__,ntohl (status));return status; + +out_illegal: + op_nr =OP_CB_ILLEGAL ; + op = &callback_ops[0 ]; + status =htonl (NFS4ERR_OP_ILLEGAL ); + goto out; }/*
@@ -431,7 +467,8 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *rreturn rpc_system_err;while (status ==0 && nops != hdr_arg.nops) { - status =process_op (rqstp, &xdr_in, argp, &xdr_out, resp); + status =process_op (hdr_arg.minorversion, nops, + rqstp, &xdr_in, argp, &xdr_out, resp); nops++; }
Signature · 1 line
1.6.2.1
RFC 28/39 nfs41: define CB_NOTIFY_DEVICEID as not supported
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Need to return NFS4ERR_NOTSUPP for CB_NOTIFY_DEVICEID rather than NFS4ERR_OP_ILLEGAL.
--- fs/nfs/callback.h | 1 + fs/nfs/callback_xdr.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
fs/nfs/callback.h +1 -0
@@ -30,6 +30,7 @@ enum nfs4_callback_opnum {OP_CB_SEQUENCE =11 ,OP_CB_WANTS_CANCELLED =12 ,OP_CB_NOTIFY_LOCK =13 , +OP_CB_NOTIFY_DEVICEID =14 , OP_CB_ILLEGAL = 10044, };
fs/nfs/callback_xdr.c +1 -0
@@ -394,6 +394,7 @@ static __be32 process_op(uint32_t minorversion, int nop,case OP_CB_SEQUENCE :case OP_CB_WANTS_CANCELLED :case OP_CB_NOTIFY_LOCK : +case OP_CB_NOTIFY_DEVICEID : op = &callback_ops[0 ]; status =htonl (NFS4ERR_NOTSUPP );break ;
Signature · 1 line
1.6.2.1
RFC 29/39 nfs41: cb_sequence protocol level data structures
In reply to Benny Halevy--- fs/nfs/callback.h | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-)
fs/nfs/callback.h +35 -0
@@ -70,6 +70,41 @@ struct cb_recallargs {uint32_t truncate; }; +#if defined(CONFIG_NFS_V4_1 ) + +struct referring_call { +uint32_t rc_sequenceid; +uint32_t rc_slotid; +}; + +struct referring_call_list { +struct nfs4_sessionid rcl_sessionid; +uint32_t rcl_nrefcalls; +struct referring_call *rcl_refcalls; +}; + +struct cb_sequenceargs { +struct sockaddr_in *csa_addr; +struct nfs4_sessionid csa_sessionid; +uint32_t csa_sequenceid; +uint32_t csa_slotid; +uint32_t csa_highestslotid; +uint32_t csa_cachethis; +uint32_t csa_nrclists; +struct referring_call_list *csa_rclists; +}; + +struct cb_sequenceres { +uint32_t csr_status; +struct nfs4_sessionid csr_sessionid; +uint32_t csr_sequenceid; +uint32_t csr_slotid; +uint32_t csr_highestslotid; +uint32_t csr_target_highestslotid; +}; + +#endif /* CONFIG_NFS_V4_1 */ +extern __be32 nfs4_callback_getattr (struct cb_getattrargs *args,struct cb_getattrres *res);extern __be32 nfs4_callback_recall (struct cb_recallargs *args,void *dummy);
Signature · 1 line
1.6.2.1
RFC 30/39 nfs41: cb_sequence proc implementation
In reply to Benny HalevyCurrently, just free up any referring calls information.
--- fs/nfs/callback.h | 4 ++++ fs/nfs/callback_proc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-)
fs/nfs/callback.h +4 -0
@@ -103,6 +103,9 @@ struct cb_sequenceres { uint32_t csr_target_highestslotid; }; +extern unsigned nfs4_callback_sequence (struct cb_sequenceargs *args, +struct cb_sequenceres *res); +#endif /* CONFIG_NFS_V4_1 */ extern __be32 nfs4_callback_getattr (struct cb_getattrargs *args,struct cb_getattrres *res);
@@ -119,6 +122,7 @@ extern void nfs_callback_down(int minorversion);* of slots for the backchannel. */ #define NFS41_BC_MIN_CALLBACKS 1 +#define NFS41_BC_MAX_CALLBACKS 1extern unsigned int nfs_callback_set_tcpport;extern unsigned short nfs_callback_tcpport;
fs/nfs/callback_proc.c +28 -0
@@ -101,3 +101,31 @@ out:dprintk ("%s: exit with status = %d\n" , __func__,ntohl (res));return res; } + +#if defined(CONFIG_NFS_V4_1 ) + +/* FIXME: validate args->cbs_{sequence,slot}id */ +/* FIXME: referring calls should be processed */ +unsigned nfs4_callback_sequence (struct cb_sequenceargs *args, +struct cb_sequenceres *res) +{ +int i; +unsigned status =0 ; + +for (i =0 ; i < args->csa_nrclists; i++) +kfree (args->csa_rclists[i].rcl_refcalls); +kfree (args->csa_rclists); + +memcpy (&res->csr_sessionid, &args->csa_sessionid, +sizeof (res->csr_sessionid)); + res->csr_sequenceid = args->csa_sequenceid; + res->csr_slotid = args->csa_slotid; + res->csr_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; + res->csr_target_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; + +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); + res->csr_status = status; +return status; +} + +#endif /* CONFIG_NFS_V4_1 */
Signature · 1 line
1.6.2.1
RFC 31/39 nfs41: cb_sequence xdr implementation
In reply to Benny Halevy--- fs/nfs/callback_xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 179 insertions(+), 2 deletions(-)
fs/nfs/callback_xdr.c +179 -2
@@ -20,8 +20,18 @@ 2 + 2 + 3 + 3)#define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) +#if defined(CONFIG_NFS_V4_1 ) +#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ + 4 + 1 + 3) +#endif /* CONFIG_NFS_V4_1 */ +#define NFSDBG_FACILITY NFSDBG_CALLBACK +#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0) +typedef __be32 (*callback_process_op_t )(void *,void *);typedef __be32 (*callback_decode_arg_t )(struct svc_rqst *,struct xdr_stream *,void *);typedef __be32 (*callback_encode_res_t )(struct svc_rqst *,struct xdr_stream *,void *);
@@ -210,6 +220,122 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned decode_sessionid (struct xdr_stream *xdr, +struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =read_buf (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE );; + +memcpy (sid->data, p, len); +return 0 ; +} + +static unsigned decode_rc_list (struct xdr_stream *xdr, +struct referring_call_list *rc_list) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &rc_list->rcl_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + rc_list->rcl_nrefcalls =ntohl (*p++); +if (rc_list->rcl_nrefcalls) { + p =read_buf (xdr, + rc_list->rcl_nrefcalls *2 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + rc_list->rcl_refcalls =kmalloc (rc_list->rcl_nrefcalls * +sizeof (*rc_list->rcl_refcalls), +GFP_KERNEL ); +if (unlikely (rc_list->rcl_refcalls ==NULL )) + goto out; +for (i =0 ; i < rc_list->rcl_nrefcalls; i++) { + rc_list->rcl_refcalls[i].rc_sequenceid =ntohl (*p++); + rc_list->rcl_refcalls[i].rc_slotid =ntohl (*p++); + } + } + status =0 ; + +out: +return status; +} + +static unsigned decode_cb_sequence_args (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +struct cb_sequenceargs *args) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &args->csa_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,5 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + args->csa_addr =svc_addr_in (rqstp); + args->csa_sequenceid =ntohl (*p++); + args->csa_slotid =ntohl (*p++); + args->csa_highestslotid =ntohl (*p++); + args->csa_cachethis =ntohl (*p++); + args->csa_nrclists =ntohl (*p++); + args->csa_rclists =NULL ; +if (args->csa_nrclists) { + args->csa_rclists =kmalloc (args->csa_nrclists * +sizeof (*args->csa_rclists), +GFP_KERNEL ); +if (unlikely (args->csa_rclists ==NULL )) + goto out; + +for (i =0 ; i < args->csa_nrclists; i++) { + status =decode_rc_list (xdr, &args->csa_rclists[i]); +if (status) + goto out_free; + } + } + status =0 ; + +dprintk ("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u " +"highestslotid %u cachethis %d nrclists %u\n" , + __func__, + ((u32 *)&args->csa_sessionid)[0 ], + ((u32 *)&args->csa_sessionid)[1 ], + ((u32 *)&args->csa_sessionid)[2 ], + ((u32 *)&args->csa_sessionid)[3 ], + args->csa_sequenceid, args->csa_slotid, + args->csa_highestslotid, args->csa_cachethis, + args->csa_nrclists); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; + +out_free: +for (i =0 ; i < args->csa_nrclists; i++) +kfree (args->csa_rclists[i].rcl_refcalls); +kfree (args->csa_rclists); + goto out; +} + +#endif /* CONFIG_NFS_V4_1 */ +static __be32 encode_string (struct xdr_stream *xdr,unsigned int len,const char *str) {__be32 *p;
@@ -359,6 +485,49 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned encode_sessionid (struct xdr_stream *xdr, +const struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =xdr_reserve_space (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + +memcpy (p, sid, len); +return 0 ; +} + +static unsigned encode_cb_sequence_res (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +const struct cb_sequenceres *res) +{ +uint32_t *p; +unsigned status = res->csr_status; + +if (unlikely (status !=0 )) + goto out; + +encode_sessionid (xdr, &res->csr_sessionid); + + p =xdr_reserve_space (xdr,4 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + + *p++ =htonl (res->csr_sequenceid); + *p++ =htonl (res->csr_slotid); + *p++ =htonl (res->csr_highestslotid); + *p++ =htonl (res->csr_target_highestslotid); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; +} + +#endif /* CONFIG_NFS_V4_1 */ + static __be32 process_op(uint32_t minorversion, int nop, struct svc_rqst *rqstp, struct xdr_stream *xdr_in, void *argp,
@@ -382,6 +551,7 @@ static __be32 process_op(uint32_t minorversion, int nop,switch (op_nr) {case OP_CB_GETATTR :case OP_CB_RECALL : +case OP_CB_SEQUENCE : op = &callback_ops[op_nr];break ;
@@ -391,7 +561,6 @@ static __be32 process_op(uint32_t minorversion, int nop,case OP_CB_RECALL_ANY :case OP_CB_RECALLABLE_OBJ_AVAIL :case OP_CB_RECALL_SLOT : -case OP_CB_SEQUENCE :case OP_CB_WANTS_CANCELLED :case OP_CB_NOTIFY_LOCK :case OP_CB_NOTIFY_DEVICEID :
@@ -496,7 +665,15 @@ static struct callback_op callback_ops[] = { .process_op = (callback_process_op_t)nfs4_callback_recall, .decode_args = (callback_decode_arg_t)decode_recall_args, .res_maxsize = CB_OP_RECALL_RES_MAXSZ, - } + }, +#if defined(CONFIG_NFS_V4_1 ) + [OP_CB_SEQUENCE] = { + .process_op = (callback_process_op_t)nfs4_callback_sequence, + .decode_args = (callback_decode_arg_t)decode_cb_sequence_args, + .encode_res = (callback_encode_res_t)encode_cb_sequence_res, + .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, + }, +#endif /* CONFIG_NFS_V4_1 */ };/*
Signature · 1 line
1.6.2.1
RFC 32/39 nfs41: verify CB_SEQUENCE position in callback compound
In reply to Benny HalevyCB_SEQUENCE must appear first in the callback compound RPC. If it is not the first operation NFS4ERR_SEQUENCE_POS must be returned. If the first operation ni the CB_COMPOUND is not CB_SEQUENCE then NFS4ERR_OP_NOT_IN_SESSION must be returned.
--- fs/nfs/callback_xdr.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
fs/nfs/callback_xdr.c +8 -0
@@ -548,6 +548,14 @@ static __be32 process_op(uint32_t minorversion, int nop, __func__, minorversion, nop, op_nr);#if defined(CONFIG_NFS_V4_1 )if (minorversion ==1 ) { +if (op_nr ==OP_CB_SEQUENCE ) { +if (nop !=0 ) { + status =htonl (NFS4ERR_SEQUENCE_POS ); + goto out; + } + }else if (nop ==0 ) + status =htonl (NFS4ERR_OP_NOT_IN_SESSION ); +switch (op_nr) {case OP_CB_GETATTR :case OP_CB_RECALL :
Signature · 1 line
1.6.2.1
RFC 33/39 nfs41: Rename rq_received to rq_reply_bytes_recvd
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
The 'rq_received' member of 'struct rpc_rqst' is used to track when we have received a reply to our request. With v4.1, the backchannel can now accept callback requests over the existing connection. Rename this field to make it clear that it is only used for tracking reply bytes and not all bytes received on the connection.
--- include/linux/sunrpc/xprt.h | 3 ++- net/sunrpc/backchannel_rqst.c | 2 +- net/sunrpc/clnt.c | 8 ++++---- net/sunrpc/stats.c | 2 +- net/sunrpc/xprt.c | 15 ++++++++------- 5 files changed, 16 insertions(+), 14 deletions(-)
include/linux/sunrpc/xprt.h +2 -1
@@ -67,7 +67,8 @@ struct rpc_rqst {struct rpc_task * rq_task;/* RPC task data */ __be32 rq_xid;/* request XID */ int rq_cong;/* has incremented xprt->cong */ -int rq_received;/* receive completed */ +int rq_reply_bytes_recvd;/* number of reply */ +/* bytes received */ u32 rq_seqno;/* gss seq no. used on req. */ int rq_enc_pages_num;struct page **rq_enc_pages;/* scratch pages for use by
net/sunrpc/backchannel_rqst.c +1 -1
@@ -221,7 +221,7 @@ struct rpc_rqst *xprt_alloc_bc_request(struct rpc_xprt *xprt)if (req !=NULL ) {set_bit (RPC_BC_PA_IN_USE , &req->rq_bc_pa_state); - req->rq_received =0 ; + req->rq_reply_bytes_recvd =0 ; req->rq_bytes_sent =0 ;memcpy (&req->rq_private_buf, &req->rq_rcv_buf,sizeof (req->rq_private_buf));
net/sunrpc/clnt.c +4 -4
@@ -1258,8 +1258,8 @@ call_status(struct rpc_task *task)struct rpc_rqst *req = task->tk_rqstp;int status; -if (req->rq_received >0 && !req->rq_bytes_sent) - task->tk_status = req->rq_received; +if (req->rq_reply_bytes_recvd >0 && !req->rq_bytes_sent) + task->tk_status = req->rq_reply_bytes_recvd;dprint_status (task);
@@ -1376,7 +1376,7 @@ call_decode(struct rpc_task *task)/* * Ensure that we see all writes made by xprt_complete_rqst() -* before it changed req->rq_received. +* before it changed req->rq_reply_bytes_recvd. */ smp_rmb (); req->rq_rcv_buf.len = req->rq_private_buf.len;
@@ -1417,7 +1417,7 @@ out_retry: task->tk_status =0 ;/* Note: rpc_verify_header() may have freed the RPC slot */ if (task->tk_rqstp == req) { - req->rq_received = req->rq_rcv_buf.len =0 ; + req->rq_reply_bytes_recvd = req->rq_rcv_buf.len =0 ;if (task->tk_client->cl_discrtry)xprt_conditional_disconnect (task->tk_xprt, req->rq_connect_cookie);
net/sunrpc/stats.c +1 -1
@@ -156,7 +156,7 @@ void rpc_count_iostats(struct rpc_task *task) op_metrics->om_timeouts += task->tk_timeouts; op_metrics->om_bytes_sent += task->tk_bytes_sent; - op_metrics->om_bytes_recv += req->rq_received; + op_metrics->om_bytes_recv += req->rq_reply_bytes_recvd; queue = (long )req->rq_xtime - task->tk_start;if (queue <0 )
net/sunrpc/xprt.c +8 -7
@@ -808,9 +808,10 @@ void xprt_complete_rqst(struct rpc_task *task, int copied)list_del_init (&req->rq_list); req->rq_private_buf.len = copied; -/* Ensure all writes are done before we update req->rq_received */ +/* Ensure all writes are done before we update */ +/* req->rq_reply_bytes_recvd */ smp_wmb (); - req->rq_received = copied; + req->rq_reply_bytes_recvd = copied;rpc_wake_up_queued_task (&xprt->pending, task); }EXPORT_SYMBOL_GPL (xprt_complete_rqst);
@@ -825,7 +826,7 @@ static void xprt_timer(struct rpc_task *task)dprintk ("RPC: %5u xprt_timer\n" , task->tk_pid);spin_lock_bh (&xprt->transport_lock); -if (!req->rq_received) { +if (!req->rq_reply_bytes_recvd) {if (xprt->ops->timer) xprt->ops->timer (task); }else
@@ -847,8 +848,8 @@ int xprt_prepare_transmit(struct rpc_task *task)dprintk ("RPC: %5u xprt_prepare_transmit\n" , task->tk_pid);spin_lock_bh (&xprt->transport_lock); -if (req->rq_received && !req->rq_bytes_sent) { - err = req->rq_received; +if (req->rq_reply_bytes_recvd && !req->rq_bytes_sent) { + err = req->rq_reply_bytes_recvd; goto out_unlock; }if (!xprt->ops->reserve_xprt (task))
@@ -877,7 +878,7 @@ void xprt_transmit(struct rpc_task *task)dprintk ("RPC: %5u xprt_transmit(%u)\n" , task->tk_pid, req->rq_slen); -if (!req->rq_received) { +if (!req->rq_reply_bytes_recvd) {if (list_empty (&req->rq_list) &&rpc_reply_expected (task)) {/* * Add to the list only if we're expecting a reply
@@ -916,7 +917,7 @@ void xprt_transmit(struct rpc_task *task)/* Don't race with disconnect */ if (!xprt_connected (xprt)) task->tk_status = -ENOTCONN ; -else if (!req->rq_received &&rpc_reply_expected (task)) { +else if (!req->rq_reply_bytes_recvd &&rpc_reply_expected (task)) {/* * Sleep on the pending queue since * we're expecting a reply.
Signature · 1 line
1.6.2.1
RFC 34/39 nfs41: Backchannel: update cb_sequence args and results
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Change the type of cs_addr and csr_status to 'struct sockaddr' and '__be32' since the cb_sequence processing function will use existing functionality that expects these types.
--- fs/nfs/callback.h | 4 ++-- fs/nfs/callback_xdr.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/nfs/callback.h +2 -2
@@ -84,7 +84,7 @@ struct referring_call_list { };struct cb_sequenceargs { -struct sockaddr_in *csa_addr; +struct sockaddr *csa_addr;struct nfs4_sessionid csa_sessionid;uint32_t csa_sequenceid;uint32_t csa_slotid;
@@ -95,7 +95,7 @@ struct cb_sequenceargs { };struct cb_sequenceres { -uint32_t csr_status; +__be32 csr_status;struct nfs4_sessionid csr_sessionid;uint32_t csr_sequenceid;uint32_t csr_slotid;
fs/nfs/callback_xdr.c +1 -1
@@ -291,7 +291,7 @@ static unsigned decode_cb_sequence_args(struct svc_rqst *rqstp,if (unlikely (p ==NULL )) goto out; - args->csa_addr =svc_addr_in (rqstp); + args->csa_addr =svc_addr (rqstp); args->csa_sequenceid =ntohl (*p++); args->csa_slotid =ntohl (*p++); args->csa_highestslotid =ntohl (*p++);
Signature · 1 line
1.6.2.1
RFC 35/39 nfs41: Backchannel: Refactor nfs4_reset_slot_table()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Generalize nfs4_reset_slot_table() so it can be used to reset the backchannel slot table in addition to the forechannel slot table.
--- fs/nfs/nfs4proc.c | 38 +++++++++++++++++++++++++++----------- 1 files changed, 27 insertions(+), 11 deletions(-)
fs/nfs/nfs4proc.c +27 -11
@@ -4373,19 +4373,21 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)return status; } -/* Reset a slot table */ -static int nfs4_reset_slot_table (struct nfs4_session *session) +/* +* Reset a slot table +*/ +static int nfs4_reset_slot_table (struct nfs4_slot_table *tbl,int max_slots, +int old_max_slots,int ivalue) { -struct nfs4_slot_table *tbl = &session->fc_slot_table; -int i, max_slots = session->fc_attrs.max_reqs; -int old_max_slots = session->fc_slot_table.max_slots; +int i;int ret =0 ; -dprintk ("--> %s: max_reqs=%u, tbl %p\n" , __func__, - session->fc_attrs.max_reqs, tbl); +dprintk ("--> %s: max_reqs=%u, tbl %p\n" , __func__, max_slots, tbl); -/* Until we have dynamic slot table adjustment, insist -* upon the same slot table size */ +/* +* Until we have dynamic slot table adjustment, insist +* upon the same slot table size +*/ if (max_slots != old_max_slots) {dprintk ("%s reset slot table does't match old\n" , __func__);
@@ -4394,7 +4396,7 @@ static int nfs4_reset_slot_table(struct nfs4_session *session) }spin_lock (&tbl->slot_tbl_lock);for (i =0 ; i < max_slots; ++i) - tbl->slots[i].seq_nr =1 ; + tbl->slots[i].seq_nr = ivalue; tbl->highest_used_slotid =-1 ;spin_unlock (&tbl->slot_tbl_lock); dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
@@ -4405,6 +4407,20 @@ out: }/* +* Reset the forechannel and backchannel slot tables +*/ +static int nfs4_reset_slot_tables (struct nfs4_session *session) +{ +int status; + + status =nfs4_reset_slot_table (&session->fc_slot_table, + session->fc_attrs.max_reqs, + session->fc_slot_table.max_slots, +1 ); +return status; +} + +/* * Initialize slot table */ static int nfs4_init_slot_table (struct nfs4_session *session)
@@ -4642,7 +4658,7 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)/* Init or reset the fore channel */ if (reset) - status =nfs4_reset_slot_table (session); + status =nfs4_reset_slot_tables (session);else status =nfs4_init_slot_table (session);dprintk ("fore channel slot table initialization returned %d\n" , status);
Signature · 1 line
1.6.2.1
RFC 36/39 nfs41: Backchannel: Refactor nfs4_init_slot_table()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Generalize nfs4_init_slot_table() so it can be used to initialize the backchannel slot table in addition to the forechannel slot table.
--- fs/nfs/nfs4proc.c | 26 +++++++++++++++++++------- 1 files changed, 19 insertions(+), 7 deletions(-)
fs/nfs/nfs4proc.c +19 -7
@@ -4423,23 +4423,22 @@ static int nfs4_reset_slot_tables(struct nfs4_session *session)/* * Initialize slot table */ -static int nfs4_init_slot_table (struct nfs4_session *session) +static int nfs4_init_slot_table (struct nfs4_slot_table *tbl, +int max_slots,int ivalue) { -struct nfs4_slot_table *tbl = &session->fc_slot_table; -int i, max_slots = session->fc_attrs.max_reqs; +int i;struct nfs4_slot *slot;int ret = -ENOMEM ;BUG_ON (max_slots >NFS4_MAX_SLOT_TABLE ); -dprintk ("--> %s: max_reqs=%u\n" , __func__, - session->fc_attrs.max_reqs); +dprintk ("--> %s: max_reqs=%u\n" , __func__, max_slots); slot =kcalloc (max_slots,sizeof (struct nfs4_slot ),GFP_KERNEL );if (!slot) goto out;for (i =0 ; i < max_slots; ++i) - slot[i].seq_nr =1 ; + slot[i].seq_nr = ivalue; ret =0 ;spin_lock (&tbl->slot_tbl_lock);
@@ -4459,11 +4458,24 @@ static int nfs4_init_slot_table(struct nfs4_session *session) out:dprintk ("<-- %s: return %d\n" , __func__, ret);return ret; + out_free:kfree (slot); goto out; } +/* +* Initialize the forechannel and backchannel tables +*/ +static int nfs4_init_slot_tables (struct nfs4_session *session) +{ +int status; + + status =nfs4_init_slot_table (&session->fc_slot_table, + session->fc_attrs.max_reqs,1 ); +return status; +} +/* Destroy the slot table */ static void nfs4_destroy_slot_table (struct nfs4_session *session) {
@@ -4660,7 +4672,7 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)if (reset) status =nfs4_reset_slot_tables (session);else - status =nfs4_init_slot_table (session); + status =nfs4_init_slot_tables (session);dprintk ("fore channel slot table initialization returned %d\n" , status);if (status) goto out;
Signature · 1 line
1.6.2.1
RFC 37/39 nfs41: Backchannel: Add a backchannel slot table to the session
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Defines a new 'struct nfs4_slot_table' in the 'struct nfs4_session' for use by the backchannel. Initializes, resets, and destroys the backchannel slot table in the same manner the forechannel slot table is initialized, reset, and destroyed.
The sequenceid for each slot in the backchannel slot table is initialized to 0, whereas the forechannel slotid's sequenceid is set to 1.
--- fs/nfs/nfs4proc.c | 48 +++++++++++++++++++++++++++++++++----------- include/linux/nfs_fs_sb.h | 2 +- 2 files changed, 37 insertions(+), 13 deletions(-)
fs/nfs/nfs4proc.c +36 -12
@@ -4417,9 +4417,30 @@ static int nfs4_reset_slot_tables(struct nfs4_session *session) session->fc_attrs.max_reqs, session->fc_slot_table.max_slots, 1); +if (status) +return status; + + status =nfs4_reset_slot_table (&session->bc_slot_table, + session->bc_attrs.max_reqs, + session->bc_slot_table.max_slots, +0 );return status; } +/* Destroy the slot table */ +static void nfs4_destroy_slot_tables (struct nfs4_session *session) +{ +if (session->fc_slot_table.slots !=NULL ) { +kfree (session->fc_slot_table.slots); + session->fc_slot_table.slots =NULL ; + } +if (session->bc_slot_table.slots !=NULL ) { +kfree (session->bc_slot_table.slots); + session->bc_slot_table.slots =NULL ; + } +return ; +} +/* * Initialize slot table */
@@ -4473,17 +4494,15 @@ static int nfs4_init_slot_tables(struct nfs4_session *session) status =nfs4_init_slot_table (&session->fc_slot_table, session->fc_attrs.max_reqs,1 ); -return status; -} +if (status) +return status; -/* Destroy the slot table */ -static void nfs4_destroy_slot_table (struct nfs4_session *session) -{ -if (session->fc_slot_table.slots ==NULL ) -return ; -kfree (session->fc_slot_table.slots); - session->fc_slot_table.slots =NULL ; -return ; + status =nfs4_init_slot_table (&session->bc_slot_table, + session->bc_attrs.max_reqs,0 ); +if (status) +nfs4_destroy_slot_tables (session); + +return status; }struct nfs4_session *nfs4_alloc_session (struct nfs_client *clp)
@@ -4506,7 +4525,12 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp) tbl = &session->fc_slot_table;spin_lock_init (&tbl->slot_tbl_lock); -rpc_init_wait_queue (&tbl->slot_tbl_waitq,"Slot table" ); +rpc_init_wait_queue (&tbl->slot_tbl_waitq,"ForeChannel Slot table" ); + + tbl = &session->bc_slot_table; +spin_lock_init (&tbl->slot_tbl_lock); +rpc_init_wait_queue (&tbl->slot_tbl_waitq,"BackChannel Slot table" ); + session->clp = clp;return session; }
@@ -4518,7 +4542,7 @@ void nfs4_destroy_session(struct nfs4_session *session) __func__, session->clp->cl_rpcclient->cl_xprt);xprt_destroy_backchannel (session->clp->cl_rpcclient->cl_xprt,NFS41_BC_MIN_CALLBACKS ); -nfs4_destroy_slot_table (session); +nfs4_destroy_slot_tables (session);kfree (session); }
include/linux/nfs_fs_sb.h +1 -1
@@ -205,7 +205,7 @@ struct nfs4_session {struct nfs4_channel_attrs fc_attrs;struct nfs4_slot_table fc_slot_table;struct nfs4_channel_attrs bc_attrs; -/* back channel has one slot */ +struct nfs4_slot_table bc_slot_table;struct nfs_client *clp; };
Signature · 1 line
1.6.2.1
RFC 38/39 nfs41: Backchannel: New find_client_with_session()
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Finds the 'struct nfs_client' that matches the server's address, major version number, and session ID.
--- fs/nfs/callback_proc.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
fs/nfs/callback_proc.c +36 -0
@@ -104,6 +104,42 @@ out:#if defined(CONFIG_NFS_V4_1 ) +/* +* Returns a pointer to a held 'struct nfs_client' that matches the server's +* address, major version number, and session ID. It is the caller's +* responsibility to release the returned reference. +* +* Returns NULL if there are no connections with sessions, or if no session +* matches the one of interest. +*/ +static struct nfs_client *find_client_with_session ( +const struct sockaddr *addr,u32 nfsversion, +struct nfs4_sessionid *sessionid) +{ +struct nfs_client *clp; + + clp =nfs_find_client (addr,4 ); +if (clp ==NULL ) +return NULL ; + +do { +struct nfs_client *prev = clp; + +if (clp->cl_session !=NULL ) { +if (memcmp (clp->cl_session->sess_id.data, + sessionid->data, +NFS4_MAX_SESSIONID_LEN ) ==0 ) { +/* Returns a held reference to clp */ +return clp; + } + } + clp =nfs_find_client_next (prev); +nfs_put_client (prev); + }while (clp !=NULL ); + +return NULL ; +} +/* FIXME: validate args->cbs_{sequence,slot}id */ /* FIXME: referring calls should be processed */ unsigned nfs4_callback_sequence(struct cb_sequenceargs *args,
Signature · 1 line
1.6.2.1
RFC 39/39 nfs41: Backchannel: CB_SEQUENCE validation
In reply to Benny HalevyFrom: Ricardo Labiaga <[email protected]>
Validates the callback's sessionID, the slot number, and the sequence ID. Increments the slot's sequence.
Detects replays, but simply prints a debug message (if debugging is enabled since we don't yet implement a duplicate request cache for the backchannel. This should not present a problem, since only idempotent callbacks are currently implemented.
--- fs/nfs/callback_proc.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 6 deletions(-)
fs/nfs/callback_proc.c +69 -6
@@ -105,6 +105,57 @@ out:#if defined(CONFIG_NFS_V4_1 )/* +* Validate the sequenceID sent by the server. +* Return success if the sequenceID is one more than what we last saw on +* this slot, accounting for wraparound. Increments the slot's sequence. +* +* We don't yet implement a duplicate request cache, so at this time +* we will log replays, and process them as if we had not seen them before, +* but we don't bump the sequence in the slot. Not too worried about it, +* since we only currently implement idempotent callbacks anyway. +* +* We have a single slot backchannel at this time, so we don't bother +* checking the used_slots bit array on the table. The lower layer guarantees +* a single outstanding callback request at a time. +*/ +static int +validate_seqid (struct nfs4_slot_table *tbl,u32 slotid,u32 seqid) +{ +struct nfs4_slot *slot; + +dprintk ("%s enter. slotid %d seqid %d\n" , + __func__, slotid, seqid); + +if (slotid >NFS41_BC_MAX_CALLBACKS ) +return NFS4ERR_BADSLOT ; + + slot = tbl->slots + slotid; +dprintk ("%s slot table seqid: %d\n" , __func__, slot->seq_nr); + +/* Normal */ +if (likely (seqid == slot->seq_nr +1 )) { + slot->seq_nr++; +return NFS4_OK ; + } + +/* Replay */ +if (seqid == slot->seq_nr) { +dprintk ("%s seqid %d is a replay - no DRC available\n" , + __func__, seqid); +return NFS4_OK ; + } + +/* Wraparound */ +if (seqid ==1 && (slot->seq_nr +1 ) ==0 ) { + slot->seq_nr =1 ; +return NFS4_OK ; + } + +/* Misordered request */ +return NFS4ERR_SEQ_MISORDERED ; +} + +/* * Returns a pointer to a held 'struct nfs_client' that matches the server's * address, major version number, and session ID. It is the caller's * responsibility to release the returned reference.
@@ -140,18 +191,27 @@ out:return NULL ; } -/* FIXME: validate args->cbs_{sequence,slot}id */ /* FIXME: referring calls should be processed */ unsigned nfs4_callback_sequence (struct cb_sequenceargs *args,struct cb_sequenceres *res) { -int i; -unsigned status =0 ; +struct nfs_client *clp; +int i, status;for (i =0 ; i < args->csa_nrclists; i++)kfree (args->csa_rclists[i].rcl_refcalls);kfree (args->csa_rclists); + status =NFS4ERR_BADSESSION ; + clp =find_client_with_session (args->csa_addr,4 , &args->csa_sessionid); +if (clp ==NULL ) + goto out; + + status =validate_seqid (&clp->cl_session->bc_slot_table, + args->csa_slotid, args->csa_sequenceid); +if (status) + goto out_putclient; +memcpy (&res->csr_sessionid, &args->csa_sessionid,sizeof (res->csr_sessionid)); res->csr_sequenceid = args->csa_sequenceid;
@@ -159,9 +219,12 @@ unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, res->csr_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; res->csr_target_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; -dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); - res->csr_status = status; - return status; +out_putclient: +nfs_put_client (clp); +out: +dprintk ("%s: exit with status = %d\n" , __func__, status); + res->csr_status =htonl (status); + return res->csr_status; }#endif /* CONFIG_NFS_V4_1 */
Signature · 1 line
1.6.2.1
Re: [pnfs] [RFC 02/39] nfs41: Skip past the RPC call direction
In reply to Benny HalevyQuoted 35 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
xs_tcp_read_calldir()is now responsible for reading the RPC call direction and determining whether it is a reply or a callback request. The call toxdr_skb_read_bits()insidexs_tcp_read_calldir()moves thexdr_skb_readeroffset past the RPC call direction (offset should be equal to 8). Thereforexs_tcp_read_common()called fromxs_tcp_ready_reply()should be copying the TCP buffer starting past the RPC call direction. It is now necessary to read the RPC call direction earlier to determine whether to call the reply handler or the callback handler.
call_verify()should therefore skip past the XID and call/reply flag.Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- net/sunrpc/clnt.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)net/sunrpc/clnt.c +0
-6@@ -1390,13 +1390,14 @@ rpc_verify_header(struct rpc_task *task) }if ((len -=3 ) <0 ) goto out_overflow; - p +=1 ;/* skip XID */ -if ((n =ntohl (*p++)) !=RPC_REPLY ) { -dprintk ("RPC: %5u %s: not an RPC reply: %x\n" , - task->tk_pid, __func__, n); - goto out_garbage; - }
net/sunrpc/clnt.c rpc_verify_header(struct rpc_task *task) · line 1403
Quoted 10 lines
net/sunrpc/clnt.c +7
-0+/* +* Skip the XID and call direction. +* The underlying transport has read the XID and RPC call direction +* to determine this is an RPC reply. +*/ + p +=2 ; +if ((n =ntohl (*p++)) !=RPC_MSG_ACCEPTED ) {if (--len <0 ) goto out_overflow;
Err... No... The above comment is true only for the case of TCP. Why don't you simply copy the RPC call direction into the buffer?
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
RE: [pnfs] [RFC 02/39] nfs41: Skip past the RPC call direction
In reply to a message not in the archiveQuoted 6 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Wednesday, June 03, 2009 2:30 PM
To: Benny Halevy
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 02/39] nfs41: Skip past the RPC call
direction
Quoted 6 lines · Benny Halevy
Quoted 4 lines
From: Ricardo Labiaga <[email protected]>
xs_tcp_read_calldir()is now responsible for reading the RPC call direction and determining whether it is a reply or a callback
request.
Quoted 1 line
Quoted 1 line
The call to
xdr_skb_read_bits()insidexs_tcp_read_calldir()moves
the
Quoted 3 lines
Quoted 3 lines
xdr_skb_readeroffset past the RPC call direction (offset should be equal to 8). Thereforexs_tcp_read_common()called fromxs_tcp_ready_reply()should be copying the TCP buffer starting past
the
Quoted 1 line
Quoted 1 line
RPC call direction. It is now necessary to read the RPC call
direction
Quoted 1 line
Quoted 1 line
earlier to determine whether to call the reply handler or the
callback
Quoted 3 lines
Quoted 3 lines
handler.
call_verify()should therefore skip past the XID and call/reply
flag.
Quoted 17 lines
Quoted 17 lines
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- net/sunrpc/clnt.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)net/sunrpc/clnt.c +0
-1@@ -1390,13 +1390,14 @@ rpc_verify_header(struct rpc_task *task) }if ((len -=3 ) <0 ) goto out_overflow; - p +=1 ;/* skip XID */
Quoted 8 lines
net/sunrpc/clnt.c rpc_verify_header(struct rpc_task *task)
Quoted 8 lines
net/sunrpc/clnt.c +3
-5-if ((n =ntohl (*p++)) !=RPC_REPLY ) { -dprintk ("RPC: %5u %s: not an RPC reply: %x\n" , - task->tk_pid, __func__, n); - goto out_garbage; - } +/* +* Skip the XID and call direction. +* The underlying transport has read the XID and RPC call
direction
Quoted 10 lines
net/sunrpc/clnt.c rpc_verify_header(struct rpc_task *task) · line 1403
Quoted 7 lines
net/sunrpc/clnt.c +4
-0+* to determine this is an RPC reply. +*/ + p +=2 ; +if ((n =ntohl (*p++)) !=RPC_MSG_ACCEPTED ) {if (--len <0 ) goto out_overflow;Err... No... The above comment is true only for the case of TCP. Why don't you simply copy the RPC call direction into the buffer?
You're right. We'll follow your suggestion to copy it into the buffer and leave the processing as it originally was in rpc_verify_header().
- ricardo
Quoted 9 lines
--
Trond Myklebust
Linux NFS client maintainerNetApp
[email protected]
www.netapp.com
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs"
in
Quoted 2 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [pnfs] [RFC 04/39] nfs41: minorversion support for nfs4_{init, destroy}_callback
In reply to Benny HalevyQuoted 64 lines · Benny Halevy
move
nfs4_init_callbackintonfs4_init_client_minor_versionandnfs4_destroy_callbackintonfs4_clear_client_minor_versionas these need to happen also when auto-negotiating the minorversion once the callback service for nfs41 becomes different than for nfs4.0
Signed-off-by Benny Halevy <[email protected]>[nfs41: Fix checkpatch warning]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.c | 67 ++++++++++++++++++++++++++++++++++++++--------------- fs/nfs/callback.h | 2 +- fs/nfs/client.c | 21 +++++----------- 3 files changed, 56 insertions(+), 34 deletions(-)fs/nfs/callback.c +7
-17@@ -59,7 +59,7 @@ module_param_call(callback_tcpport, param_set_port, param_get_int,* This is the callback kernel thread. */ static int -nfs_callback_svc (void *vrqstp) +nfs4_callback_svc (void *vrqstp) {int err, preverr =0 ;struct svc_rqst *rqstp = vrqstp;@@ -97,20 +97,12 @@ nfs_callback_svc(void *vrqstp) }/* -* Bring up the callback thread if it is not already up. +* Prepare to bring up the NFSv4 callback service */ -int nfs_callback_up (void ) +struct svc_rqst * +nfs4_callback_up (struct svc_serv *serv) { -struct svc_serv *serv =NULL ; -int ret =0 ; - -mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) - goto out; - serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL ); - ret = -ENOMEM ; -if (!serv) - goto out_err; +int ret; ret =svc_create_xprt (serv,"tcp" ,PF_INET , nfs_callback_set_tcpport,SVC_SOCK_ANONYMOUS );@@ -131,18 +123,55 @@ int nfs_callback_up(void) goto out_err;#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ - nfs_callback_info.rqst =svc_prepare_thread (serv, &serv->sv_pools[0 ]); -if (IS_ERR (nfs_callback_info.rqst)) { - ret =PTR_ERR (nfs_callback_info.rqst); - nfs_callback_info.rqst =NULL ; +return svc_prepare_thread (serv, &serv->sv_pools[0 ]); +
fs/nfs/callback.c int nfs_callback_up(void) · line 137
Quoted 10 lines
fs/nfs/callback.c +10
-0+out_err: +if (ret ==0 ) + ret = -ENOMEM ; +return ERR_PTR (ret); +} + +/* +* Bring up the callback thread if it is not already up. +*/ +int nfs_callback_up (u32 minorversion,void *args)
^^^^^^^^^^
There is no reason not to type check the arguments here. Please fix...
Quoted 136 lines
fs/nfs/callback.c +31
-2+{ +struct svc_serv *serv =NULL ; +struct svc_rqst *rqstp; +int (*callback_svc)(void *vrqstp); +char svc_name[12 ]; +int ret =0 ; + +mutex_lock (&nfs_callback_mutex); +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) + goto out; + serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL ); +if (!serv) { + ret = -ENOMEM ; + goto out_err; + } + +/* FIXME: either 4.0 or 4.1 callback service can be up at a time +* need to monitor and control them both */ +if (!minorversion) { + rqstp =nfs4_callback_up (serv); + callback_svc = nfs4_callback_svc; + }else { +BUG ();/* for now */ + } + +if (IS_ERR (rqstp)) { + ret =PTR_ERR (rqstp); goto out_err; }svc_sock_update_bufs (serv); - nfs_callback_info.task =kthread_run (nfs_callback_svc, +sprintf (svc_name,"nfsv4.%u-svc" , minorversion); + nfs_callback_info.rqst = rqstp; + nfs_callback_info.task =kthread_run (callback_svc, nfs_callback_info.rqst, -"nfsv4-svc" ); + svc_name);if (IS_ERR (nfs_callback_info.task)) { ret =PTR_ERR (nfs_callback_info.task);svc_exit_thread (nfs_callback_info.rqst);fs/nfs/callback.h +1
-1@@ -63,7 +63,7 @@ extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getatextern __be32 nfs4_callback_recall (struct cb_recallargs *args,void *dummy);#ifdef CONFIG_NFS_V4 -extern int nfs_callback_up (void ); +extern int nfs_callback_up (u32 minorversion,void *args);extern void nfs_callback_down (void );#else #define nfs_callback_up () (0)fs/nfs/client.c +7
-14@@ -47,9 +47,6 @@#include "internal.h" #include "fscache.h" -static int nfs4_init_callback (struct nfs_client *); -static void nfs4_destroy_callback (struct nfs_client *); -#define NFSDBG_FACILITY NFSDBG_CLIENTstatic DEFINE_SPINLOCK (nfs_client_lock);@@ -124,9 +121,6 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ clp->rpc_ops = cl_init->rpc_ops; -if (nfs4_init_callback (clp) <0 ) - goto error_2; -atomic_set (&clp->cl_count,1 ); clp->cl_cons_state =NFS_CS_INITING ;@@ -136,7 +130,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_if (cl_init->hostname) { clp->cl_hostname =kstrdup (cl_init->hostname,GFP_KERNEL );if (!clp->cl_hostname) - goto error_3; + goto error_cleanup; }INIT_LIST_HEAD (&clp->cl_superblocks);@@ -161,9 +155,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_return clp; -error_3: -nfs4_destroy_callback (clp); -error_2: +error_cleanup:kfree (clp); error_0:return NULL ;@@ -207,6 +199,8 @@ static void nfs4_clear_client_minor_version(struct nfs_client *clp) clp->cl_call_sync = _nfs4_call_sync;#endif /* CONFIG_NFS_V4_1 */ + +nfs4_destroy_callback (clp); }/* @@ -225,8 +219,6 @@ static void nfs_free_client(struct nfs_client *clp)if (!IS_ERR (clp->cl_rpcclient))rpc_shutdown_client (clp->cl_rpcclient); -nfs4_destroy_callback (clp); -if (clp->cl_machine_cred !=NULL )put_rpccred (clp->cl_machine_cred);@@ -1104,7 +1096,8 @@ static int nfs4_init_callback(struct nfs_client *clp)int error;if (clp->rpc_ops->version ==4 ) { - error =nfs_callback_up (); + error =nfs_callback_up (clp->cl_minorversion, + clp->cl_rpcclient->cl_xprt);if (error <0 ) {dprintk ("%s: failed to start callback. Error = %d\n" , __func__, error);@@ -1139,7 +1132,7 @@ static int nfs4_init_client_minor_version(struct nfs_client *clp) }#endif /* CONFIG_NFS_V4_1 */ -return 0 ; +return nfs4_init_callback (clp); }/*
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
RE: [pnfs] [RFC 04/39] nfs41: minorversion support for nfs4_{init, destroy}_callback
In reply to a message not in the archiveQuoted 8 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Wednesday, June 03, 2009 7:40 PM
To: Benny Halevy
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 04/39] nfs41: minorversion support for nfs4_{init, destroy}_callback
Quoted 6 lines
Quoted 5 lines · Benny Halevy
move
nfs4_init_callbackintonfs4_init_client_minor_versionandnfs4_destroy_callbackintonfs4_clear_client_minor_versionas these need to happen also when auto-negotiating the minorversion once the callback service for nfs41 becomes different than for
nfs4.0
Quoted 7 lines
Quoted 7 lines
Signed-off-by Benny Halevy <[email protected]>[nfs41: Fix checkpatch warning]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.c | 67
++++++++++++++++++++++++++++++++++++++--------
Quoted 10 lines
-------
fs/nfs/callback.c module_param_call(callback_tcpport,
Quoted 9 lines
fs/nfs/callback.h | 2 +- fs/nfs/client.c | 21 +++++----------- 3 files changed, 56 insertions(+), 34 deletions(-)fs/nfs/callback.c +0
-0@@ -59,7 +59,7 @@ module_param_call(callback_tcpport,
param_set_port,
Quoted 28 lines
param_get_int,Quoted 16 lines
fs/nfs/callback.c +2
-3* This is the callback kernel thread. */ static int -nfs_callback_svc (void *vrqstp) +nfs4_callback_svc (void *vrqstp) {int err, preverr =0 ;struct svc_rqst *rqstp = vrqstp;@@ -97,20 +97,12 @@ nfs_callback_svc(void *vrqstp) }/* -* Bring up the callback thread if it is not already up. +* Prepare to bring up the NFSv4 callback service */ -int nfs_callback_up (void )fs/nfs/callback.c nfs_callback_svc(void *vrqstp) · line 110
Quoted 10 lines
fs/nfs/callback.c +2
-7+struct svc_rqst * +nfs4_callback_up (struct svc_serv *serv) { -struct svc_serv *serv =NULL ; -int ret =0 ; - -mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) - goto out; - serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,NULL);
Quoted 7 lines
fs/nfs/callback.c nfs_callback_svc(void *vrqstp)
Quoted 7 lines
fs/nfs/callback.c +1
-3- ret = -ENOMEM ; -if (!serv) - goto out_err; +int ret; ret = svc_create_xprt(serv, "tcp", PF_INET, nfs_callback_set_tcpport,
SVC_SOCK_ANONYMOUS);
Quoted 3 lines
fs/nfs/callback.c int nfs_callback_up(void) · line 124
Quoted 3 lines
fs/nfs/callback.c +0
-0@@ -131,18 +123,55 @@ int nfs_callback_up(void) goto out_err;#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
*/
Quoted 19 lines
Quoted 8 lines
fs/nfs/callback.c +2
-4- nfs_callback_info.rqst =svc_prepare_thread (serv, &serv- sv_pools[0]); -if (IS_ERR (nfs_callback_info.rqst)) { - ret =PTR_ERR (nfs_callback_info.rqst); - nfs_callback_info.rqst =NULL ; +return svc_prepare_thread (serv, &serv->sv_pools[0 ]); +fs/nfs/callback.c int nfs_callback_up(void) · line 137
Quoted 10 lines
fs/nfs/callback.c +10
-0+out_err: +if (ret ==0 ) + ret = -ENOMEM ; +return ERR_PTR (ret); +} + +/* +* Bring up the callback thread if it is not already up. +*/ +int nfs_callback_up (u32 minorversion,void *args)^^^^^^^^^^
Quoted 1 line
There is no reason not to type check the arguments here. Please fix...
Will do.
- ricardo
Quoted 77 lines
fs/nfs/callback.c int nfs_callback_up(void)
Quoted 11 lines
fs/nfs/callback.c +11
-0+{ +struct svc_serv *serv =NULL ; +struct svc_rqst *rqstp; +int (*callback_svc)(void *vrqstp); +char svc_name[12 ]; +int ret =0 ; + +mutex_lock (&nfs_callback_mutex); +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) + goto out; + serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,NULL);
fs/nfs/callback.h extern __be32 nfs4_callback_getattr(struct
Quoted 36 lines
fs/nfs/callback.c +20
-2+if (!serv) { + ret = -ENOMEM ; + goto out_err; + } + +/* FIXME: either 4.0 or 4.1 callback service can be up at a time +* need to monitor and control them both */ +if (!minorversion) { + rqstp =nfs4_callback_up (serv); + callback_svc = nfs4_callback_svc; + }else { +BUG ();/* for now */ + } + +if (IS_ERR (rqstp)) { + ret =PTR_ERR (rqstp); goto out_err; }svc_sock_update_bufs (serv); - nfs_callback_info.task =kthread_run (nfs_callback_svc, +sprintf (svc_name,"nfsv4.%u-svc" , minorversion); + nfs_callback_info.rqst = rqstp; + nfs_callback_info.task =kthread_run (callback_svc, nfs_callback_info.rqst, -"nfsv4-svc" ); + svc_name);if (IS_ERR (nfs_callback_info.task)) { ret =PTR_ERR (nfs_callback_info.task);svc_exit_thread (nfs_callback_info.rqst);fs/nfs/callback.h +0
-0@@ -63,7 +63,7 @@ extern __be32 nfs4_callback_getattr(struct
cb_getattrargs*args, structcb_getatfs/nfs/callback.h extern __be32 nfs4_callback_getattr(struct · line 63
Quoted 1 line
fs/nfs/callback.h +0
-0extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void*dummy);
fs/nfs/client.c static struct nfs_client *nfs_alloc_client(const
Quoted 22 lines
fs/nfs/callback.h +1
-1#ifdef CONFIG_NFS_V4 -extern int nfs_callback_up (void ); +extern int nfs_callback_up (u32 minorversion,void *args);extern void nfs_callback_down (void );#else #define nfs_callback_up () (0)fs/nfs/client.c +0
-3@@ -47,9 +47,6 @@#include "internal.h" #include "fscache.h" -static int nfs4_init_callback (struct nfs_client *); -static void nfs4_destroy_callback (struct nfs_client *); -#define NFSDBG_FACILITY NFSDBG_CLIENTstatic DEFINE_SPINLOCK (nfs_client_lock);@@ -124,9 +121,6 @@ static struct nfs_client *nfs_alloc_client(conststruct
nfs_client_initdata*cl_Quoted 3 lines
fs/nfs/client.c +0
-0clp->rpc_ops = cl_init->rpc_ops;
Quoted 10 lines
fs/nfs/client.c static struct nfs_client *nfs_alloc_client(const
Quoted 7 lines
fs/nfs/client.c +0
-3-if (nfs4_init_callback (clp) <0 ) - goto error_2; -atomic_set (&clp->cl_count,1 ); clp->cl_cons_state =NFS_CS_INITING ;@@ -136,7 +130,7 @@ static struct nfs_client *nfs_alloc_client(conststruct
nfs_client_initdata*cl_Quoted 2 lines
fs/nfs/client.c +0
-0if (cl_init->hostname) { clp->cl_hostname = kstrdup(cl_init->hostname,
GFP_KERNEL);
Quoted 11 lines
fs/nfs/client.c static struct nfs_client *nfs_alloc_client(const
Quoted 7 lines
fs/nfs/client.c +1
-1if (!clp->cl_hostname) - goto error_3; + goto error_cleanup; }INIT_LIST_HEAD (&clp->cl_superblocks);@@ -161,9 +155,7 @@ static struct nfs_client *nfs_alloc_client(conststruct
nfs_client_initdata*cl_Quoted 3 lines
fs/nfs/client.c +0
-0return clp;
Quoted 8 lines
fs/nfs/client.c static void
Quoted 8 lines
fs/nfs/client.c +1
-3-error_3: -nfs4_destroy_callback (clp); -error_2: +error_cleanup:kfree (clp); error_0:return NULL ;@@ -207,6 +199,8 @@ static void
nfs4_clear_client_minor_version(struct
Quoted 10 lines
nfs_client*clp)fs/nfs/client.c static void nfs_free_client(struct nfs_client
Quoted 9 lines
fs/nfs/client.c +2
-0clp->cl_call_sync = _nfs4_call_sync;#endif /* CONFIG_NFS_V4_1 */ + +nfs4_destroy_callback (clp); }/* @@ -225,8 +219,6 @@ static void nfs_free_client(struct nfs_client
*clp)
Quoted 9 lines
fs/nfs/client.c static int nfs4_init_callback(struct
Quoted 9 lines
fs/nfs/client.c +0
-2if (!IS_ERR (clp->cl_rpcclient))rpc_shutdown_client (clp->cl_rpcclient); -nfs4_destroy_callback (clp); -if (clp->cl_machine_cred !=NULL )put_rpccred (clp->cl_machine_cred);@@ -1104,7 +1096,8 @@ static int nfs4_init_callback(struct
nfs_client
Quoted 9 lines
*clp)
fs/nfs/client.c static int nfs4_init_callback(struct nfs_client *clp)
Quoted 8 lines
fs/nfs/client.c +2
-1int error;if (clp->rpc_ops->version ==4 ) { - error =nfs_callback_up (); + error =nfs_callback_up (clp->cl_minorversion, + clp->cl_rpcclient->cl_xprt);if (error <0 ) { dprintk("%s: failed to start callback. Error =
%d\n",
Quoted 2 lines
fs/nfs/client.c static int
Quoted 2 lines
fs/nfs/client.c +0
-0__func__, error);@@ -1139,7 +1132,7 @@ static int
nfs4_init_client_minor_version(struct
Quoted 23 lines
nfs_client*clp)fs/nfs/client.c static int nfs4_init_client_minor_version(struct nfs_client *clp) · line 1138
Quoted 8 lines
fs/nfs/client.c +1
-1}#endif /* CONFIG_NFS_V4_1 */ -return 0 ; +return nfs4_init_callback (clp); }/* --
Trond Myklebust
Linux NFS client maintainerNetApp
[email protected]
www.netapp.com
_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
Re: [pnfs] [RFC 10/39] nfs41: Add backchannel processing support to RPC state machine
In reply to Benny HalevyQuoted 243 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Adds
rpc_run_bc_task()which is called by the NFS callback service to process backchannel requests. It performs similar work torpc_run_task()though "schedules" the backchannel task to be executed starting at thecall_trasmitstate in the RPC state machine.It also introduces some miscellaneous updates to the argument validation,
call_transmit, and transport cleanup functions to take into account that there are now forechannel and backchannel tasks.Backchannel requests do not carry an RPC message structure, since the payload has already been XDR encoded using the existing NFSv4 callback mechanism.
Introduce a new transmit state for the client to reply on to backchannel requests. This new state simply reserves the transport and issues the reply. In case of a connection related error, disconnects the transport and drops the reply. It requires the forechannel to re-establish the connection and the server to retransmit the request, as stated in NFSv4.1 section 2.9.2 "Client and Server Transport Behavior".
Note: There is no need to loop attempting to reserve the transport. If EAGAIN is returned by
xprt_prepare_transmit(), return withtk_status== 0, settingtk_actiontocall_bc_transmit.rpc_execute()will invoke it again after the task is taken off the sleep queue.[nfs41: rpc_run_bc_task() need not be exported outside RPC module][nfs41: New call_bc_transmit RPC state]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>[nfs41: Backchannel: No need to loop in call_bc_transmit()]Signed-off-by Andy Adamson <[email protected]>Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- include/linux/sunrpc/sched.h | 2 + include/linux/sunrpc/xprt.h | 12 ++++ net/sunrpc/clnt.c | 117 +++++++++++++++++++++++++++++++++++++++++- net/sunrpc/stats.c | 6 ++- net/sunrpc/sunrpc.h | 35 +++++++++++++ net/sunrpc/xprt.c | 36 +++++++++++-- 6 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 net/sunrpc/sunrpc.hinclude/linux/sunrpc/sched.h +2
-0@@ -210,6 +210,8 @@ struct rpc_wait_queue {*/ struct rpc_task *rpc_new_task (const struct rpc_task_setup *);struct rpc_task *rpc_run_task (const struct rpc_task_setup *); +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, +const struct rpc_call_ops *ops);void rpc_put_task (struct rpc_task *);void rpc_exit_task (struct rpc_task *);void rpc_release_calldata (const struct rpc_call_ops *,void *);include/linux/sunrpc/xprt.h +12
-0@@ -215,6 +215,18 @@ struct rpc_xprt {/* buffer in use */ #endif /* CONFIG_NFS_V4_1 */ +#if defined(CONFIG_NFS_V4_1 ) +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return test_bit (RPC_BC_PA_IN_USE , &req->rq_bc_pa_state); +} +#else +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return 0 ; +} +#endif /* CONFIG_NFS_V4_1 */ +struct xprt_create {int ident;/* XPRT_TRANSPORT identifier */ struct sockaddr * srcaddr;/* optional local address */ net/sunrpc/clnt.c +116
-1@@ -36,7 +36,9 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/metrics.h> +#include <linux/sunrpc/bc_xprt.h> +#include "sunrpc.h" #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_CALL@@ -63,6 +65,9 @@ static void call_decode(struct rpc_task *task);static void call_bind (struct rpc_task *task);static void call_bind_status (struct rpc_task *task);static void call_transmit (struct rpc_task *task); +#if defined(CONFIG_NFS_V4_1 ) +static void call_bc_transmit (struct rpc_task *task); +#endif /* CONFIG_NFS_V4_1 */ static void call_status (struct rpc_task *task);static void call_transmit_status (struct rpc_task *task);static void call_refresh (struct rpc_task *task);@@ -613,6 +618,50 @@ rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags, }EXPORT_SYMBOL_GPL (rpc_call_async); +#if defined(CONFIG_NFS_V4_1 ) +/** +* rpc_run_bc_task - Allocate a new RPC task for backchannel use, then run +* rpc_execute against it +* @ops: RPC call ops +*/ +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, +const struct rpc_call_ops *tk_ops) +{ +struct rpc_task *task; +struct xdr_buf *xbufp = &req->rq_snd_buf; +struct rpc_task_setup task_setup_data = { + .callback_ops = tk_ops, + }; + +dprintk ("RPC: rpc_run_bc_task req= %p\n" , req); +/* +* Create an rpc_task to send the data +*/ + task =rpc_new_task (&task_setup_data); +if (!task) { +xprt_free_bc_request (req); + goto out; + } + task->tk_rqstp = req; + +/* +* Set up the xdr_buf length. +* This also indicates that the buffer is XDR encoded already. +*/ + xbufp->len = xbufp->head[0 ].iov_len + xbufp->page_len + + xbufp->tail[0 ].iov_len; + + task->tk_action = call_bc_transmit; +atomic_inc (&task->tk_count); +BUG_ON (atomic_read (&task->tk_count) !=2 ); +rpc_execute (task); + +out: +dprintk ("RPC: rpc_run_bc_task: task= %p\n" , task); +return task; +} +#endif /* CONFIG_NFS_V4_1 */ +void rpc_call_start (struct rpc_task *task) {@@ -1098,7 +1147,7 @@ call_transmit(struct rpc_task *task)* in order to allow access to the socket to other RPC requests. */ call_transmit_status (task); -if (task->tk_msg.rpc_proc->p_decode !=NULL ) +if (rpc_reply_expected (task))return ; task->tk_action = rpc_exit_task;rpc_wake_up_queued_task (&task->tk_xprt->pending, task);@@ -1133,6 +1182,72 @@ call_transmit_status(struct rpc_task *task) } } +#if defined(CONFIG_NFS_V4_1 ) +/* +* 5b. Send the backchannel RPC reply. On error, drop the reply. In +* addition, disconnect on connectivity errors. +*/ +static void +call_bc_transmit (struct rpc_task *task) +{ +struct rpc_rqst *req = task->tk_rqstp; + +BUG_ON (task->tk_status !=0 ); + task->tk_status =xprt_prepare_transmit (task); +if (task->tk_status == -EAGAIN ) { +/* +* Could not reserve the transport. Try again after the +* transport is released. +*/ + task->tk_status =0 ; + task->tk_action = call_bc_transmit; +return ; + } + + task->tk_action = rpc_exit_task; +if (task->tk_status <0 ) { +printk (KERN_NOTICE "RPC: Could not send backchannel reply " +"error: %d\n" , task->tk_status); +return ; + } + +xprt_transmit (task); +xprt_end_transmit (task); +dprint_status (task); +switch (task->tk_status) { +case 0 : +/* Success */ +break ; +case -EHOSTDOWN : +case -EHOSTUNREACH : +case -ENETUNREACH : +case -ETIMEDOUT : +/* +* Problem reaching the server. Disconnect and let the +* forechannel reestablish the connection. The server will +* have to retransmit the backchannel request and we'll +* reprocess it. Since these ops are idempotent, there's no +* need to cache our reply at this time. +*/ +printk (KERN_NOTICE "RPC: Could not send backchannel reply " +"error: %d\n" , task->tk_status); +xprt_conditional_disconnect (task->tk_xprt, + req->rq_connect_cookie); +break ; +default : +/* +* We were unable to reply and will have to drop the +* request. The server should reconnect and retransmit. +*/ +BUG_ON (task->tk_status == -EAGAIN ); +printk (KERN_NOTICE "RPC: Could not send backchannel reply " +"error: %d\n" , task->tk_status); +break ; + } +rpc_wake_up_queued_task (&req->rq_xprt->pending, task); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * 6. Sort out the RPC call status */ net/sunrpc/stats.c +0
-0
net/sunrpc/stats.c EXPORT_SYMBOL_GPL(rpc_free_iostats); · line 148
Quoted 10 lines
net/sunrpc/stats.c +2
-2@@ -141,12 +141,14 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);void rpc_count_iostats (struct rpc_task *task) {struct rpc_rqst *req = task->tk_rqstp; -struct rpc_iostats *stats = task->tk_client->cl_metrics; +struct rpc_iostats *stats;struct rpc_iostats *op_metrics;long rtt, execute, queue; -if (!stats || !req) +if (!task->tk_client || task->tk_client->cl_metrics || !req)
When are we going to have a tk_client without metrics?
Quoted 12 lines
net/sunrpc/stats.c +2
-0return ; + + stats = task->tk_client->cl_metrics; op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx]; op_metrics->om_ops++;net/sunrpc/sunrpc.h new file +0
-0
net/sunrpc/sunrpc.h line 4
Quoted 4 lines
net/sunrpc/sunrpc.h new file +4
-0@@ -0,0 +1,35 @@ +/****************************************************************************** + +(c) 2008 Network Appliance, Inc. All Rights Reserved. +
Ditto...
Quoted 18 lines
net/sunrpc/sunrpc.h new file +18
-0+Network Appliance provides this source code under the GPL v2 License. +The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ +
net/sunrpc/sunrpc.h line 32
Quoted 10 lines
net/sunrpc/sunrpc.h new file +10
-0+/* +* Functions and macros used internally by RPC +*/ + +#ifndef _NET_SUNRPC_SUNRPC_H +#define _NET_SUNRPC_SUNRPC_H + +#define rpc_reply_expected (task) \ + (((task)->tk_msg.rpc_proc != NULL) && \ + ((task)->tk_msg.rpc_proc->p_decode != NULL))
Why is this a macro instead of being an inlined function?
Quoted 56 lines
net/sunrpc/sunrpc.h new file +3
-0+ +#endif /* _NET_SUNRPC_SUNRPC_H */ +net/sunrpc/xprt.c +15
-4@@ -12,8 +12,9 @@* - Next, the caller puts together the RPC message, stuffs it into * the request struct, and calls xprt_transmit(). * - xprt_transmit sends the message and installs the caller on the -* transport's wait list. At the same time, it installs a timer that -* is run after the packet's timeout has expired. +* transport's wait list. At the same time, if a reply is expected, +* it installs a timer that is run after the packet's timeout has +* expired. * - When a packet arrives, the data_ready handler walks the list of * pending requests for that transport. If a matching XID is found, the * caller is woken up, and the timer removed. @@ -46,6 +47,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/metrics.h> +#include "sunrpc.h" +/* * Local variables */ @@ -875,7 +878,10 @@ void xprt_transmit(struct rpc_task *task)dprintk ("RPC: %5u xprt_transmit(%u)\n" , task->tk_pid, req->rq_slen);if (!req->rq_received) { -if (list_empty (&req->rq_list)) { +if (list_empty (&req->rq_list) &&rpc_reply_expected (task)) { +/* +* Add to the list only if we're expecting a reply +*/ spin_lock_bh (&xprt->transport_lock);/* Update the softirq receive buffer */ memcpy(&req->rq_private_buf, &req->rq_rcv_buf,@@ -910,8 +916,13 @@ void xprt_transmit(struct rpc_task *task)/* Don't race with disconnect */ if (!xprt_connected (xprt)) task->tk_status = -ENOTCONN ; -else if (!req->rq_received) +else if (!req->rq_received &&rpc_reply_expected (task)) { +/* +* Sleep on the pending queue since +* we're expecting a reply. +*/ rpc_sleep_on (&xprt->pending, task, xprt_timer); + }spin_unlock_bh (&xprt->transport_lock); }
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) · line 1002
Quoted 9 lines
net/sunrpc/xprt.c +3
-1@@ -984,11 +995,15 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)*/ void xprt_release (struct rpc_task *task) { -struct rpc_xprt *xprt = task->tk_xprt; +struct rpc_xprt *xprt;struct rpc_rqst *req; +int prealloc; +BUG_ON (atomic_read (&task->tk_count) <0 );
Err?
Quoted 14 lines
net/sunrpc/xprt.c +4
-1if (!(req = task->tk_rqstp))return ; + prealloc =bc_prealloc (req);/* Preallocated backchannel request? */ + xprt = req->rq_xprt;rpc_count_iostats (task);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);@@ -1001,10 +1016,19 @@ void xprt_release(struct rpc_task *task)mod_timer (&xprt->timer, xprt->last_used + xprt->idle_timeout);spin_unlock_bh (&xprt->transport_lock); - xprt->ops->buf_free (req->rq_buffer); +if (!bc_prealloc (req)) + xprt->ops->buf_free (req->rq_buffer);
net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1030
Quoted 10 lines
net/sunrpc/xprt.c +7
-0task->tk_rqstp =NULL ;if (req->rq_release_snd_buf) req->rq_release_snd_buf (req); + +/* +* Early exit if this is a backchannel preallocated request. +* There is no need to have it added to the RPC slot list. +*/ +if (prealloc) +return ;
Could we change the name of 'prealloc' to something along the lines of 'is_bc_request'?
Quoted 4 lines
net/sunrpc/xprt.c +1
-0+memset (req,0 ,sizeof (*req));/* mark unused */ dprintk ("RPC: %5u release request %p\n" , task->tk_pid, req);
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 14/39] nfs41: Implement NFSv4.1 callback service process.
In reply to Benny HalevyQuoted 123 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
nfs41_callback_up()initializes the necessary queues and creates the newnfs41_callback_svcthread. This thread executes the callback service which waits for requests to arrive on thesvc_serv->sv_cb_list.
NFS41_BC_MIN_CALLBACKSis set to 1 because we expect callbacks to not cause substantial latency.The actual processing of the callback will be implemented as a separate patch.
There is only one NFSv4.1 callback service. The first caller of
nfs4_callback_up()creates the service, subsequent callers increment a reference count on the service. The service is destroyed when the last caller invokesnfs_callback_down().The transport needs to hold a reference to the callback service in order to invoke it during callback processing. Currently this reference is only obtained when the service is first created. This is incorrect, since subsequent registrations for other transports will leave the
xprt->servpointer uninitialized, leading to an oops when a callback arrives on the "unreferenced" transport.This patch fixes the problem by ensuring that a reference to the service is saved in
xprt->serv, either because the service is created by this invocation tonfs4_callback_up()or by a prior invocation.Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>[nfs41: Add a reference to svc_serv during callback service bring up]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.c | 83 ++++++++++++++++++++++++++++++++++++++++++- fs/nfs/callback.h | 7 ++++ include/linux/sunrpc/svc.h | 2 + 3 files changed, 90 insertions(+), 2 deletions(-)fs/nfs/callback.c +66
-0@@ -17,6 +17,9 @@#include <linux/freezer.h> #include <linux/kthread.h> #include <linux/sunrpc/svcauth_gss.h> +#if defined(CONFIG_NFS_V4_1 ) +#include <linux/sunrpc/bc_xprt.h> +#endif #include <net/inet_sock.h> @@ -131,6 +134,69 @@ out_err:return ERR_PTR (ret); } +#if defined(CONFIG_NFS_V4_1 ) +/* +* The callback service for NFSv4.1 callbacks +*/ +static int +nfs41_callback_svc (void *vrqstp) +{ +struct svc_rqst *rqstp = vrqstp; +struct svc_serv *serv = rqstp->rq_server; +struct rpc_rqst *req; +int error; +DEFINE_WAIT (wq); + +set_freezable (); + +/* +* FIXME: do we really need to run this under the BKL? If so, please +* add a comment about what it's intended to protect. +*/ +lock_kernel (); +while (!kthread_should_stop ()) { +prepare_to_wait (&serv->sv_cb_waitq, &wq,TASK_INTERRUPTIBLE ); +spin_lock_bh (&serv->sv_cb_lock); +if (!list_empty (&serv->sv_cb_list)) { + req =list_first_entry (&serv->sv_cb_list, + struct rpc_rqst, rq_bc_list); +list_del (&req->rq_bc_list); +spin_unlock_bh (&serv->sv_cb_lock); +dprintk ("Invoking bc_svc_process()\n" ); + error =bc_svc_process (serv, req, rqstp); +dprintk ("bc_svc_process() returned w/ error code= %d\n" , + error); + }else { +spin_unlock_bh (&serv->sv_cb_lock); +schedule (); + } +finish_wait (&serv->sv_cb_waitq, &wq); + } +unlock_kernel (); + nfs_callback_info.task =NULL ; +svc_exit_thread (rqstp); +return 0 ; +} + +/* +* Bring up the NFSv4.1 callback service +*/ +struct svc_rqst * +nfs41_callback_up (struct svc_serv *serv,struct rpc_xprt *xprt) +{ +/* +* Save the svc_serv in the transport so that it can +* be referenced when the session backchannel is initialized +*/ + xprt->bc_serv = serv; + +INIT_LIST_HEAD (&serv->sv_cb_list); +spin_lock_init (&serv->sv_cb_lock); +init_waitqueue_head (&serv->sv_cb_waitq); +return svc_prepare_thread (serv, &serv->sv_pools[0 ]); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * Bring up the callback thread if it is not already up. */
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 212
Quoted 6 lines
fs/nfs/callback.c +3
-0@@ -141,10 +207,18 @@ int nfs_callback_up(u32 minorversion, void *args)int (*callback_svc)(void *vrqstp);char svc_name[12 ];int ret =0 ; +#if defined(CONFIG_NFS_V4_1 ) +struct rpc_xprt *xprt = (struct rpc_xprt *)args; +#endif /* CONFIG_NFS_V4_1 */
More ugly embedded ifdefs...
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 219
Quoted 8 lines
fs/nfs/callback.c +5
-1mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) { +#if defined(CONFIG_NFS_V4_1 ) +if (minorversion) + xprt->bc_serv = nfs_callback_info.serv; +#endif /* CONFIG_NFS_V4_1 */
Ditto
Quoted 6 lines
fs/nfs/callback.c +1
-0goto out; + } serv =svc_create (&nfs4_callback_program,NFS4_CALLBACK_BUFSIZE ,NULL );if (!serv) { ret = -ENOMEM ;
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 239
Quoted 10 lines
fs/nfs/callback.c +6
-1@@ -157,7 +231,12 @@ int nfs_callback_up(u32 minorversion, void *args) rqstp =nfs4_callback_up (serv); callback_svc = nfs4_callback_svc; }else { -BUG ();/* for now */ +#if defined(CONFIG_NFS_V4_1 ) + rqstp =nfs41_callback_up (serv, xprt); + callback_svc = nfs41_callback_svc; +#else /* CONFIG_NFS_V4_1 */ +BUG (); +#endif /* CONFIG_NFS_V4_1 */
Ditto
Quoted 26 lines
fs/nfs/callback.c +0
-0}if (IS_ERR (rqstp)) {fs/nfs/callback.h +7
-0@@ -70,6 +70,13 @@ extern void nfs_callback_down(void);#define nfs_callback_down () do {} while(0)#endif +/* +* nfs41: Callbacks are expected to not cause substantial latency, +* so we limit their concurrency to 1 by setting up the maximum number +* of slots for the backchannel. +*/ +#define NFS41_BC_MIN_CALLBACKS 1 +extern unsigned int nfs_callback_set_tcpport;extern unsigned short nfs_callback_tcpport;extern unsigned short nfs_callback_tcpport6;include/linux/sunrpc/svc.h +0
-0
include/linux/sunrpc/svc.h int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); · line 423
Quoted 5 lines
include/linux/sunrpc/svc.h +2
-0@@ -419,6 +419,8 @@ int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int);int svc_pool_stats_open (struct svc_serv *serv,struct file *file);void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); +int bc_svc_process (struct svc_serv *,struct rpc_rqst *, +struct svc_rqst *);
OK, I give up. Why is the function text and export declaration in one patch, while the declaration is in this patch?
Quoted 3 lines
include/linux/sunrpc/svc.h +0
-0int svc_register (const struct svc_serv *,const int ,const unsigned short ,const unsigned short );
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 11/39] nfs41: Backchannel callback service helper routines
In reply to Benny HalevyQuoted 59 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Executes the backchannel task on the RPC state machine using the existing open connection previously established by the client.
Signed-off-by Ricardo Labiaga <[email protected]>nfs41: Add bc_svc.o to sunrpc
Makefile.[nfs41: bc_send() does not need to be exported outside RPC module][nfs41: xprt_free_bc_request() need not be exported outside RPC module]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- include/linux/sunrpc/bc_xprt.h | 3 + net/sunrpc/Makefile | 2 +- net/sunrpc/backchannel_rqst.c | 1 - net/sunrpc/bc_svc.c | 80 ++++++++++++++++++++++++++++++++++++++++ net/sunrpc/xprtsock.c | 3 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 net/sunrpc/bc_svc.cinclude/linux/sunrpc/bc_xprt.h +3
-0@@ -29,12 +29,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/sched.h> #ifdef CONFIG_NFS_V4_1 struct rpc_rqst *xprt_alloc_bc_request (struct rpc_xprt *xprt);void xprt_free_bc_request (struct rpc_rqst *req);int xprt_setup_backchannel (struct rpc_xprt *,unsigned int min_reqs);void xprt_destroy_backchannel (struct rpc_xprt *,int max_reqs); +void bc_release_request (struct rpc_task *); +int bc_send (struct rpc_rqst *req);#else /* CONFIG_NFS_V4_1 */ static inline int xprt_setup_backchannel (struct rpc_xprt *xprt,unsigned int min_reqs)net/sunrpc/Makefile +1
-1@@ -13,6 +13,6 @@ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o sched.o \ rpcb_clnt.o timer.o xdr.o \ sunrpc_syms.o cache.o rpc_pipe.o \ svc_xprt.o -sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o +sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o bc_svc.o sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.onet/sunrpc/backchannel_rqst.c +0
-0
net/sunrpc/backchannel_rqst.c void xprt_free_bc_request(struct rpc_rqst *req) · line 268
Quoted 4 lines
net/sunrpc/backchannel_rqst.c +0
-1@@ -265,6 +265,5 @@ void xprt_free_bc_request(struct rpc_rqst *req)list_add (&req->rq_bc_pa_list, &xprt->bc_pa_list);spin_unlock_bh (&xprt->bc_pa_lock); } -EXPORT_SYMBOL (xprt_free_bc_request);
Err.... That's random... What is there in this patch that suddenly makes the export unnecessary?
net/sunrpc/bc_svc.c line 3
Quoted 10 lines
net/sunrpc/backchannel_rqst.c +0
-0#endif /* CONFIG_NFS_V4_1 */ net/sunrpc/bc_svc.c new file +3
-0@@ -0,0 +1,80 @@ +/****************************************************************************** + +(c) 2007 Network Appliance, Inc. All Rights Reserved.
More references to historic entities...
Quoted 91 lines
net/sunrpc/bc_svc.c new file +77
-0+ +Network Appliance provides this source code under the GPL v2 License. +The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +******************************************************************************/ + +/* +* The NFSv4.1 callback service helper routines. +* They implement the transport level processing required to send the +* reply over an existing open connection previously established by the client. +*/ + +#if defined(CONFIG_NFS_V4_1 ) + +#include <linux/module.h> + +#include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/sched.h> +#include <linux/sunrpc/bc_xprt.h> + +#define RPCDBG_FACILITY RPCDBG_SVCDSP + +void bc_release_request (struct rpc_task *task) +{ +struct rpc_rqst *req = task->tk_rqstp; + +dprintk ("RPC: bc_release_request: task= %p\n" , task); + +/* +* Release this request only if it's a backchannel +* preallocated request +*/ +if (!bc_prealloc (req)) +return ; +xprt_free_bc_request (req); +} + +/* Empty callback ops */ +static const struct rpc_call_ops nfs41_callback_ops = { +}; + + +/* +* Send the callback reply +*/ +int bc_send (struct rpc_rqst *req) +{ +struct rpc_task *task; +int ret; + +dprintk ("RPC: bc_send req= %p\n" , req); + task =rpc_run_bc_task (req, &nfs41_callback_ops); +if (IS_ERR (task)) + ret =PTR_ERR (task); +else { +BUG_ON (atomic_read (&task->tk_count) !=1 ); + ret = task->tk_status; +rpc_put_task (task); + } +return ret; +dprintk ("RPC: bc_send ret= %d \n" , ret); +} + +#endif /* CONFIG_NFS_V4_1 */ net/sunrpc/xprtsock.c +3
-0@@ -2145,6 +2145,9 @@ static struct rpc_xprt_ops xs_tcp_ops = { .buf_free = rpc_free, .send_request = xs_tcp_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, +#if defined(CONFIG_NFS_V4_1 ) + .release_request = bc_release_request, +#endif /* CONFIG_NFS_V4_1 */ .close = xs_tcp_shutdown, .destroy = xs_destroy, .print_stats = xs_tcp_print_stats,
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
RE: [pnfs] [RFC 10/39] nfs41: Add backchannel processing support to RPC state machine
In reply to a message not in the archiveQuoted 6 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Thursday, June 04, 2009 12:55 PM
To: Benny Halevy
Cc: Adamson, Andy; [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 10/39] nfs41: Add backchannel processing
support
Quoted 6 lines
to RPC state machine
Quoted 3 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Adds
rpc_run_bc_task()which is called by the NFS callback service
to
Quoted 3 lines
Quoted 1 line
process backchannel requests. It performs similar work to
rpc_run_task()Quoted 1 line
though "schedules" the backchannel task to be executed starting at
the
Quoted 8 lines
Quoted 3 lines
call_trasmitstate in the RPC state machine.It also introduces some miscellaneous updates to the argument
validation,
Quoted 4 lines
call_transmit, and transport cleanup functions to take into account that there are now forechannel and backchannel tasks.Backchannel requests do not carry an RPC message structure, since
the
Quoted 1 line
Quoted 1 line
payload has already been XDR encoded using the existing NFSv4
callback
Quoted 3 lines
Quoted 3 lines
mechanism.
Introduce a new transmit state for the client to reply on to
backchannel
Quoted 1 line
Quoted 1 line
requests. This new state simply reserves the transport and issues
the
Quoted 1 line
Quoted 1 line
reply. In case of a connection related error, disconnects the
transport
Quoted 4 lines
and
Quoted 1 line
drops the reply. It requires the forechannel to re-establish the
connection
Quoted 1 line
and the server to retransmit the request, as stated in NFSv4.1
section
Quoted 3 lines
Quoted 3 lines
2.9.2 "Client and Server Transport Behavior".
Note: There is no need to loop attempting to reserve the transport.
If
Quoted 18 lines
EAGAIN
Quoted 2 lines
is returned by
xprt_prepare_transmit(), return withtk_status== 0, settingtk_actiontocall_bc_transmit.rpc_execute()will invoke itagain
Quoted 10 lines
after the task is taken off the sleep queue.
[nfs41: rpc_run_bc_task() need not be exported outside RPC module][nfs41: New call_bc_transmit RPC state]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>[nfs41: Backchannel: No need to loop in call_bc_transmit()]Signed-off-by Andy Adamson <[email protected]>Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>Quoted 4 lines
--- include/linux/sunrpc/sched.h | 2 + include/linux/sunrpc/xprt.h | 12 ++++ net/sunrpc/clnt.c | 117
Quoted 8 lines
+++++++++++++++++++++++++++++++++++++++++-
Review
Quoted 7 lines
net/sunrpc/stats.c | 6 ++- net/sunrpc/sunrpc.h | 35 +++++++++++++ net/sunrpc/xprt.c | 36 +++++++++++-- 6 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 net/sunrpc/sunrpc.h(quoted diff) +0
-0
b/include/linux/sunrpc/sched.h
Quoted 4 lines
Quoted 4 lines
index 1773768..4010977 100644
include/linux/sunrpc/sched.h +0
-0@@ -210,6 +210,8 @@ struct rpc_wait_queue {
Quoted 8 lines
include/linux/sunrpc/sched.h struct rpc_wait_queue {
Quoted 8 lines
include/linux/sunrpc/sched.h +2
-0*/ struct rpc_task *rpc_new_task (const struct rpc_task_setup *);struct rpc_task *rpc_run_task (const struct rpc_task_setup *); +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, +const struct rpc_call_ops *ops);void rpc_put_task (struct rpc_task *);void rpc_exit_task (struct rpc_task *); void rpc_release_calldata(const struct rpc_call_ops
*, void *);
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/linux/sunrpc/xprt.h
Quoted 7 lines
Quoted 7 lines
index 6b37724..1531abe 100644
include/linux/sunrpc/xprt.h +0
-0@@ -215,6 +215,18 @@ struct rpc_xprt {/* buffer in use */ #endif /* CONFIG_NFS_V4_1 */
Quoted 14 lines
Quoted 4 lines
include/linux/sunrpc/xprt.h +4
-0+#if defined(CONFIG_NFS_V4_1 ) +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return test_bit (RPC_BC_PA_IN_USE , &req->rq_bc_pa_state);include/linux/sunrpc/xprt.h struct rpc_xprt {
Quoted 10 lines
include/linux/sunrpc/xprt.h +8
-0+} +#else +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return 0 ; +} +#endif /* CONFIG_NFS_V4_1 */ +struct xprt_create {int ident;/* XPRT_TRANSPORT
identifier */
Quoted 1 line
include/linux/sunrpc/xprt.h struct rpc_xprt { · line 232
Quoted 1 line
include/linux/sunrpc/xprt.h +0
-0struct sockaddr * srcaddr;/* optional local
address */
Quoted 10 lines
Quoted 10 lines
net/sunrpc/clnt.c +1
-0@@ -36,7 +36,9 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/metrics.h> +#include <linux/sunrpc/bc_xprt.h>
Quoted 5 lines
net/sunrpc/clnt.c static void call_decode(struct rpc_task
Quoted 5 lines
net/sunrpc/clnt.c +1
-0+#include "sunrpc.h" #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_CALL@@ -63,6 +65,9 @@ static void call_decode(struct rpc_task
*task);
Quoted 10 lines
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const
Quoted 10 lines
net/sunrpc/clnt.c +3
-0static void call_bind (struct rpc_task *task);static void call_bind_status (struct rpc_task *task);static void call_transmit (struct rpc_task *task); +#if defined(CONFIG_NFS_V4_1 ) +static void call_bc_transmit (struct rpc_task *task); +#endif /* CONFIG_NFS_V4_1 */ static void call_status (struct rpc_task *task);static void call_transmit_status (struct rpc_task *task);static void call_refresh (struct rpc_task *task);@@ -613,6 +618,50 @@ rpc_call_async(struct rpc_clnt *clnt, const
struct
Quoted 7 lines
rpc_message*msg, int flags,net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 6 lines
net/sunrpc/clnt.c +3
-0}EXPORT_SYMBOL_GPL (rpc_call_async); +#if defined(CONFIG_NFS_V4_1 ) +/** +* rpc_run_bc_task - Allocate a new RPC task for backchannel use,
then
Quoted 6 lines
run
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 5 lines
net/sunrpc/clnt.c +5
-0+* rpc_execute against it +* @ops: RPC call ops +*/ +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, + const struct rpc_call_ops
*tk_ops)
Quoted 52 lines
Quoted 52 lines
net/sunrpc/clnt.c +37
-1+{ +struct rpc_task *task; +struct xdr_buf *xbufp = &req->rq_snd_buf; +struct rpc_task_setup task_setup_data = { + .callback_ops = tk_ops, + }; + +dprintk ("RPC: rpc_run_bc_task req= %p\n" , req); +/* +* Create an rpc_task to send the data +*/ + task =rpc_new_task (&task_setup_data); +if (!task) { +xprt_free_bc_request (req); + goto out; + } + task->tk_rqstp = req; + +/* +* Set up the xdr_buf length. +* This also indicates that the buffer is XDR encoded already. +*/ + xbufp->len = xbufp->head[0 ].iov_len + xbufp->page_len + + xbufp->tail[0 ].iov_len; + + task->tk_action = call_bc_transmit; +atomic_inc (&task->tk_count); +BUG_ON (atomic_read (&task->tk_count) !=2 ); +rpc_execute (task); + +out: +dprintk ("RPC: rpc_run_bc_task: task= %p\n" , task); +return task; +} +#endif /* CONFIG_NFS_V4_1 */ +void rpc_call_start (struct rpc_task *task) {@@ -1098,7 +1147,7 @@ call_transmit(struct rpc_task *task)* in order to allow access to the socket to other RPC requests. */ call_transmit_status (task); -if (task->tk_msg.rpc_proc->p_decode !=NULL ) +if (rpc_reply_expected (task))return ; task->tk_action = rpc_exit_task;rpc_wake_up_queued_task (&task->tk_xprt->pending, task);@@ -1133,6 +1182,72 @@ call_transmit_status(struct rpc_task *task) } }
Quoted 3 lines
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 3 lines
net/sunrpc/clnt.c +3
-0+#if defined(CONFIG_NFS_V4_1 ) +/* +* 5b. Send the backchannel RPC reply. On error, drop the
reply. In
Quoted 14 lines
Quoted 14 lines
net/sunrpc/clnt.c +14
-0+* addition, disconnect on connectivity errors. +*/ +static void +call_bc_transmit (struct rpc_task *task) +{ +struct rpc_rqst *req = task->tk_rqstp; + +BUG_ON (task->tk_status !=0 ); + task->tk_status =xprt_prepare_transmit (task); +if (task->tk_status == -EAGAIN ) { +/* +* Could not reserve the transport. Try again after the +* transport is released. +*/
Quoted 8 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 8 lines
net/sunrpc/clnt.c +8
-0+ task->tk_status =0 ; + task->tk_action = call_bc_transmit; +return ; + } + + task->tk_action = rpc_exit_task; + if (task->tk_status < 0) { + printk(KERN_NOTICE "RPC: Could not send backchannel
reply "
Quoted 10 lines
Quoted 10 lines
net/sunrpc/clnt.c +10
-0+ "error: %d\n", task->tk_status); +return ; + } + +xprt_transmit (task); +xprt_end_transmit (task); +dprint_status (task); +switch (task->tk_status) { +case 0 : +/* Success */
Quoted 8 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 8 lines
net/sunrpc/clnt.c +8
-0+break ; +case -EHOSTDOWN : +case -EHOSTUNREACH : +case -ENETUNREACH : +case -ETIMEDOUT : +/* +* Problem reaching the server. Disconnect and let the +* forechannel reestablish the connection. The server
will
Quoted 2 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task) · line 1229
Quoted 2 lines
net/sunrpc/clnt.c +2
-0+* have to retransmit the backchannel request and we'll +* reprocess it. Since these ops are idempotent,
there's no
Quoted 3 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 3 lines
net/sunrpc/clnt.c +3
-0+* need to cache our reply at this time. +*/ + printk(KERN_NOTICE "RPC: Could not send backchannel
reply "
Quoted 11 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 11 lines
net/sunrpc/clnt.c +11
-0+ "error: %d\n", task->tk_status); +xprt_conditional_disconnect (task->tk_xprt, + req->rq_connect_cookie); +break ; +default : +/* +* We were unable to reply and will have to drop the +* request. The server should reconnect and retransmit. +*/ +BUG_ON (task->tk_status == -EAGAIN ); + printk(KERN_NOTICE "RPC: Could not send backchannel
reply "
Quoted 23 lines
Quoted 23 lines
net/sunrpc/clnt.c +7
-0+ "error: %d\n", task->tk_status); + break; + } +rpc_wake_up_queued_task (&req->rq_xprt->pending, task); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * 6. Sort out the RPC call status */ net/sunrpc/stats.c +1
-1@@ -141,12 +141,14 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);void rpc_count_iostats (struct rpc_task *task) {struct rpc_rqst *req = task->tk_rqstp; -struct rpc_iostats *stats = task->tk_client->cl_metrics; +struct rpc_iostats *stats;struct rpc_iostats *op_metrics;long rtt, execute, queue;
Quoted 5 lines
net/sunrpc/stats.c EXPORT_SYMBOL_GPL(rpc_free_iostats); · line 148
Quoted 2 lines
net/sunrpc/stats.c +1
-1-if (!stats || !req) +if (!task->tk_client || task->tk_client->cl_metrics || !req)When are we going to have a
tk_clientwithout metrics?
The original code checked for stats being non-null, so we're doing the same thing. Having said that, I don't see when cl_metrics could be null either, since rpc_new_client() guarantees its allocation.
I can remove it, but it's not strictly due to functionality in this patch.
Quoted 5 lines
Quoted 5 lines
net/sunrpc/stats.c +2
-0return ; + + stats = task->tk_client->cl_metrics; op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx];
Quoted 9 lines
net/sunrpc/sunrpc.h
Quoted 8 lines
net/sunrpc/stats.c +0
-0op_metrics->om_ops++;net/sunrpc/sunrpc.h new file +0
-0@@ -0,0 +1,35 @@
+/********************************************************************** **
Quoted 6 lines
******
net/sunrpc/sunrpc.h line 4
Quoted 3 lines
net/sunrpc/sunrpc.h new file +3
-0+ +(c) 2008 Network Appliance, Inc. All Rights Reserved. +Ditto...
Will fix.
Quoted 1 line
net/sunrpc/sunrpc.h line 4
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+Network Appliance provides this source code under the GPL v2
License.
Quoted 6 lines
net/sunrpc/sunrpc.h
Quoted 6 lines
net/sunrpc/sunrpc.h new file +6
-0+The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR
Quoted 1 line
net/sunrpc/sunrpc.h line 11
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
Quoted 2 lines
OWNER OR
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL,
Quoted 3 lines
net/sunrpc/sunrpc.h
Quoted 3 lines
net/sunrpc/sunrpc.h new file +3
-0+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF
Quoted 1 line
net/sunrpc/sunrpc.h line 16
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING
Quoted 5 lines
net/sunrpc/sunrpc.h line 20
Quoted 4 lines
net/sunrpc/sunrpc.h new file +3
-0+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +
+***********************************************************************
**
Quoted 15 lines
*****/
net/sunrpc/sunrpc.h line 32
Quoted 11 lines
net/sunrpc/sunrpc.h new file +11
-0+ +/* +* Functions and macros used internally by RPC +*/ + +#ifndef _NET_SUNRPC_SUNRPC_H +#define _NET_SUNRPC_SUNRPC_H + +#define rpc_reply_expected (task) \ + (((task)->tk_msg.rpc_proc != NULL) && \ + ((task)->tk_msg.rpc_proc->p_decode != NULL))Why is this a macro instead of being an inlined function?
My fault, I was still getting acquainted with the difference between macros and inlining. Will change to inlined function.
Quoted 9 lines
net/sunrpc/xprt.c line 12
Quoted 9 lines
net/sunrpc/sunrpc.h new file +3
-0+ +#endif /* _NET_SUNRPC_SUNRPC_H */ +net/sunrpc/xprt.c +0
-0@@ -12,8 +12,9 @@* - Next, the caller puts together the RPC message, stuffs
it into
Quoted 2 lines
net/sunrpc/xprt.c line 14
Quoted 2 lines
net/sunrpc/xprt.c +0
-0* the request struct, and calls xprt_transmit(). * - xprt_transmit sends the message and installs the caller
on the
Quoted 7 lines
net/sunrpc/xprt.c line 15
Quoted 1 line
net/sunrpc/xprt.c +0
-1-* transport's wait list. At the same time, it installs a timer that
Quoted 5 lines
net/sunrpc/xprt.c +3
-1-* is run after the packet's timeout has expired. +* transport's wait list. At the same time, if a reply is expected, +* it installs a timer that is run after the packet's timeout has +* expired. * - When a packet arrives, the data_ready handler walks the
list of
Quoted 7 lines
net/sunrpc/xprt.c line 19
Quoted 1 line
net/sunrpc/xprt.c +0
-0* pending requests for that transport. If a matching XID is found, the
Quoted 5 lines
net/sunrpc/xprt.c +0
-0* caller is woken up, and the timer removed. @@ -46,6 +47,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/metrics.h>
Quoted 7 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task) · line 878
Quoted 7 lines
net/sunrpc/xprt.c +2
-0+#include "sunrpc.h" +/* * Local variables */ @@ -875,7 +878,10 @@ void xprt_transmit(struct rpc_task *task) dprintk("RPC: %5u xprt_transmit(%u)\n", task->tk_pid,
req->rq_slen);
Quoted 4 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task)
Quoted 4 lines
net/sunrpc/xprt.c +1
-1if (!req->rq_received) { -if (list_empty (&req->rq_list)) { + if (list_empty(&req->rq_list) &&
rpc_reply_expected(task)) {
Quoted 2 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task) · line 882
Quoted 2 lines
net/sunrpc/xprt.c +2
-0+/* +* Add to the list only if we're expecting a
reply
Quoted 29 lines
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task
Quoted 20 lines
net/sunrpc/xprt.c +7
-1+*/ spin_lock_bh (&xprt->transport_lock);/* Update the softirq receive buffer */ memcpy(&req->rq_private_buf, &req->rq_rcv_buf,@@ -910,8 +916,13 @@ void xprt_transmit(struct rpc_task *task)/* Don't race with disconnect */ if (!xprt_connected (xprt)) task->tk_status = -ENOTCONN ; -else if (!req->rq_received) +else if (!req->rq_received &&rpc_reply_expected (task)) { +/* +* Sleep on the pending queue since +* we're expecting a reply. +*/ rpc_sleep_on (&xprt->pending, task, xprt_timer); + }spin_unlock_bh (&xprt->transport_lock); }@@ -984,11 +995,15 @@ static void xprt_request_init(struct rpc_task*task, struct
rpc_xprt*xprt)Quoted 8 lines
net/sunrpc/xprt.c +2
-1*/ void xprt_release (struct rpc_task *task) { -struct rpc_xprt *xprt = task->tk_xprt; +struct rpc_xprt *xprt;struct rpc_rqst *req; +int prealloc;
Quoted 4 lines
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) · line 1002
Quoted 1 line
net/sunrpc/xprt.c +1
-0+BUG_ON (atomic_read (&task->tk_count) <0 );Err?
This was useful during early development. Never hit it though :-) So I'll remove it.
Quoted 3 lines
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
Quoted 3 lines
net/sunrpc/xprt.c +1
-0if (!(req = task->tk_rqstp))return ; + prealloc =bc_prealloc (req);/* Preallocated backchannel
request? */
Quoted 16 lines
Quoted 16 lines
net/sunrpc/xprt.c +5
-1+ xprt = req->rq_xprt;rpc_count_iostats (task);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);@@ -1001,10 +1016,19 @@ void xprt_release(struct rpc_task *task)mod_timer (&xprt->timer, xprt->last_used + xprt->idle_timeout);spin_unlock_bh (&xprt->transport_lock); - xprt->ops->buf_free (req->rq_buffer); +if (!bc_prealloc (req)) + xprt->ops->buf_free (req->rq_buffer); task->tk_rqstp =NULL ;if (req->rq_release_snd_buf) req->rq_release_snd_buf (req); + +/*
Quoted 9 lines
net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1030
Quoted 5 lines
net/sunrpc/xprt.c +5
-0+* Early exit if this is a backchannel preallocated request. +* There is no need to have it added to the RPC slot list. +*/ +if (prealloc) +return ;Could we change the name of 'prealloc' to something along the lines of '
is_bc_request'?
Yes, will do.
- ricardo
Quoted 16 lines
net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1034
Quoted 4 lines
net/sunrpc/xprt.c +1
-0+memset (req,0 ,sizeof (*req));/* mark unused */ dprintk ("RPC: %5u release request %p\n" , task->tk_pid, req);--
Trond Myklebust
Linux NFS client maintainerNetApp
[email protected]
www.netapp.com
_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
RE: [pnfs] [RFC 14/39] nfs41: Implement NFSv4.1 callback service process.
In reply to a message not in the archiveQuoted 6 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Thursday, June 04, 2009 1:18 PM
To: Benny Halevy
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 14/39] nfs41: Implement NFSv4.1 callback
service
Quoted 6 lines
process.
Quoted 3 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
nfs41_callback_up()initializes the necessary queues and creates the
new
Quoted 1 line
Quoted 1 line
nfs41_callback_svcthread. This thread executes the callback
service
Quoted 4 lines
which
Quoted 3 lines
waits for requests to arrive on the
svc_serv->sv_cb_list.
NFS41_BC_MIN_CALLBACKSis set to 1 because we expect callbacks to
not
Quoted 3 lines
Quoted 3 lines
cause substantial latency.
The actual processing of the callback will be implemented as a
separate
Quoted 4 lines
patch.
Quoted 3 lines
There is only one NFSv4.1 callback service. The first caller of
nfs4_callback_up()creates the service, subsequent callers increment
a
Quoted 1 line
Quoted 1 line
reference count on the service. The service is destroyed when the
last
Quoted 3 lines
Quoted 3 lines
caller invokes
nfs_callback_down().The transport needs to hold a reference to the callback service in
order
Quoted 1 line
Quoted 1 line
to invoke it during callback processing. Currently this reference
is
Quoted 2 lines
only
Quoted 1 line
obtained when the service is first created. This is incorrect,
since
Quoted 1 line
Quoted 1 line
subsequent registrations for other transports will leave the
xprt->serv
Quoted 4 lines
Quoted 4 lines
pointer uninitialized, leading to an oops when a callback arrives on the "unreferenced" transport.
This patch fixes the problem by ensuring that a reference to the
service
Quoted 1 line
Quoted 1 line
is saved in
xprt->serv, either because the service is created by
this
Quoted 5 lines
Quoted 5 lines
invocation to
nfs4_callback_up()or by a prior invocation.Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>[nfs41: Add a reference to
svc_servduring callback service bring
up]
Quoted 36 lines
Quoted 4 lines
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.c | 83++++++++++++++++++++++++++++++++++++++++++-
Quoted 31 lines
fs/nfs/callback.h | 7 ++++ include/linux/sunrpc/svc.h | 2 + 3 files changed, 90 insertions(+), 2 deletions(-)fs/nfs/callback.c +12
-0@@ -17,6 +17,9 @@#include <linux/freezer.h> #include <linux/kthread.h> #include <linux/sunrpc/svcauth_gss.h> +#if defined(CONFIG_NFS_V4_1 ) +#include <linux/sunrpc/bc_xprt.h> +#endif #include <net/inet_sock.h> @@ -131,6 +134,69 @@ out_err:return ERR_PTR (ret); } +#if defined(CONFIG_NFS_V4_1 ) +/* +* The callback service for NFSv4.1 callbacks +*/ +static int +nfs41_callback_svc (void *vrqstp) +{ +struct svc_rqst *rqstp = vrqstp; +struct svc_serv *serv = rqstp->rq_server;
Quoted 8 lines
fs/nfs/callback.c out_err:
Quoted 8 lines
fs/nfs/callback.c +8
-0+struct rpc_rqst *req; +int error; +DEFINE_WAIT (wq); + +set_freezable (); + +/* +* FIXME: do we really need to run this under the BKL? If so,
please
Quoted 5 lines
fs/nfs/callback.c out_err:
Quoted 5 lines
fs/nfs/callback.c +5
-0+* add a comment about what it's intended to protect. +*/ +lock_kernel (); +while (!kthread_should_stop ()) { + prepare_to_wait(&serv->sv_cb_waitq, &wq,
TASK_INTERRUPTIBLE);
Quoted 9 lines
fs/nfs/callback.c out_err:
Quoted 9 lines
fs/nfs/callback.c +9
-0+spin_lock_bh (&serv->sv_cb_lock); +if (!list_empty (&serv->sv_cb_list)) { + req =list_first_entry (&serv->sv_cb_list, + struct rpc_rqst, rq_bc_list); +list_del (&req->rq_bc_list); +spin_unlock_bh (&serv->sv_cb_lock); +dprintk ("Invoking bc_svc_process()\n" ); + error =bc_svc_process (serv, req, rqstp); + dprintk("bc_svc_process() returned w/ error
code= %d\n",
Quoted 28 lines
Quoted 28 lines
fs/nfs/callback.c +28
-0+ error); + }else { +spin_unlock_bh (&serv->sv_cb_lock); +schedule (); + } +finish_wait (&serv->sv_cb_waitq, &wq); + } +unlock_kernel (); + nfs_callback_info.task =NULL ; +svc_exit_thread (rqstp); +return 0 ; +} + +/* +* Bring up the NFSv4.1 callback service +*/ +struct svc_rqst * +nfs41_callback_up (struct svc_serv *serv,struct rpc_xprt *xprt) +{ +/* +* Save the svc_serv in the transport so that it can +* be referenced when the session backchannel is initialized +*/ + xprt->bc_serv = serv; + +INIT_LIST_HEAD (&serv->sv_cb_list); +spin_lock_init (&serv->sv_cb_lock); +init_waitqueue_head (&serv->sv_cb_waitq);
Quoted 8 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void
Quoted 8 lines
fs/nfs/callback.c +4
-0+ return svc_prepare_thread(serv, &serv->sv_pools[0]); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * Bring up the callback thread if it is not already up. */ @@ -141,10 +207,18 @@ int nfs_callback_up(u32 minorversion, void
*args)
Quoted 10 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 212
Quoted 6 lines
fs/nfs/callback.c +3
-0int (*callback_svc)(void *vrqstp);char svc_name[12 ];int ret =0 ; +#if defined(CONFIG_NFS_V4_1 ) +struct rpc_xprt *xprt = (struct rpc_xprt *)args; +#endif /* CONFIG_NFS_V4_1 */ More ugly embedded ifdefs...
Quoted 1 line
Quoted 3 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args)
Quoted 3 lines
fs/nfs/callback.c +1
-1mutex_lock (&nfs_callback_mutex); -if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL ) +if (nfs_callback_info.users++ || nfs_callback_info.task !=NULL )
{
Quoted 7 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 219
Quoted 4 lines
fs/nfs/callback.c +4
-0+#if defined(CONFIG_NFS_V4_1 ) +if (minorversion) + xprt->bc_serv = nfs_callback_info.serv; +#endif /* CONFIG_NFS_V4_1 */ Ditto
Quoted 7 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args)
Quoted 3 lines
fs/nfs/callback.c +1
-0goto out; + } serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE,NULL);
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void
Quoted 3 lines
fs/nfs/callback.c +0
-0if (!serv) { ret = -ENOMEM ;@@ -157,7 +231,12 @@ int nfs_callback_up(u32 minorversion, void
*args)
Quoted 24 lines
fs/nfs/callback.c int nfs_callback_up(u32 minorversion, void *args) · line 239
Quoted 10 lines
fs/nfs/callback.c +6
-1rqstp =nfs4_callback_up (serv); callback_svc = nfs4_callback_svc; }else { -BUG ();/* for now */ +#if defined(CONFIG_NFS_V4_1 ) + rqstp =nfs41_callback_up (serv, xprt); + callback_svc = nfs41_callback_svc; +#else /* CONFIG_NFS_V4_1 */ +BUG (); +#endif /* CONFIG_NFS_V4_1 */ Ditto
Quoted 11 lines
fs/nfs/callback.c +0
-0}if (IS_ERR (rqstp)) {fs/nfs/callback.h +0
-0@@ -70,6 +70,13 @@ extern void nfs_callback_down(void);#define nfs_callback_down () do {} while(0)#endif
Quoted 3 lines
fs/nfs/callback.h extern void nfs_callback_down(void);
Quoted 3 lines
fs/nfs/callback.h +3
-0+/* +* nfs41: Callbacks are expected to not cause substantial latency, +* so we limit their concurrency to 1 by setting up the maximum
number
Quoted 4 lines
Quoted 4 lines
fs/nfs/callback.h +4
-0+* of slots for the backchannel. +*/ +#define NFS41_BC_MIN_CALLBACKS 1 +
Quoted 8 lines
include/linux/sunrpc/svc.h int svc_set_num_threads(struct
Quoted 8 lines
fs/nfs/callback.h +0
-0extern unsigned int nfs_callback_set_tcpport;extern unsigned short nfs_callback_tcpport;extern unsigned short nfs_callback_tcpport6;include/linux/sunrpc/svc.h +0
-0@@ -419,6 +419,8 @@ int svc_set_num_threads(struct
svc_serv
Quoted 2 lines
*, struct
svc_pool*, int);Quoted 1 line
include/linux/sunrpc/svc.h +0
-0int svc_pool_stats_open(struct svc_serv *serv,
struct file
Quoted 4 lines
*file);
Quoted 3 lines
include/linux/sunrpc/svc.h +1
-0void svc_destroy (struct svc_serv *);int svc_process (struct svc_rqst *); +int bc_svc_process(struct svc_serv *, struct
rpc_rqst *,
Quoted 5 lines
include/linux/sunrpc/svc.h int svc_set_num_threads(struct svc_serv *, struct svc_pool *, int); · line 423
Quoted 1 line
include/linux/sunrpc/svc.h +1
-0+ struct svc_rqst *);OK, I give up. Why is the function text and export declaration in one patch, while the declaration is in this patch?
Will move this declaration to patch 13 along with the function and export declaration. Will also address the ifdefs.
- ricardo
Quoted 1 line
include/linux/sunrpc/svc.h int svc_set_num_threads(struct · line 424
Quoted 1 line
include/linux/sunrpc/svc.h +0
-0int svc_register(const struct svc_serv *, const
int,
Quoted 1 line
include/linux/sunrpc/svc.h int svc_set_num_threads(struct · line 425
Quoted 1 line
include/linux/sunrpc/svc.h +0
-0const unsigned short, const unsigned
short);
Quoted 13 lines
Quoted 1 line
--
Trond Myklebust
Linux NFS client maintainerNetApp
[email protected]
www.netapp.com
_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
RE: [pnfs] [RFC 11/39] nfs41: Backchannel callback service helper routines
In reply to a message not in the archiveQuoted 6 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Thursday, June 04, 2009 1:21 PM
To: Benny Halevy
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 11/39] nfs41: Backchannel callback service
helper
Quoted 14 lines
routines
Quoted 11 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Executes the backchannel task on the RPC state machine using the existing open connection previously established by the client.
Signed-off-by Ricardo Labiaga <[email protected]>nfs41: Add bc_svc.o to sunrpc
Makefile.[nfs41:
bc_send()does not need to be exported outside RPC module] [nfs41:xprt_free_bc_request()need not be exported outside RPC
module]
Quoted 12 lines
Quoted 7 lines
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- include/linux/sunrpc/bc_xprt.h | 3 + net/sunrpc/Makefile | 2 +- net/sunrpc/backchannel_rqst.c | 1 - net/sunrpc/bc_svc.c | 80++++++++++++++++++++++++++++++++++++++++
Quoted 4 lines
net/sunrpc/xprtsock.c | 3 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 net/sunrpc/bc_svc.c
Quoted 6 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/linux/sunrpc/bc_xprt.hinclude/linux/sunrpc/bc_xprt.h SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Quoted 4 lines
index 1c1746a..3016c00 100644
include/linux/sunrpc/bc_xprt.h +0
-0@@ -29,12 +29,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH
Quoted 10 lines
DAMAGE.
Quoted 9 lines
include/linux/sunrpc/bc_xprt.h +1
-0#include <linux/sunrpc/svcsock.h> #include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/sched.h> #ifdef CONFIG_NFS_V4_1 struct rpc_rqst *xprt_alloc_bc_request (struct rpc_xprt *xprt);void xprt_free_bc_request (struct rpc_rqst *req); int xprt_setup_backchannel(struct rpc_xprt *, unsigned int
min_reqs);
Quoted 11 lines
net/sunrpc/Makefile sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o
Quoted 11 lines
include/linux/sunrpc/bc_xprt.h +2
-0void xprt_destroy_backchannel (struct rpc_xprt *,int max_reqs); +void bc_release_request (struct rpc_task *); +int bc_send (struct rpc_rqst *req);#else /* CONFIG_NFS_V4_1 */ static inline int xprt_setup_backchannel (struct rpc_xprt *xprt,unsigned int min_reqs)net/sunrpc/Makefile +0
-0@@ -13,6 +13,6 @@ sunrpc-y := clnt.o xprt.o socklib.o xprtsock.o
sched.o
Quoted 10 lines
\
Review
Quoted 8 lines
net/sunrpc/Makefile +1
-1rpcb_clnt.o timer.o xdr.o \ sunrpc_syms.o cache.o rpc_pipe.o \ svc_xprt.o -sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o +sunrpc-$(CONFIG_NFS_V4_1) += backchannel_rqst.o bc_svc.o sunrpc-$(CONFIG_PROC_FS) += stats.o sunrpc-$(CONFIG_SYSCTL) += sysctl.o(quoted diff) +0
-0
b/net/sunrpc/backchannel_rqst.c
Quoted 10 lines
net/sunrpc/backchannel_rqst.c void xprt_free_bc_request(struct rpc_rqst *req) · line 268
Quoted 8 lines
index 7d7708a..92fb3bd 100644
net/sunrpc/backchannel_rqst.c +0
-1@@ -265,6 +265,5 @@ void xprt_free_bc_request(struct rpc_rqst *req)list_add (&req->rq_bc_pa_list, &xprt->bc_pa_list);spin_unlock_bh (&xprt->bc_pa_lock); } -EXPORT_SYMBOL (xprt_free_bc_request);Err.... That's random... What is there in this patch that suddenly
makes
Quoted 2 lines
the export unnecessary?
Squashing mistake. We should have never exported the 'xprt_free_bc_request' symbol since it is not needed outside sunrpc. We'll update patch 0007 to remove the EXPORT_SYMBOL all together.
Quoted 9 lines
net/sunrpc/bc_svc.c
Quoted 8 lines
net/sunrpc/backchannel_rqst.c +0
-0#endif /* CONFIG_NFS_V4_1 */ net/sunrpc/bc_svc.c new file +0
-0@@ -0,0 +1,80 @@
+/********************************************************************** **
Quoted 6 lines
******
net/sunrpc/bc_svc.c line 3
Quoted 2 lines
net/sunrpc/bc_svc.c new file +2
-0+ +(c) 2007 Network Appliance, Inc. All Rights Reserved.More references to historic entities...
We'll update.
- ricardo
Quoted 2 lines
net/sunrpc/bc_svc.c line 4
Quoted 2 lines
net/sunrpc/bc_svc.c new file +2
-0+ +Network Appliance provides this source code under the GPL v2
License.
Quoted 6 lines
net/sunrpc/bc_svc.c
Quoted 6 lines
net/sunrpc/bc_svc.c new file +6
-0+The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR
Quoted 1 line
net/sunrpc/bc_svc.c line 11
Quoted 1 line
net/sunrpc/bc_svc.c new file +1
-0+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT
Quoted 2 lines
OWNER OR
Quoted 1 line
net/sunrpc/bc_svc.c new file +1
-0+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL,
Quoted 3 lines
net/sunrpc/bc_svc.c
Quoted 3 lines
net/sunrpc/bc_svc.c new file +3
-0+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF
Quoted 1 line
net/sunrpc/bc_svc.c line 16
Quoted 1 line
net/sunrpc/bc_svc.c new file +1
-0+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING
Quoted 5 lines
net/sunrpc/bc_svc.c line 20
Quoted 4 lines
net/sunrpc/bc_svc.c new file +3
-0+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +
+***********************************************************************
**
Quoted 5 lines
*****/
net/sunrpc/bc_svc.c
Quoted 4 lines
net/sunrpc/bc_svc.c new file +4
-0+ +/* +* The NFSv4.1 callback service helper routines. +* They implement the transport level processing required to send
the
Quoted 1 line
net/sunrpc/bc_svc.c line 24
Quoted 1 line
net/sunrpc/bc_svc.c new file +1
-0+* reply over an existing open connection previously established by
the
Quoted 81 lines
client.
Quoted 59 lines
net/sunrpc/bc_svc.c new file +54
-0+*/ + +#if defined(CONFIG_NFS_V4_1 ) + +#include <linux/module.h> + +#include <linux/sunrpc/xprt.h> +#include <linux/sunrpc/sched.h> +#include <linux/sunrpc/bc_xprt.h> + +#define RPCDBG_FACILITY RPCDBG_SVCDSP + +void bc_release_request (struct rpc_task *task) +{ +struct rpc_rqst *req = task->tk_rqstp; + +dprintk ("RPC: bc_release_request: task= %p\n" , task); + +/* +* Release this request only if it's a backchannel +* preallocated request +*/ +if (!bc_prealloc (req)) +return ; +xprt_free_bc_request (req); +} + +/* Empty callback ops */ +static const struct rpc_call_ops nfs41_callback_ops = { +}; + + +/* +* Send the callback reply +*/ +int bc_send (struct rpc_rqst *req) +{ +struct rpc_task *task; +int ret; + +dprintk ("RPC: bc_send req= %p\n" , req); + task =rpc_run_bc_task (req, &nfs41_callback_ops); +if (IS_ERR (task)) + ret =PTR_ERR (task); +else { +BUG_ON (atomic_read (&task->tk_count) !=1 ); + ret = task->tk_status; +rpc_put_task (task); + } +return ret; +dprintk ("RPC: bc_send ret= %d \n" , ret); +} + +#endif /* CONFIG_NFS_V4_1 */ net/sunrpc/xprtsock.c +0
-0net/sunrpc/xprtsock.c static struct rpc_xprt_ops xs_tcp_ops = { · line 2153
Quoted 9 lines
net/sunrpc/xprtsock.c +3
-0@@ -2145,6 +2145,9 @@ static struct rpc_xprt_ops xs_tcp_ops = { .buf_free = rpc_free, .send_request = xs_tcp_send_request, .set_retrans_timeout = xprt_set_retrans_timeout_def, +#if defined(CONFIG_NFS_V4_1 ) + .release_request = bc_release_request, +#endif /* CONFIG_NFS_V4_1 */ .close = xs_tcp_shutdown, .destroy = xs_destroy, .print_stats = xs_tcp_print_stats,--
Trond Myklebust
Linux NFS client maintainerNetApp
[email protected]
www.netapp.com
_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
RE: [pnfs] [RFC 10/39] nfs41: Add backchannel processing support toRPC state machine
In reply to a message not in the archiveQuoted 6 lines
-----Original Message-----
From: Labiaga, Ricardo
Sent: Friday, June 05, 2009 10:44 AM
To: Myklebust, Trond; Benny Halevy
Cc: [email protected]; Adamson, Andy; [email protected]
Subject: Re: [pnfs] [RFC 10/39] nfs41: Add backchannel processing
support
Quoted 12 lines
toRPC state machine
Quoted 6 lines
-----Original Message-----
From: Myklebust, Trond
Sent: Thursday, June 04, 2009 12:55 PM
To: Benny Halevy
Cc: Adamson, Andy; [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 10/39] nfs41: Add backchannel processingsupport
Quoted 3 lines
to RPC state machine
On Fri, 2009-05-01 at 02:20 +0300, Benny Halevy wrote:
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
From: Ricardo Labiaga <[email protected]>
Adds
rpc_run_bc_task()which is called by the NFS callback serviceto
Quoted 3 lines
Quoted 1 line
process backchannel requests. It performs similar work to
rpc_run_task()Quoted 1 line
though "schedules" the backchannel task to be executed starting at
the
Quoted 5 lines
Quoted 3 lines
call_trasmitstate in the RPC state machine.It also introduces some miscellaneous updates to the argument
validation,
Quoted 1 line
call_transmit, and transport cleanup functions to take into
account
Quoted 11 lines
Quoted 3 lines
Quoted 3 lines
that there are now forechannel and backchannel tasks.
Backchannel requests do not carry an RPC message structure, since
the
Quoted 1 line
Quoted 1 line
payload has already been XDR encoded using the existing NFSv4
callback
Quoted 3 lines
Quoted 3 lines
mechanism.
Introduce a new transmit state for the client to reply on to
backchannel
Quoted 1 line
Quoted 1 line
requests. This new state simply reserves the transport and issues
Quoted 11 lines
the
Quoted 1 line
Quoted 1 line
reply. In case of a connection related error, disconnects the
transport
Quoted 4 lines
and
Quoted 1 line
drops the reply. It requires the forechannel to re-establish the
connection
Quoted 1 line
and the server to retransmit the request, as stated in NFSv4.1
section
Quoted 3 lines
Quoted 3 lines
2.9.2 "Client and Server Transport Behavior".
Note: There is no need to loop attempting to reserve the
transport.
Quoted 3 lines
If
Quoted 2 lines
EAGAIN
Quoted 1 line
is returned by
xprt_prepare_transmit(), return withtk_status==
0,
Quoted 1 line
Quoted 1 line
Quoted 1 line
setting
tk_actiontocall_bc_transmit.rpc_execute()will invoke
it
Quoted 245 lines
Quoted 15 lines
again
Quoted 10 lines
after the task is taken off the sleep queue.
[nfs41: rpc_run_bc_task() need not be exported outside RPC module][nfs41: New call_bc_transmit RPC state]Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>[nfs41: Backchannel: No need to loop in call_bc_transmit()]Signed-off-by Andy Adamson <[email protected]>Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>Quoted 4 lines
--- include/linux/sunrpc/sched.h | 2 + include/linux/sunrpc/xprt.h | 12 ++++ net/sunrpc/clnt.c | 117Quoted 8 lines
+++++++++++++++++++++++++++++++++++++++++-
Review
Quoted 7 lines
net/sunrpc/stats.c | 6 ++- net/sunrpc/sunrpc.h | 35 +++++++++++++ net/sunrpc/xprt.c | 36 +++++++++++-- 6 files changed, 199 insertions(+), 9 deletions(-) create mode 100644 net/sunrpc/sunrpc.h(quoted diff) +0
-0
b/include/linux/sunrpc/sched.hQuoted 4 lines
Quoted 4 lines
index 1773768..4010977 100644
include/linux/sunrpc/sched.h +0
-0@@ -210,6 +210,8 @@ struct rpc_wait_queue {Quoted 8 lines
include/linux/sunrpc/sched.h struct rpc_wait_queue {
Quoted 8 lines
include/linux/sunrpc/sched.h +2
-0*/ struct rpc_task *rpc_new_task (const struct rpc_task_setup *);struct rpc_task *rpc_run_task (const struct rpc_task_setup *); +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, +const struct rpc_call_ops *ops);void rpc_put_task (struct rpc_task *);void rpc_exit_task (struct rpc_task *); void rpc_release_calldata(const struct rpc_call_ops*, void *);
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/include/linux/sunrpc/xprt.hQuoted 7 lines
Quoted 7 lines
index 6b37724..1531abe 100644
include/linux/sunrpc/xprt.h +0
-0@@ -215,6 +215,18 @@ struct rpc_xprt {/* buffer in use */ #endif /* CONFIG_NFS_V4_1 */ Quoted 14 lines
Quoted 4 lines
include/linux/sunrpc/xprt.h +4
-0+#if defined(CONFIG_NFS_V4_1 ) +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return test_bit (RPC_BC_PA_IN_USE , &req->rq_bc_pa_state);include/linux/sunrpc/xprt.h struct rpc_xprt {
Quoted 10 lines
include/linux/sunrpc/xprt.h +8
-0+} +#else +static inline int bc_prealloc (struct rpc_rqst *req) +{ +return 0 ; +} +#endif /* CONFIG_NFS_V4_1 */ +struct xprt_create {int ident;/* XPRT_TRANSPORT identifier */
Quoted 1 line
include/linux/sunrpc/xprt.h struct rpc_xprt { · line 232
Quoted 1 line
include/linux/sunrpc/xprt.h +0
-0struct sockaddr * srcaddr;/* optional local address */
Quoted 10 lines
Quoted 10 lines
net/sunrpc/clnt.c +1
-0@@ -36,7 +36,9 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/metrics.h> +#include <linux/sunrpc/bc_xprt.h> Quoted 5 lines
net/sunrpc/clnt.c static void call_decode(struct rpc_task
Quoted 5 lines
net/sunrpc/clnt.c +1
-0+#include "sunrpc.h" #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_CALL@@ -63,6 +65,9 @@ static void call_decode(struct rpc_task*task);
Quoted 10 lines
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const
Quoted 10 lines
net/sunrpc/clnt.c +3
-0static void call_bind (struct rpc_task *task);static void call_bind_status (struct rpc_task *task);static void call_transmit (struct rpc_task *task); +#if defined(CONFIG_NFS_V4_1 ) +static void call_bc_transmit (struct rpc_task *task); +#endif /* CONFIG_NFS_V4_1 */ static void call_status (struct rpc_task *task);static void call_transmit_status (struct rpc_task *task);static void call_refresh (struct rpc_task *task);@@ -613,6 +618,50 @@ rpc_call_async(struct rpc_clnt *clnt, conststruct
Quoted 7 lines
rpc_message*msg, int flags,net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 6 lines
net/sunrpc/clnt.c +3
-0}EXPORT_SYMBOL_GPL (rpc_call_async); +#if defined(CONFIG_NFS_V4_1 ) +/** +* rpc_run_bc_task - Allocate a new RPC task for backchannel use, then
Quoted 6 lines
run
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 5 lines
net/sunrpc/clnt.c +5
-0+* rpc_execute against it +* @ops: RPC call ops +*/ +struct rpc_task *rpc_run_bc_task (struct rpc_rqst *req, + const struct rpc_call_ops
*tk_ops)Quoted 52 lines
Quoted 52 lines
net/sunrpc/clnt.c +37
-1+{ +struct rpc_task *task; +struct xdr_buf *xbufp = &req->rq_snd_buf; +struct rpc_task_setup task_setup_data = { + .callback_ops = tk_ops, + }; + +dprintk ("RPC: rpc_run_bc_task req= %p\n" , req); +/* +* Create an rpc_task to send the data +*/ + task =rpc_new_task (&task_setup_data); +if (!task) { +xprt_free_bc_request (req); + goto out; + } + task->tk_rqstp = req; + +/* +* Set up the xdr_buf length. +* This also indicates that the buffer is XDR encoded already. +*/ + xbufp->len = xbufp->head[0 ].iov_len + xbufp->page_len + + xbufp->tail[0 ].iov_len; + + task->tk_action = call_bc_transmit; +atomic_inc (&task->tk_count); +BUG_ON (atomic_read (&task->tk_count) !=2 ); +rpc_execute (task); + +out: +dprintk ("RPC: rpc_run_bc_task: task= %p\n" , task); +return task; +} +#endif /* CONFIG_NFS_V4_1 */ +void rpc_call_start (struct rpc_task *task) {@@ -1098,7 +1147,7 @@ call_transmit(struct rpc_task *task)* in order to allow access to the socket to other RPC requests. */ call_transmit_status (task); -if (task->tk_msg.rpc_proc->p_decode !=NULL ) +if (rpc_reply_expected (task))return ; task->tk_action = rpc_exit_task;rpc_wake_up_queued_task (&task->tk_xprt->pending, task);@@ -1133,6 +1182,72 @@ call_transmit_status(struct rpc_task *task) } }Quoted 3 lines
net/sunrpc/clnt.c rpc_call_async(struct rpc_clnt *clnt, const struct rpc_message *msg, int flags,
Quoted 3 lines
net/sunrpc/clnt.c +3
-0+#if defined(CONFIG_NFS_V4_1 ) +/* +* 5b. Send the backchannel RPC reply. On error, drop the reply. In
Quoted 14 lines
Quoted 14 lines
net/sunrpc/clnt.c +14
-0+* addition, disconnect on connectivity errors. +*/ +static void +call_bc_transmit (struct rpc_task *task) +{ +struct rpc_rqst *req = task->tk_rqstp; + +BUG_ON (task->tk_status !=0 ); + task->tk_status =xprt_prepare_transmit (task); +if (task->tk_status == -EAGAIN ) { +/* +* Could not reserve the transport. Try again after the +* transport is released. +*/ Quoted 8 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 8 lines
net/sunrpc/clnt.c +8
-0+ task->tk_status =0 ; + task->tk_action = call_bc_transmit; +return ; + } + + task->tk_action = rpc_exit_task; + if (task->tk_status < 0) { + printk(KERN_NOTICE "RPC: Could not send backchannelreply "
Quoted 10 lines
Quoted 10 lines
net/sunrpc/clnt.c +10
-0+ "error: %d\n", task->tk_status); +return ; + } + +xprt_transmit (task); +xprt_end_transmit (task); +dprint_status (task); +switch (task->tk_status) { +case 0 : +/* Success */ Quoted 8 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 8 lines
net/sunrpc/clnt.c +8
-0+break ; +case -EHOSTDOWN : +case -EHOSTUNREACH : +case -ENETUNREACH : +case -ETIMEDOUT : +/* +* Problem reaching the server. Disconnect and let the +* forechannel reestablish the connection. The server will
Quoted 2 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task) · line 1229
Quoted 2 lines
net/sunrpc/clnt.c +2
-0+* have to retransmit the backchannel request and we'll +* reprocess it. Since these ops are idempotent, there's no
Quoted 3 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 3 lines
net/sunrpc/clnt.c +3
-0+* need to cache our reply at this time. +*/ + printk(KERN_NOTICE "RPC: Could not send backchannelreply "
Quoted 11 lines
net/sunrpc/clnt.c call_transmit_status(struct rpc_task *task)
Quoted 11 lines
net/sunrpc/clnt.c +11
-0+ "error: %d\n", task->tk_status); +xprt_conditional_disconnect (task->tk_xprt, + req->rq_connect_cookie); +break ; +default : +/* +* We were unable to reply and will have to drop the +* request. The server should reconnect and retransmit. +*/ +BUG_ON (task->tk_status == -EAGAIN ); + printk(KERN_NOTICE "RPC: Could not send backchannelreply "
Quoted 23 lines
Quoted 23 lines
net/sunrpc/clnt.c +7
-0+ "error: %d\n", task->tk_status); + break; + } +rpc_wake_up_queued_task (&req->rq_xprt->pending, task); +} +#endif /* CONFIG_NFS_V4_1 */ +/* * 6. Sort out the RPC call status */ net/sunrpc/stats.c +1
-1@@ -141,12 +141,14 @@ EXPORT_SYMBOL_GPL(rpc_free_iostats);void rpc_count_iostats (struct rpc_task *task) {struct rpc_rqst *req = task->tk_rqstp; -struct rpc_iostats *stats = task->tk_client->cl_metrics; +struct rpc_iostats *stats;struct rpc_iostats *op_metrics;long rtt, execute, queue;
Quoted 8 lines
Quoted 5 lines
net/sunrpc/stats.c EXPORT_SYMBOL_GPL(rpc_free_iostats); · line 148
Quoted 2 lines
net/sunrpc/stats.c +1
-1-if (!stats || !req) +if (!task->tk_client || task->tk_client->cl_metrics || !req)When are we going to have a
tk_clientwithout metrics?The original code checked for stats being non-null, so we're doing the same thing. Having said that, I don't see when
cl_metricscould be
null
Quoted 4 lines
either, since
rpc_new_client()guarantees its allocation.I can remove it, but it's not strictly due to functionality in this patch.
I mis-read the patch. We are indeed doing the wrong thing. Should be taking the early exit if !task->tk_client->cl_metrics instead. I'll fix it.
- ricardo
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
net/sunrpc/stats.c +2
-0return ; + + stats = task->tk_client->cl_metrics; op_metrics = &stats[task->tk_msg.rpc_proc->p_statidx];
Quoted 10 lines
Quoted 9 lines
net/sunrpc/sunrpc.h
Quoted 8 lines
net/sunrpc/stats.c +0
-0op_metrics->om_ops++;net/sunrpc/sunrpc.h new file +0
-0@@ -0,0 +1,35 @@
+/**********************************************************************
Quoted 8 lines
**
Quoted 6 lines
******
net/sunrpc/sunrpc.h line 4
Quoted 3 lines
net/sunrpc/sunrpc.h new file +3
-0+ +(c) 2008 Network Appliance, Inc. All Rights Reserved. +Ditto...
Quoted 8 lines
Will fix.
Quoted 1 line
net/sunrpc/sunrpc.h line 4
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+Network Appliance provides this source code under the GPL v2License.
Quoted 4 lines
net/sunrpc/sunrpc.h
Quoted 4 lines
net/sunrpc/sunrpc.h new file +4
-0+The GPL v2 license is available at +http://opensource.org/licenses/gpl-license.php. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS
Quoted 9 lines
Quoted 2 lines
net/sunrpc/sunrpc.h line 10
Quoted 2 lines
net/sunrpc/sunrpc.h new file +2
-0+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESSFOR
Quoted 1 line
net/sunrpc/sunrpc.h line 11
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THECOPYRIGHT
Quoted 2 lines
OWNER OR
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,SPECIAL,
Quoted 1 line
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO,
Quoted 1 line
Quoted 1 line
net/sunrpc/sunrpc.h line 14
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR
Quoted 1 line
Quoted 1 line
net/sunrpc/sunrpc.h line 15
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY
Quoted 4 lines
OF
Quoted 1 line
net/sunrpc/sunrpc.h line 16
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING
Quoted 1 line
Quoted 1 line
net/sunrpc/sunrpc.h new file +1
-0+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS
Quoted 5 lines
Quoted 4 lines
net/sunrpc/sunrpc.h line 19
Quoted 3 lines
net/sunrpc/sunrpc.h new file +2
-0+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +
+***********************************************************************
Quoted 30 lines
**
Quoted 15 lines
*****/
net/sunrpc/sunrpc.h line 32
Quoted 11 lines
net/sunrpc/sunrpc.h new file +11
-0+ +/* +* Functions and macros used internally by RPC +*/ + +#ifndef _NET_SUNRPC_SUNRPC_H +#define _NET_SUNRPC_SUNRPC_H + +#define rpc_reply_expected (task) \ + (((task)->tk_msg.rpc_proc != NULL) && \ + ((task)->tk_msg.rpc_proc->p_decode != NULL))Why is this a macro instead of being an inlined function?
My fault, I was still getting acquainted with the difference between macros and inlining. Will change to inlined function.
Quoted 9 lines
net/sunrpc/xprt.c line 12
Quoted 9 lines
net/sunrpc/sunrpc.h new file +3
-0+ +#endif /* _NET_SUNRPC_SUNRPC_H */ +net/sunrpc/xprt.c +0
-0@@ -12,8 +12,9 @@* - Next, the caller puts together the RPC message, stuffs it into
Quoted 4 lines
Quoted 2 lines
net/sunrpc/xprt.c line 14
Quoted 2 lines
net/sunrpc/xprt.c +0
-0* the request struct, and calls xprt_transmit(). * - xprt_transmit sends the message and installs the caller on the
Quoted 1 line
Quoted 1 line
net/sunrpc/xprt.c +0
-1-* transport's wait list. At the same time, it installs a
timer
Quoted 3 lines
Quoted 3 lines
that
Quoted 2 lines
net/sunrpc/xprt.c +1
-1-* is run after the packet's timeout has expired. +* transport's wait list. At the same time, if a reply is
expected,
Quoted 1 line
Quoted 1 line
net/sunrpc/xprt.c line 16
Quoted 1 line
net/sunrpc/xprt.c +1
-0+* it installs a timer that is run after the packet's
timeout has
Quoted 4 lines
Quoted 2 lines
net/sunrpc/xprt.c line 18
Quoted 2 lines
net/sunrpc/xprt.c +1
-0+* expired. * - When a packet arrives, the data_ready handler walks the list of
Quoted 1 line
Quoted 1 line
net/sunrpc/xprt.c +0
-0* pending requests for that transport. If a matching XID
is found,
Quoted 41 lines
Quoted 6 lines
the
Quoted 5 lines
net/sunrpc/xprt.c +0
-0* caller is woken up, and the timer removed. @@ -46,6 +47,8 @@#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/metrics.h> Quoted 7 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task) · line 878
Quoted 7 lines
net/sunrpc/xprt.c +2
-0+#include "sunrpc.h" +/* * Local variables */ @@ -875,7 +878,10 @@ void xprt_transmit(struct rpc_task *task) dprintk("RPC: %5u xprt_transmit(%u)\n", task->tk_pid,
req->rq_slen);Quoted 4 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task)
Quoted 4 lines
net/sunrpc/xprt.c +1
-1if (!req->rq_received) { -if (list_empty (&req->rq_list)) { + if (list_empty(&req->rq_list) &&
rpc_reply_expected(task)) {Quoted 2 lines
net/sunrpc/xprt.c void xprt_transmit(struct rpc_task *task) · line 882
Quoted 2 lines
net/sunrpc/xprt.c +2
-0+/* +* Add to the list only if we're expecting a reply
Quoted 19 lines
Quoted 19 lines
net/sunrpc/xprt.c +7
-1+*/ spin_lock_bh (&xprt->transport_lock);/* Update the softirq receive buffer */ memcpy(&req->rq_private_buf, &req->rq_rcv_buf,@@ -910,8 +916,13 @@ void xprt_transmit(struct rpc_task *task)/* Don't race with disconnect */ if (!xprt_connected (xprt)) task->tk_status = -ENOTCONN ; -else if (!req->rq_received) +else if (!req->rq_received &&rpc_reply_expected (task)) { +/* +* Sleep on the pending queue since +* we're expecting a reply. +*/ rpc_sleep_on (&xprt->pending, task, xprt_timer); + }spin_unlock_bh (&xprt->transport_lock); }
Quoted 1 line
Quoted 1 line
net/sunrpc/xprt.c static void xprt_request_init(struct
Quoted 1 line
net/sunrpc/xprt.c +0
-0@@ -984,11 +995,15 @@ static void xprt_request_init(struct
rpc_task
Quoted 14 lines
Quoted 9 lines
*task, struct
rpc_xprt*xprt)Quoted 8 lines
net/sunrpc/xprt.c +2
-1*/ void xprt_release (struct rpc_task *task) { -struct rpc_xprt *xprt = task->tk_xprt; +struct rpc_xprt *xprt;struct rpc_rqst *req; +int prealloc;Quoted 4 lines
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt) · line 1002
Quoted 1 line
net/sunrpc/xprt.c +1
-0+BUG_ON (atomic_read (&task->tk_count) <0 );Err?
Quoted 31 lines
This was useful during early development. Never hit it though :-) So I'll remove it.
Quoted 3 lines
net/sunrpc/xprt.c static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
Quoted 3 lines
net/sunrpc/xprt.c +1
-0if (!(req = task->tk_rqstp))return ; + prealloc =bc_prealloc (req);/* Preallocated backchannel request? */
Quoted 23 lines
Quoted 11 lines
net/sunrpc/xprt.c +3
-1+ xprt = req->rq_xprt;rpc_count_iostats (task);spin_lock_bh (&xprt->transport_lock); xprt->ops->release_xprt (xprt, task);@@ -1001,10 +1016,19 @@ void xprt_release(struct rpc_task *task)mod_timer (&xprt->timer, xprt->last_used + xprt->idle_timeout);spin_unlock_bh (&xprt->transport_lock); - xprt->ops->buf_free (req->rq_buffer); +if (!bc_prealloc (req)) + xprt->ops->buf_free (req->rq_buffer);net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1030
Quoted 10 lines
net/sunrpc/xprt.c +7
-0task->tk_rqstp =NULL ;if (req->rq_release_snd_buf) req->rq_release_snd_buf (req); + +/* +* Early exit if this is a backchannel preallocated request. +* There is no need to have it added to the RPC slot list. +*/ +if (prealloc) +return ;Could we change the name of 'prealloc' to something along the lines
of
Quoted 5 lines
Quoted 2 lines
'
is_bc_request'?Yes, will do.
I removed the variable altogether. Calling bc_prealloc() directly since it's now an inline function that checks if a bit is set.
- ricardo
Quoted 22 lines
- ricardo
Quoted 9 lines
net/sunrpc/xprt.c void xprt_release(struct rpc_task *task) · line 1034
Quoted 4 lines
net/sunrpc/xprt.c +1
-0+memset (req,0 ,sizeof (*req));/* mark unused */ dprintk ("RPC: %5u release request %p\n" , task->tk_pid, req);--
Trond Myklebust
Linux NFS client maintainerQuoted 7 lines
NetApp
[email protected]
www.netapp.com
_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs_______________________________________________
pNFS mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs
Re: [pnfs] [RFC 25/39] nfs41: decode minorversion 1 cb_compound header
In reply to Benny HalevyQuoted 34 lines · Benny Halevy
decode
cb_compoundheader conforming to
http://tools.ietf.org/html/draft-ietf-nfsv4-minorversion1-26Get rid of cb_compound_hdr_arg.callback_ident
callback_identis not used anywhere so we shouldn't waste any memory to store it.Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.h | 1 - fs/nfs/callback_xdr.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)fs/nfs/callback.h +0
-1@@ -27,7 +27,6 @@ struct cb_compound_hdr_arg {unsigned int taglen;const char *tag;unsigned int minorversion; -unsigned int callback_ident;unsigned nops; };fs/nfs/callback_xdr.c +0
-0@@ -143,18 +143,22 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound __func__, hdr->taglen);return htonl (NFS4ERR_RESOURCE ); }
fs/nfs/callback_xdr.c static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · line 152
Quoted 10 lines
fs/nfs/callback_xdr.c +4
-3- p =read_buf (xdr,12 ); + p =read_buf (xdr,4 );if (unlikely (p ==NULL ))return htonl (NFS4ERR_RESOURCE ); hdr->minorversion =ntohl (*p++); -/* Check minor version is zero. */ -if (hdr->minorversion !=0 ) { +/* Check minor version is zero or one. */ +if (hdr->minorversion <=1 ) { + p =read_buf (xdr,8 );
What is the point of splitting the read_buf() here? That seems very unnecessary...
Quoted 13 lines
fs/nfs/callback_xdr.c +4
-1+if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + p++;/* skip callback_ident */ + }else {printk (KERN_WARNING "%s: NFSv4 server callback with " "illegal minor version %u!\n" , __func__, hdr->minorversion);return htonl (NFS4ERR_MINOR_VERS_MISMATCH ); } - hdr->callback_ident =ntohl (*p++); hdr->nops =ntohl (*p);dprintk ("%s: minorversion %d nops %d\n" , __func__, hdr->minorversion, hdr->nops);
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 27/39] nfs41: consider minorversion in callback_xdr:process_op
In reply to Benny HalevyQuoted 60 lines · Benny Halevy
Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_xdr.c | 63 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 50 insertions(+), 13 deletions(-)fs/nfs/callback_xdr.c +25
-11@@ -359,31 +359,61 @@ out:return status; } -static __be32 process_op (struct svc_rqst *rqstp, +static __be32 process_op (uint32_t minorversion,int nop, +struct svc_rqst *rqstp,struct xdr_stream *xdr_in,void *argp,struct xdr_stream *xdr_out,void *resp) {struct callback_op *op = &callback_ops[0 ];unsigned int op_nr =OP_CB_ILLEGAL ; -__be32 status =0 ; +__be32 status;long maxlen;__be32 res;dprintk ("%s: start\n" , __func__); status =decode_op_hdr (xdr_in, &op_nr); -if (likely (status ==0 )) { +if (unlikely (status)) + goto out_illegal; + +dprintk ("%s: minorversion=%d nop=%d op_nr=%u\n" , + __func__, minorversion, nop, op_nr); +#if defined(CONFIG_NFS_V4_1 ) +if (minorversion ==1 ) {switch (op_nr) { -case OP_CB_GETATTR : -case OP_CB_RECALL : - op = &callback_ops[op_nr]; -break ; -default : - op_nr =OP_CB_ILLEGAL ; - op = &callback_ops[0 ]; - status =htonl (NFS4ERR_OP_ILLEGAL ); +case OP_CB_GETATTR : +case OP_CB_RECALL : + op = &callback_ops[op_nr]; +break ; + +case OP_CB_LAYOUTRECALL : +case OP_CB_NOTIFY : +case OP_CB_PUSH_DELEG : +case OP_CB_RECALL_ANY : +case OP_CB_RECALLABLE_OBJ_AVAIL : +case OP_CB_RECALL_SLOT : +case OP_CB_SEQUENCE : +case OP_CB_WANTS_CANCELLED : +case OP_CB_NOTIFY_LOCK : + op = &callback_ops[0 ];
fs/nfs/callback_xdr.c out: · line 406
Quoted 10 lines
fs/nfs/callback_xdr.c +7
-1+ status =htonl (NFS4ERR_NOTSUPP ); +break ; +default : + goto out_illegal; } - } + goto out; + } +#endif /* defined(CONFIG_NFS_V4_1) */
Please move into a separate function.
fs/nfs/callback_xdr.c out: · line 415
Quoted 9 lines
fs/nfs/callback_xdr.c +9
-0+ +switch (op_nr) { +case OP_CB_GETATTR : +case OP_CB_RECALL : + op = &callback_ops[op_nr]; +break ; +default : + goto out_illegal; + }
Ditto...
Quoted 27 lines
fs/nfs/callback_xdr.c +9
-1+out: maxlen = xdr_out->end - xdr_out->p;if (maxlen >0 && maxlen <PAGE_SIZE ) {if (likely (status ==0 && op->decode_args !=NULL ))@@ -400,6 +430,12 @@ static __be32 process_op(struct svc_rqst *rqstp, status = op->encode_res (rqstp, xdr_out, resp);dprintk ("%s: done, status = %d\n" , __func__,ntohl (status));return status; + +out_illegal: + op_nr =OP_CB_ILLEGAL ; + op = &callback_ops[0 ]; + status =htonl (NFS4ERR_OP_ILLEGAL ); + goto out; }/* @@ -431,7 +467,8 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *rreturn rpc_system_err;while (status ==0 && nops != hdr_arg.nops) { - status =process_op (rqstp, &xdr_in, argp, &xdr_out, resp); + status =process_op (hdr_arg.minorversion, nops, + rqstp, &xdr_in, argp, &xdr_out, resp); nops++; }
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 31/39] nfs41: cb_sequence xdr implementation
In reply to Benny HalevyQuoted 15 lines · Benny Halevy
[nfs41: get rid of READMEM and COPYMEM for callback_xdr.c]Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 179 insertions(+), 2 deletions(-)fs/nfs/callback_xdr.c +1
-0@@ -20,8 +20,18 @@ 2 + 2 + 3 + 3)#define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) +#if defined(CONFIG_NFS_V4_1 )
fs/nfs/callback_xdr.c line 33
Quoted 10 lines
fs/nfs/callback_xdr.c +8
-0+#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ + 4 + 1 + 3) +#endif /* CONFIG_NFS_V4_1 */ +#define NFSDBG_FACILITY NFSDBG_CALLBACK +#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0)
This doesn't appear to be used, and in any case, it duplicates the existing function xdr_duplicate_hyper(). Please remove...
Quoted 210 lines
fs/nfs/callback_xdr.c +170
-2+typedef __be32 (*callback_process_op_t )(void *,void *);typedef __be32 (*callback_decode_arg_t )(struct svc_rqst *,struct xdr_stream *,void *);typedef __be32 (*callback_encode_res_t )(struct svc_rqst *,struct xdr_stream *,void *);@@ -210,6 +220,122 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned decode_sessionid (struct xdr_stream *xdr, +struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =read_buf (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE );; + +memcpy (sid->data, p, len); +return 0 ; +} + +static unsigned decode_rc_list (struct xdr_stream *xdr, +struct referring_call_list *rc_list) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &rc_list->rcl_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + rc_list->rcl_nrefcalls =ntohl (*p++); +if (rc_list->rcl_nrefcalls) { + p =read_buf (xdr, + rc_list->rcl_nrefcalls *2 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + rc_list->rcl_refcalls =kmalloc (rc_list->rcl_nrefcalls * +sizeof (*rc_list->rcl_refcalls), +GFP_KERNEL ); +if (unlikely (rc_list->rcl_refcalls ==NULL )) + goto out; +for (i =0 ; i < rc_list->rcl_nrefcalls; i++) { + rc_list->rcl_refcalls[i].rc_sequenceid =ntohl (*p++); + rc_list->rcl_refcalls[i].rc_slotid =ntohl (*p++); + } + } + status =0 ; + +out: +return status; +} + +static unsigned decode_cb_sequence_args (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +struct cb_sequenceargs *args) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &args->csa_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,5 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + args->csa_addr =svc_addr_in (rqstp); + args->csa_sequenceid =ntohl (*p++); + args->csa_slotid =ntohl (*p++); + args->csa_highestslotid =ntohl (*p++); + args->csa_cachethis =ntohl (*p++); + args->csa_nrclists =ntohl (*p++); + args->csa_rclists =NULL ; +if (args->csa_nrclists) { + args->csa_rclists =kmalloc (args->csa_nrclists * +sizeof (*args->csa_rclists), +GFP_KERNEL ); +if (unlikely (args->csa_rclists ==NULL )) + goto out; + +for (i =0 ; i < args->csa_nrclists; i++) { + status =decode_rc_list (xdr, &args->csa_rclists[i]); +if (status) + goto out_free; + } + } + status =0 ; + +dprintk ("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u " +"highestslotid %u cachethis %d nrclists %u\n" , + __func__, + ((u32 *)&args->csa_sessionid)[0 ], + ((u32 *)&args->csa_sessionid)[1 ], + ((u32 *)&args->csa_sessionid)[2 ], + ((u32 *)&args->csa_sessionid)[3 ], + args->csa_sequenceid, args->csa_slotid, + args->csa_highestslotid, args->csa_cachethis, + args->csa_nrclists); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; + +out_free: +for (i =0 ; i < args->csa_nrclists; i++) +kfree (args->csa_rclists[i].rcl_refcalls); +kfree (args->csa_rclists); + goto out; +} + +#endif /* CONFIG_NFS_V4_1 */ +static __be32 encode_string (struct xdr_stream *xdr,unsigned int len,const char *str) {__be32 *p;@@ -359,6 +485,49 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned encode_sessionid (struct xdr_stream *xdr, +const struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =xdr_reserve_space (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + +memcpy (p, sid, len); +return 0 ; +} + +static unsigned encode_cb_sequence_res (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +const struct cb_sequenceres *res) +{ +uint32_t *p; +unsigned status = res->csr_status; + +if (unlikely (status !=0 )) + goto out; + +encode_sessionid (xdr, &res->csr_sessionid); + + p =xdr_reserve_space (xdr,4 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + + *p++ =htonl (res->csr_sequenceid); + *p++ =htonl (res->csr_slotid); + *p++ =htonl (res->csr_highestslotid); + *p++ =htonl (res->csr_target_highestslotid); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; +} + +#endif /* CONFIG_NFS_V4_1 */ + static __be32 process_op(uint32_t minorversion, int nop, struct svc_rqst *rqstp, struct xdr_stream *xdr_in, void *argp,@@ -382,6 +551,7 @@ static __be32 process_op(uint32_t minorversion, int nop,switch (op_nr) {case OP_CB_GETATTR :case OP_CB_RECALL : +case OP_CB_SEQUENCE : op = &callback_ops[op_nr];break ;@@ -391,7 +561,6 @@ static __be32 process_op(uint32_t minorversion, int nop,case OP_CB_RECALL_ANY :case OP_CB_RECALLABLE_OBJ_AVAIL :case OP_CB_RECALL_SLOT : -case OP_CB_SEQUENCE :case OP_CB_WANTS_CANCELLED :case OP_CB_NOTIFY_LOCK :case OP_CB_NOTIFY_DEVICEID :@@ -496,7 +665,15 @@ static struct callback_op callback_ops[] = { .process_op = (callback_process_op_t)nfs4_callback_recall, .decode_args = (callback_decode_arg_t)decode_recall_args, .res_maxsize = CB_OP_RECALL_RES_MAXSZ, - } + }, +#if defined(CONFIG_NFS_V4_1 ) + [OP_CB_SEQUENCE] = { + .process_op = (callback_process_op_t)nfs4_callback_sequence, + .decode_args = (callback_decode_arg_t)decode_cb_sequence_args, + .encode_res = (callback_encode_res_t)encode_cb_sequence_res, + .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, + }, +#endif /* CONFIG_NFS_V4_1 */ };/*
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation
In reply to Benny HalevyQuoted 37 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Validates the callback's sessionID, the slot number, and the sequence ID. Increments the slot's sequence.
Detects replays, but simply prints a debug message (if debugging is enabled since we don't yet implement a duplicate request cache for the backchannel. This should not present a problem, since only idempotent callbacks are currently implemented.
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_proc.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 6 deletions(-)fs/nfs/callback_proc.c +13
-0@@ -105,6 +105,57 @@ out:#if defined(CONFIG_NFS_V4_1 )/* +* Validate the sequenceID sent by the server. +* Return success if the sequenceID is one more than what we last saw on +* this slot, accounting for wraparound. Increments the slot's sequence. +* +* We don't yet implement a duplicate request cache, so at this time +* we will log replays, and process them as if we had not seen them before, +* but we don't bump the sequence in the slot. Not too worried about it, +* since we only currently implement idempotent callbacks anyway. +* +* We have a single slot backchannel at this time, so we don't bother +* checking the used_slots bit array on the table. The lower layer guarantees +* a single outstanding callback request at a time. +*/
fs/nfs/callback_proc.c out: · line 130
Quoted 10 lines
fs/nfs/callback_proc.c +10
-0+static int +validate_seqid (struct nfs4_slot_table *tbl,u32 slotid,u32 seqid) +{ +struct nfs4_slot *slot; + +dprintk ("%s enter. slotid %d seqid %d\n" , + __func__, slotid, seqid); + +if (slotid >NFS41_BC_MAX_CALLBACKS ) +return NFS4ERR_BADSLOT ;
I thought we agreed to always return error values as _negative_? Why the change here?
Quoted 78 lines
fs/nfs/callback_proc.c +46
-6+ + slot = tbl->slots + slotid; +dprintk ("%s slot table seqid: %d\n" , __func__, slot->seq_nr); + +/* Normal */ +if (likely (seqid == slot->seq_nr +1 )) { + slot->seq_nr++; +return NFS4_OK ; + } + +/* Replay */ +if (seqid == slot->seq_nr) { +dprintk ("%s seqid %d is a replay - no DRC available\n" , + __func__, seqid); +return NFS4_OK ; + } + +/* Wraparound */ +if (seqid ==1 && (slot->seq_nr +1 ) ==0 ) { + slot->seq_nr =1 ; +return NFS4_OK ; + } + +/* Misordered request */ +return NFS4ERR_SEQ_MISORDERED ; +} + +/* * Returns a pointer to a held 'struct nfs_client' that matches the server's * address, major version number, and session ID. It is the caller's * responsibility to release the returned reference. @@ -140,18 +191,27 @@ out:return NULL ; } -/* FIXME: validate args->cbs_{sequence,slot}id */ /* FIXME: referring calls should be processed */ unsigned nfs4_callback_sequence (struct cb_sequenceargs *args,struct cb_sequenceres *res) { -int i; -unsigned status =0 ; +struct nfs_client *clp; +int i, status;for (i =0 ; i < args->csa_nrclists; i++)kfree (args->csa_rclists[i].rcl_refcalls);kfree (args->csa_rclists); + status =NFS4ERR_BADSESSION ; + clp =find_client_with_session (args->csa_addr,4 , &args->csa_sessionid); +if (clp ==NULL ) + goto out; + + status =validate_seqid (&clp->cl_session->bc_slot_table, + args->csa_slotid, args->csa_sequenceid); +if (status) + goto out_putclient; +memcpy (&res->csr_sessionid, &args->csa_sessionid,sizeof (res->csr_sessionid)); res->csr_sequenceid = args->csa_sequenceid;@@ -159,9 +219,12 @@ unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, res->csr_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; res->csr_target_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; -dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); - res->csr_status = status; - return status; +out_putclient: +nfs_put_client (clp); +out: +dprintk ("%s: exit with status = %d\n" , __func__, status); + res->csr_status =htonl (status); + return res->csr_status; }#endif /* CONFIG_NFS_V4_1 */
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation
In reply to a message not in the archiveQuoted 45 lines · Trond Myklebust
Quoted 44 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Validates the callback's sessionID, the slot number, and the sequence ID. Increments the slot's sequence.
Detects replays, but simply prints a debug message (if debugging is enabled since we don't yet implement a duplicate request cache for the backchannel. This should not present a problem, since only idempotent callbacks are currently implemented.
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_proc.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 6 deletions(-)fs/nfs/callback_proc.c +11
-0@@ -105,6 +105,57 @@ out:#if defined(CONFIG_NFS_V4_1 )/* +* Validate the sequenceID sent by the server. +* Return success if the sequenceID is one more than what we last saw on +* this slot, accounting for wraparound. Increments the slot's sequence. +* +* We don't yet implement a duplicate request cache, so at this time +* we will log replays, and process them as if we had not seen them before, +* but we don't bump the sequence in the slot. Not too worried about it, +* since we only currently implement idempotent callbacks anyway. +* +* We have a single slot backchannel at this time, so we don't bother +* checking the used_slots bit array on the table. The lower layer guarantees
+ * a single outstanding callback request at a time.
+ */fs/nfs/callback_proc.c +5
-0+static int +validate_seqid (struct nfs4_slot_table *tbl,u32 slotid,u32 seqid) +{ +struct nfs4_slot *slot; +
Quoted 9 lines
fs/nfs/callback_proc.c out: · line 130
Quoted 5 lines
+ dprintk("%s enter. slotid %d seqid %d\n",
fs/nfs/callback_proc.c +4
-0+ __func__, slotid, seqid); + +if (slotid >NFS41_BC_MAX_CALLBACKS ) +return NFS4ERR_BADSLOT ;I thought we agreed to always return error values as _negative_? Why the change here?
Will change to negative.
- ricardo
Quoted 79 lines
Quoted 79 lines
fs/nfs/callback_proc.c +46
-6+ + slot = tbl->slots + slotid; +dprintk ("%s slot table seqid: %d\n" , __func__, slot->seq_nr); + +/* Normal */ +if (likely (seqid == slot->seq_nr +1 )) { + slot->seq_nr++; +return NFS4_OK ; + } + +/* Replay */ +if (seqid == slot->seq_nr) { +dprintk ("%s seqid %d is a replay - no DRC available\n" , + __func__, seqid); +return NFS4_OK ; + } + +/* Wraparound */ +if (seqid ==1 && (slot->seq_nr +1 ) ==0 ) { + slot->seq_nr =1 ; +return NFS4_OK ; + } + +/* Misordered request */ +return NFS4ERR_SEQ_MISORDERED ; +} + +/* * Returns a pointer to a held 'struct nfs_client' that matches the server's * address, major version number, and session ID. It is the caller's * responsibility to release the returned reference. @@ -140,18 +191,27 @@ out:return NULL ; } -/* FIXME: validate args->cbs_{sequence,slot}id */ /* FIXME: referring calls should be processed */ unsigned nfs4_callback_sequence (struct cb_sequenceargs *args,struct cb_sequenceres *res) { -int i; -unsigned status =0 ; +struct nfs_client *clp; +int i, status;for (i =0 ; i < args->csa_nrclists; i++)kfree (args->csa_rclists[i].rcl_refcalls);kfree (args->csa_rclists); + status =NFS4ERR_BADSESSION ; + clp =find_client_with_session (args->csa_addr,4 , &args->csa_sessionid); +if (clp ==NULL ) + goto out; + + status =validate_seqid (&clp->cl_session->bc_slot_table, + args->csa_slotid, args->csa_sequenceid); +if (status) + goto out_putclient; +memcpy (&res->csr_sessionid, &args->csa_sessionid,sizeof (res->csr_sessionid)); res->csr_sequenceid = args->csa_sequenceid;@@ -159,9 +219,12 @@ unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, res->csr_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; res->csr_target_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; -dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); - res->csr_status = status; -return status; +out_putclient: +nfs_put_client (clp); +out: +dprintk ("%s: exit with status = %d\n" , __func__, status); + res->csr_status =htonl (status); +return res->csr_status; }#endif /*
CONFIG_NFS_V4_1*/
RE: [pnfs] [RFC 25/39] nfs41: decode minorversion 1 cb_compound header
In reply to Trond MyklebustQuoted 2 lines
What is the point of splitting the
read_buf()here? That seems very unnecessary...
Agreed.
I'll revert that.
For the record, my original thinking was that you don't want to read the rest of the header if you don't support its minorversion. However, minorversion can't change the compound header's format so its safe to read it all.
Benny
-----Original Message-----
From: Trond Myklebust [mailto:[email protected]]
Sent: Tue 2009-06-16 03:13
To: Halevy, Benny
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 25/39] nfs41: decode minorversion 1 cb_compound header
Quoted 34 lines · Benny Halevy
decode
cb_compoundheader conforming to
http://tools.ietf.org/html/draft-ietf-nfsv4-minorversion1-26Get rid of cb_compound_hdr_arg.callback_ident
callback_identis not used anywhere so we shouldn't waste any memory to store it.Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback.h | 1 - fs/nfs/callback_xdr.c | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)fs/nfs/callback.h +0
-1@@ -27,7 +27,6 @@ struct cb_compound_hdr_arg {unsigned int taglen;const char *tag;unsigned int minorversion; -unsigned int callback_ident;unsigned nops; };fs/nfs/callback_xdr.c +0
-0@@ -143,18 +143,22 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound __func__, hdr->taglen);return htonl (NFS4ERR_RESOURCE ); }
fs/nfs/callback_xdr.c static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound · line 152
Quoted 10 lines
fs/nfs/callback_xdr.c +4
-3- p =read_buf (xdr,12 ); + p =read_buf (xdr,4 );if (unlikely (p ==NULL ))return htonl (NFS4ERR_RESOURCE ); hdr->minorversion =ntohl (*p++); -/* Check minor version is zero. */ -if (hdr->minorversion !=0 ) { +/* Check minor version is zero or one. */ +if (hdr->minorversion <=1 ) { + p =read_buf (xdr,8 );
What is the point of splitting the read_buf() here? That seems very unnecessary...
Quoted 13 lines
fs/nfs/callback_xdr.c +4
-1+if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + p++;/* skip callback_ident */ + }else {printk (KERN_WARNING "%s: NFSv4 server callback with " "illegal minor version %u!\n" , __func__, hdr->minorversion);return htonl (NFS4ERR_MINOR_VERS_MISMATCH ); } - hdr->callback_ident =ntohl (*p++); hdr->nops =ntohl (*p);dprintk ("%s: minorversion %d nops %d\n" , __func__, hdr->minorversion, hdr->nops);
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
RE: [pnfs] [RFC 31/39] nfs41: cb_sequence xdr implementation
In reply to Trond MyklebustQuoted 6 lines
fs/nfs/callback_xdr.c line 33
Quoted 4 lines
fs/nfs/callback_xdr.c +4
-0+#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0)This doesn't appear to be used, and in any case, it duplicates the
Oops, Will do.
Quoted 1 line
existing function
xdr_duplicate_hyper(). Please remove...
xdr_decode_hyper?
Benny
-----Original Message-----
From: Trond Myklebust [mailto:[email protected]]
Sent: Tue 2009-06-16 03:18
To: Halevy, Benny
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 31/39] nfs41: cb_sequence xdr implementation
Quoted 15 lines · Benny Halevy
[nfs41: get rid of READMEM and COPYMEM for callback_xdr.c]Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 179 insertions(+), 2 deletions(-)fs/nfs/callback_xdr.c +1
-0@@ -20,8 +20,18 @@ 2 + 2 + 3 + 3)#define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) +#if defined(CONFIG_NFS_V4_1 )
fs/nfs/callback_xdr.c line 33
Quoted 10 lines
fs/nfs/callback_xdr.c +8
-0+#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ + 4 + 1 + 3) +#endif /* CONFIG_NFS_V4_1 */ +#define NFSDBG_FACILITY NFSDBG_CALLBACK +#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0)
This doesn't appear to be used, and in any case, it duplicates the existing function xdr_duplicate_hyper(). Please remove...
Quoted 210 lines
fs/nfs/callback_xdr.c +170
-2+typedef __be32 (*callback_process_op_t )(void *,void *);typedef __be32 (*callback_decode_arg_t )(struct svc_rqst *,struct xdr_stream *,void *);typedef __be32 (*callback_encode_res_t )(struct svc_rqst *,struct xdr_stream *,void *);@@ -210,6 +220,122 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned decode_sessionid (struct xdr_stream *xdr, +struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =read_buf (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE );; + +memcpy (sid->data, p, len); +return 0 ; +} + +static unsigned decode_rc_list (struct xdr_stream *xdr, +struct referring_call_list *rc_list) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &rc_list->rcl_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + rc_list->rcl_nrefcalls =ntohl (*p++); +if (rc_list->rcl_nrefcalls) { + p =read_buf (xdr, + rc_list->rcl_nrefcalls *2 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + rc_list->rcl_refcalls =kmalloc (rc_list->rcl_nrefcalls * +sizeof (*rc_list->rcl_refcalls), +GFP_KERNEL ); +if (unlikely (rc_list->rcl_refcalls ==NULL )) + goto out; +for (i =0 ; i < rc_list->rcl_nrefcalls; i++) { + rc_list->rcl_refcalls[i].rc_sequenceid =ntohl (*p++); + rc_list->rcl_refcalls[i].rc_slotid =ntohl (*p++); + } + } + status =0 ; + +out: +return status; +} + +static unsigned decode_cb_sequence_args (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +struct cb_sequenceargs *args) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &args->csa_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,5 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + args->csa_addr =svc_addr_in (rqstp); + args->csa_sequenceid =ntohl (*p++); + args->csa_slotid =ntohl (*p++); + args->csa_highestslotid =ntohl (*p++); + args->csa_cachethis =ntohl (*p++); + args->csa_nrclists =ntohl (*p++); + args->csa_rclists =NULL ; +if (args->csa_nrclists) { + args->csa_rclists =kmalloc (args->csa_nrclists * +sizeof (*args->csa_rclists), +GFP_KERNEL ); +if (unlikely (args->csa_rclists ==NULL )) + goto out; + +for (i =0 ; i < args->csa_nrclists; i++) { + status =decode_rc_list (xdr, &args->csa_rclists[i]); +if (status) + goto out_free; + } + } + status =0 ; + +dprintk ("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u " +"highestslotid %u cachethis %d nrclists %u\n" , + __func__, + ((u32 *)&args->csa_sessionid)[0 ], + ((u32 *)&args->csa_sessionid)[1 ], + ((u32 *)&args->csa_sessionid)[2 ], + ((u32 *)&args->csa_sessionid)[3 ], + args->csa_sequenceid, args->csa_slotid, + args->csa_highestslotid, args->csa_cachethis, + args->csa_nrclists); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; + +out_free: +for (i =0 ; i < args->csa_nrclists; i++) +kfree (args->csa_rclists[i].rcl_refcalls); +kfree (args->csa_rclists); + goto out; +} + +#endif /* CONFIG_NFS_V4_1 */ +static __be32 encode_string (struct xdr_stream *xdr,unsigned int len,const char *str) {__be32 *p;@@ -359,6 +485,49 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned encode_sessionid (struct xdr_stream *xdr, +const struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =xdr_reserve_space (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + +memcpy (p, sid, len); +return 0 ; +} + +static unsigned encode_cb_sequence_res (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +const struct cb_sequenceres *res) +{ +uint32_t *p; +unsigned status = res->csr_status; + +if (unlikely (status !=0 )) + goto out; + +encode_sessionid (xdr, &res->csr_sessionid); + + p =xdr_reserve_space (xdr,4 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + + *p++ =htonl (res->csr_sequenceid); + *p++ =htonl (res->csr_slotid); + *p++ =htonl (res->csr_highestslotid); + *p++ =htonl (res->csr_target_highestslotid); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; +} + +#endif /* CONFIG_NFS_V4_1 */ + static __be32 process_op(uint32_t minorversion, int nop, struct svc_rqst *rqstp, struct xdr_stream *xdr_in, void *argp,@@ -382,6 +551,7 @@ static __be32 process_op(uint32_t minorversion, int nop,switch (op_nr) {case OP_CB_GETATTR :case OP_CB_RECALL : +case OP_CB_SEQUENCE : op = &callback_ops[op_nr];break ;@@ -391,7 +561,6 @@ static __be32 process_op(uint32_t minorversion, int nop,case OP_CB_RECALL_ANY :case OP_CB_RECALLABLE_OBJ_AVAIL :case OP_CB_RECALL_SLOT : -case OP_CB_SEQUENCE :case OP_CB_WANTS_CANCELLED :case OP_CB_NOTIFY_LOCK :case OP_CB_NOTIFY_DEVICEID :@@ -496,7 +665,15 @@ static struct callback_op callback_ops[] = { .process_op = (callback_process_op_t)nfs4_callback_recall, .decode_args = (callback_decode_arg_t)decode_recall_args, .res_maxsize = CB_OP_RECALL_RES_MAXSZ, - } + }, +#if defined(CONFIG_NFS_V4_1 ) + [OP_CB_SEQUENCE] = { + .process_op = (callback_process_op_t)nfs4_callback_sequence, + .decode_args = (callback_decode_arg_t)decode_cb_sequence_args, + .encode_res = (callback_encode_res_t)encode_cb_sequence_res, + .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, + }, +#endif /* CONFIG_NFS_V4_1 */ };/*
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
Re: [pnfs] [RFC 39/39] nfs41: Backchannel: CB_SEQUENCE validation
In reply to Labiaga, RicardoQuoted 57 lines · Ricardo Labiaga
Quoted 45 lines · Trond Myklebust
Quoted 44 lines · Benny Halevy
From: Ricardo Labiaga <[email protected]>
Validates the callback's sessionID, the slot number, and the sequence ID. Increments the slot's sequence.
Detects replays, but simply prints a debug message (if debugging is enabled since we don't yet implement a duplicate request cache for the backchannel. This should not present a problem, since only idempotent callbacks are currently implemented.
Signed-off-by Ricardo Labiaga <[email protected]>Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_proc.c | 75 ++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 69 insertions(+), 6 deletions(-)fs/nfs/callback_proc.c +11
-0@@ -105,6 +105,57 @@ out:#if defined(CONFIG_NFS_V4_1 )/* +* Validate the sequenceID sent by the server. +* Return success if the sequenceID is one more than what we last saw on +* this slot, accounting for wraparound. Increments the slot's sequence. +* +* We don't yet implement a duplicate request cache, so at this time +* we will log replays, and process them as if we had not seen them before, +* but we don't bump the sequence in the slot. Not too worried about it, +* since we only currently implement idempotent callbacks anyway. +* +* We have a single slot backchannel at this time, so we don't bother +* checking the used_slots bit array on the table. The lower layer guarantees
+ * a single outstanding callback request at a time.
+ */fs/nfs/callback_proc.c +5
-0+static int +validate_seqid (struct nfs4_slot_table *tbl,u32 slotid,u32 seqid) +{ +struct nfs4_slot *slot; +Quoted 9 lines
fs/nfs/callback_proc.c out: · line 130
Quoted 5 lines
+ dprintk("%s enter. slotid %d seqid %d\n",
fs/nfs/callback_proc.c +4
-0+ __func__, slotid, seqid); + +if (slotid >NFS41_BC_MAX_CALLBACKS ) +return NFS4ERR_BADSLOT ;I thought we agreed to always return error values as _negative_? Why the change here?
Quoted 2 lines
Will change to negative.
Looking at this more closely, this is the error that we encode into the XDR result, so it's okay for it to be positive. I'll change it to use htonl() in this function to avoid confusion, instead of setting htonl() in its caller.
- ricardo
Quoted 87 lines
- ricardo
Quoted 79 lines
Quoted 79 lines
fs/nfs/callback_proc.c +28
-0+ + slot = tbl->slots + slotid; +dprintk ("%s slot table seqid: %d\n" , __func__, slot->seq_nr); + +/* Normal */ +if (likely (seqid == slot->seq_nr +1 )) { + slot->seq_nr++; +return NFS4_OK ; + } + +/* Replay */ +if (seqid == slot->seq_nr) { +dprintk ("%s seqid %d is a replay - no DRC available\n" , + __func__, seqid); +return NFS4_OK ; + } + +/* Wraparound */ +if (seqid ==1 && (slot->seq_nr +1 ) ==0 ) { + slot->seq_nr =1 ; +return NFS4_OK ; + } + +/* Misordered request */ +return NFS4ERR_SEQ_MISORDERED ; +} + +/* * Returns a pointer to a held 'struct nfs_client' that matches the server's
* address, major version number, and session ID. It is the caller's
* responsibility to release the returned reference.fs/nfs/callback_proc.c +18
-6@@ -140,18 +191,27 @@ out:return NULL ; } -/* FIXME: validate args->cbs_{sequence,slot}id */ /* FIXME: referring calls should be processed */ unsigned nfs4_callback_sequence (struct cb_sequenceargs *args,struct cb_sequenceres *res) { -int i; -unsigned status =0 ; +struct nfs_client *clp; +int i, status;for (i =0 ; i < args->csa_nrclists; i++)kfree (args->csa_rclists[i].rcl_refcalls);kfree (args->csa_rclists); + status =NFS4ERR_BADSESSION ; + clp =find_client_with_session (args->csa_addr,4 , &args->csa_sessionid); +if (clp ==NULL ) + goto out; + + status =validate_seqid (&clp->cl_session->bc_slot_table, + args->csa_slotid, args->csa_sequenceid); +if (status) + goto out_putclient; +memcpy (&res->csr_sessionid, &args->csa_sessionid,sizeof (res->csr_sessionid)); res->csr_sequenceid = args->csa_sequenceid;@@ -159,9 +219,12 @@ unsigned nfs4_callback_sequence(struct cb_sequenceargs *args, res->csr_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; res->csr_target_highestslotid =NFS41_BC_MAX_CALLBACKS -1 ; -dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); - res->csr_status = status; -return status; +out_putclient: +nfs_put_client (clp); +out: +dprintk ("%s: exit with status = %d\n" , __func__, status); + res->csr_status =htonl (status); +return res->csr_status; }Quoted 1 line
Quoted 1 line
#endif /*
CONFIG_NFS_V4_1*/--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [pnfs] [RFC 31/39] nfs41: cb_sequence xdr implementation
In reply to a message not in the archiveQuoted 7 lines · Benny
Quoted 6 lines
fs/nfs/callback_xdr.c line 33
Quoted 4 lines
fs/nfs/callback_xdr.c +4
-0+#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0)This doesn't appear to be used, and in any case, it duplicates the
Quoted 5 lines
Oops, Will do.
Quoted 1 line
existing function
xdr_duplicate_hyper(). Please remove...
xdr_decode_hyper?
Err... Yes. In the non-jetlagged vernacular, it is indeed xdr_decode_hyper()...
Trond
Quoted 250 lines
Benny
-----Original Message-----
From: Trond Myklebust [mailto:[email protected]]
Sent: Tue 2009-06-16 03:18
To: Halevy, Benny
Cc: [email protected]; [email protected]
Subject: Re: [pnfs] [RFC 31/39] nfs41:cb_sequencexdr implementationQuoted 15 lines · Benny Halevy
[nfs41: get rid of READMEM and COPYMEM for callback_xdr.c]Signed-off-by Benny Halevy <[email protected]>--- fs/nfs/callback_xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 179 insertions(+), 2 deletions(-)fs/nfs/callback_xdr.c +1
-0@@ -20,8 +20,18 @@ 2 + 2 + 3 + 3)#define CB_OP_RECALL_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ) +#if defined(CONFIG_NFS_V4_1 )fs/nfs/callback_xdr.c line 33
Quoted 10 lines
fs/nfs/callback_xdr.c +8
-0+#define CB_OP_SEQUENCE_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ + \ + 4 + 1 + 3) +#endif /* CONFIG_NFS_V4_1 */ +#define NFSDBG_FACILITY NFSDBG_CALLBACK +#define READ64 (x) do { \ + (x) = (u64)ntohl(*p++) << 32; \ + (x) |= ntohl(*p++); \ +} while (0)This doesn't appear to be used, and in any case, it duplicates the existing function
xdr_duplicate_hyper(). Please remove...Quoted 210 lines
fs/nfs/callback_xdr.c +170
-2+typedef __be32 (*callback_process_op_t )(void *,void *);typedef __be32 (*callback_decode_arg_t )(struct svc_rqst *,struct xdr_stream *,void *);typedef __be32 (*callback_encode_res_t )(struct svc_rqst *,struct xdr_stream *,void *);@@ -210,6 +220,122 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned decode_sessionid (struct xdr_stream *xdr, +struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =read_buf (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE );; + +memcpy (sid->data, p, len); +return 0 ; +} + +static unsigned decode_rc_list (struct xdr_stream *xdr, +struct referring_call_list *rc_list) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &rc_list->rcl_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + rc_list->rcl_nrefcalls =ntohl (*p++); +if (rc_list->rcl_nrefcalls) { + p =read_buf (xdr, + rc_list->rcl_nrefcalls *2 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + rc_list->rcl_refcalls =kmalloc (rc_list->rcl_nrefcalls * +sizeof (*rc_list->rcl_refcalls), +GFP_KERNEL ); +if (unlikely (rc_list->rcl_refcalls ==NULL )) + goto out; +for (i =0 ; i < rc_list->rcl_nrefcalls; i++) { + rc_list->rcl_refcalls[i].rc_sequenceid =ntohl (*p++); + rc_list->rcl_refcalls[i].rc_slotid =ntohl (*p++); + } + } + status =0 ; + +out: +return status; +} + +static unsigned decode_cb_sequence_args (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +struct cb_sequenceargs *args) +{ +uint32_t *p; +int i; +unsigned status; + + status =decode_sessionid (xdr, &args->csa_sessionid); +if (status) + goto out; + + status =htonl (NFS4ERR_RESOURCE ); + p =read_buf (xdr,5 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) + goto out; + + args->csa_addr =svc_addr_in (rqstp); + args->csa_sequenceid =ntohl (*p++); + args->csa_slotid =ntohl (*p++); + args->csa_highestslotid =ntohl (*p++); + args->csa_cachethis =ntohl (*p++); + args->csa_nrclists =ntohl (*p++); + args->csa_rclists =NULL ; +if (args->csa_nrclists) { + args->csa_rclists =kmalloc (args->csa_nrclists * +sizeof (*args->csa_rclists), +GFP_KERNEL ); +if (unlikely (args->csa_rclists ==NULL )) + goto out; + +for (i =0 ; i < args->csa_nrclists; i++) { + status =decode_rc_list (xdr, &args->csa_rclists[i]); +if (status) + goto out_free; + } + } + status =0 ; + +dprintk ("%s: sessionid %x:%x:%x:%x sequenceid %u slotid %u " +"highestslotid %u cachethis %d nrclists %u\n" , + __func__, + ((u32 *)&args->csa_sessionid)[0 ], + ((u32 *)&args->csa_sessionid)[1 ], + ((u32 *)&args->csa_sessionid)[2 ], + ((u32 *)&args->csa_sessionid)[3 ], + args->csa_sequenceid, args->csa_slotid, + args->csa_highestslotid, args->csa_cachethis, + args->csa_nrclists); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; + +out_free: +for (i =0 ; i < args->csa_nrclists; i++) +kfree (args->csa_rclists[i].rcl_refcalls); +kfree (args->csa_rclists); + goto out; +} + +#endif /* CONFIG_NFS_V4_1 */ +static __be32 encode_string (struct xdr_stream *xdr,unsigned int len,const char *str) {__be32 *p;@@ -359,6 +485,49 @@ out:return status; } +#if defined(CONFIG_NFS_V4_1 ) + +static unsigned encode_sessionid (struct xdr_stream *xdr, +const struct nfs4_sessionid *sid) +{ +uint32_t *p; +int len =NFS4_MAX_SESSIONID_LEN ; + + p =xdr_reserve_space (xdr, len); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + +memcpy (p, sid, len); +return 0 ; +} + +static unsigned encode_cb_sequence_res (struct svc_rqst *rqstp, +struct xdr_stream *xdr, +const struct cb_sequenceres *res) +{ +uint32_t *p; +unsigned status = res->csr_status; + +if (unlikely (status !=0 )) + goto out; + +encode_sessionid (xdr, &res->csr_sessionid); + + p =xdr_reserve_space (xdr,4 *sizeof (uint32_t )); +if (unlikely (p ==NULL )) +return htonl (NFS4ERR_RESOURCE ); + + *p++ =htonl (res->csr_sequenceid); + *p++ =htonl (res->csr_slotid); + *p++ =htonl (res->csr_highestslotid); + *p++ =htonl (res->csr_target_highestslotid); +out: +dprintk ("%s: exit with status = %d\n" , __func__,ntohl (status)); +return status; +} + +#endif /* CONFIG_NFS_V4_1 */ + static __be32 process_op(uint32_t minorversion, int nop, struct svc_rqst *rqstp, struct xdr_stream *xdr_in, void *argp,@@ -382,6 +551,7 @@ static __be32 process_op(uint32_t minorversion, int nop,switch (op_nr) {case OP_CB_GETATTR :case OP_CB_RECALL : +case OP_CB_SEQUENCE : op = &callback_ops[op_nr];break ;@@ -391,7 +561,6 @@ static __be32 process_op(uint32_t minorversion, int nop,case OP_CB_RECALL_ANY :case OP_CB_RECALLABLE_OBJ_AVAIL :case OP_CB_RECALL_SLOT : -case OP_CB_SEQUENCE :case OP_CB_WANTS_CANCELLED :case OP_CB_NOTIFY_LOCK :case OP_CB_NOTIFY_DEVICEID :@@ -496,7 +665,15 @@ static struct callback_op callback_ops[] = { .process_op = (callback_process_op_t)nfs4_callback_recall, .decode_args = (callback_decode_arg_t)decode_recall_args, .res_maxsize = CB_OP_RECALL_RES_MAXSZ, - } + }, +#if defined(CONFIG_NFS_V4_1 ) + [OP_CB_SEQUENCE] = { + .process_op = (callback_process_op_t)nfs4_callback_sequence, + .decode_args = (callback_decode_arg_t)decode_cb_sequence_args, + .encode_res = (callback_encode_res_t)encode_cb_sequence_res, + .res_maxsize = CB_OP_SEQUENCE_RES_MAXSZ, + }, +#endif /* CONFIG_NFS_V4_1 */ };/*
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com