From: Benny Halevy <bhalevy@panasas.com>
To: pnfs@linux-nfs.org
Cc: trond.myklebust@fys.uio.no, linux-nfs@vger.kernel.org
Subject: Re: [pnfs] [RFC 18/85] nfs41: sessions client infrastructure
Date: Mon, 17 Nov 2008 15:44:25 +0200 [thread overview]
Message-ID: <49217539.2000902@panasas.com> (raw)
In-Reply-To: <1226348459-7784-1-git-send-email-bhalevy@panasas.com>
On Nov. 10, 2008, 22:20 +0200, Benny Halevy <bhalevy@panasas.com> wrote:
> From: Andy Adamson <andros@netapp.com>
>
> NFSv4.1 Sessions basic data types, initialization, and destruction.
>
> The session is always associated with a struct nfs_client that holds
> the exchange_id results. Add an nfs_client struct backpointer to the session
> and refactor the session recovery routines to only require a struct
> nfs4_sessions parameter.
>
> Signed-off-by: Rahul Iyer <iyer@netapp.com>
> Signed-off-by: Andy Adamson<andros@netapp.com>
> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> ---
> fs/nfs/client.c | 40 +++++++++++++++++++++++++++++++++++++
> fs/nfs/internal.h | 1 +
> fs/nfs/nfs4_fs.h | 4 +++
> fs/nfs/nfs4proc.c | 35 ++++++++++++++++++++++++++++++++
> include/linux/nfs4_session.h | 45 ++++++++++++++++++++++++++++++++++++++++++
> include/linux/nfs_fs_sb.h | 5 ++++
> 6 files changed, 130 insertions(+), 0 deletions(-)
> create mode 100644 include/linux/nfs4_session.h
>
> diff --git a/fs/nfs/client.c b/fs/nfs/client.c
> index 0a8a082..80091dc 100644
> --- a/fs/nfs/client.c
> +++ b/fs/nfs/client.c
> @@ -37,6 +37,9 @@
> #include <linux/in6.h>
> #include <net/ipv6.h>
> #include <linux/nfs_xdr.h>
> +#if defined(CONFIG_NFS_V4_1)
> +#include <linux/nfs4_session.h>
> +#endif /* CONFIG_NFS_V4_1 */
>
> #include <asm/system.h>
>
> @@ -884,6 +887,11 @@ void nfs_free_server(struct nfs_server *server)
> list_del(&server->master_link);
> spin_unlock(&nfs_client_lock);
>
> +#ifdef CONFIG_NFS_V4_1
> + if (server->nfs_client->cl_session != NULL)
> + nfs4_put_session(&server->nfs_client->cl_session);
> +#endif /* CONFIG_NFS_V4_1 */
> +
> if (server->destroy != NULL)
> server->destroy(server);
>
> @@ -1110,6 +1118,34 @@ error:
> }
>
> /*
> + * Allocate and initialize a session if required
> + */
> +int nfs4_init_session(struct nfs_client *clp, struct rpc_clnt *clnt)
> +{
> + int error = 0;
> +
> +#if defined(CONFIG_NFS_V4_1)
> + if (clp->cl_minorversion) {
> + struct nfs4_session *session = NULL;
> + /*
> + * Create the session and mark it expired.
> + * When a SEQUENCE operation encounters the expired session
> + * it will do session recovery to initialize it.
> + */
> + session = nfs4_alloc_session();
> + if (!session)
> + error = -ENOMEM;
> + else {
> + session->clnt = clnt;
> + session->clp = clp;
> + }
> + clp->cl_session = session;
> + }
> +#endif /* CONFIG_NFS_V4_1 */
> + return error;
> +}
> +
> +/*
> * Create a version 4 volume record
> * - keyed on server and FSID
> */
> @@ -1139,6 +1175,10 @@ retry:
> BUG_ON(!server->nfs_client->rpc_ops);
> BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
>
> + error = nfs4_init_session(server->nfs_client, server->client);
> + if (error)
> + goto error;
> +
> /* Probe the root fh to retrieve its FSID */
> error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path);
> if (error < 0)
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index 8386e99..9b2228f 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -82,6 +82,7 @@ extern void nfs_free_server(struct nfs_server *server);
> extern struct nfs_server *nfs_clone_server(struct nfs_server *,
> struct nfs_fh *,
> struct nfs_fattr *);
> +extern int nfs4_init_session(struct nfs_client *clp, struct rpc_clnt *clnt);
> #ifdef CONFIG_PROC_FS
> extern int __init nfs_fs_proc_init(void);
> extern void nfs_fs_proc_exit(void);
> diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
> index 5fb7382..4b13945 100644
> --- a/fs/nfs/nfs4_fs.h
> +++ b/fs/nfs/nfs4_fs.h
> @@ -188,6 +188,10 @@ extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
>
> extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;
> extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops;
> +#if defined(CONFIG_NFS_V4_1)
> +extern void nfs4_put_session(struct nfs4_session **session);
> +extern struct nfs4_session *nfs4_alloc_session(void);
> +#endif /* CONFIG_NFS_V4_1 */
>
> extern const u32 nfs4_fattr_bitmap[2];
> extern const u32 nfs4_statfs_bitmap[2];
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index f87d4de..8e373e9 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -53,6 +53,9 @@
> #include "delegation.h"
> #include "internal.h"
> #include "iostat.h"
> +#if defined(CONFIG_NFS_V4_1)
> +#include <linux/nfs4_session.h>
> +#endif /* CONFIG_NFS_V4_1 */
>
> #define NFSDBG_FACILITY NFSDBG_PROC
>
> @@ -3679,6 +3682,38 @@ int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
> return status;
> }
>
> +#ifdef CONFIG_NFS_V4_1
> +struct nfs4_session *nfs4_alloc_session(void)
> +{
> + struct nfs4_session *session;
> +
> + session = kzalloc(sizeof(struct nfs4_session), GFP_ATOMIC);
> + if (!session)
> + return NULL;
> +
> + atomic_set(&session->ref_count, 1);
> +
> + return session;
> +}
> +
> +static void nfs4_free_session(struct nfs4_session *session)
> +{
> + dprintk("%s: freeing session %p\n", __func__, session);
> + kfree(session);
> +}
> +
> +void nfs4_put_session(struct nfs4_session **session)
review 11-14: pass a struct nfs4_session* (not **)
do not set *session to NULL
> +{
> + dprintk("--> nfs4_put_session()\n");
> + if (atomic_dec_and_test(&((*session)->ref_count))) {
> + nfs4_free_session(*session);
> + *session = NULL;
> + }
> + dprintk("<-- nfs4_put_session()\n");
> +}
> +
> +#endif /* CONFIG_NFS_V4_1 */
> +
> struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops = {
> .recover_open = nfs4_open_reclaim,
> .recover_lock = nfs4_lock_reclaim,
> diff --git a/include/linux/nfs4_session.h b/include/linux/nfs4_session.h
> new file mode 100644
> index 0000000..36c0f94
> --- /dev/null
> +++ b/include/linux/nfs4_session.h
review 11-14: move to fs/nfs/nfs4_fs.h
> @@ -0,0 +1,45 @@
> +#ifndef _NFS4_SESSIONS_H
> +#define _NFS4_SESSIONS_H
> +
> +#if defined(CONFIG_NFS_V4_1)
> +
> +#include <linux/nfs4.h>
> +#include <linux/smp_lock.h>
> +#include <linux/sunrpc/sched.h>
> +
> +struct nfs4_channel_attrs {
> + u32 headerpadsz;
> + u32 max_rqst_sz;
> + u32 max_resp_sz;
> + u32 max_resp_sz_cached;
> + u32 max_ops;
> + u32 max_reqs;
> + u32 rdma_attrs;
review 11-14: weed out unused fields
> +};
> +
> +struct nfs4_channel {
> + struct nfs4_channel_attrs chan_attrs;
> + struct rpc_clnt *rpc_client;
review 11-14: unused, no need for this struct
> +};
> +
> +/*
> + * Session related parameters
> + */
> +struct nfs4_session {
> + nfs41_sessionid sess_id;
> + u32 flags;
review 11-14: remove until used
> + unsigned long session_state;
> + u32 hash_alg;
> + u32 ssv_len;
review 11-14: take these out for now.
> +
> + /* The fore and back channel */
> + struct nfs4_channel fore_channel;
review 11-14: s/nfs4_channel/nfs4_channel_attrs/
> + struct nfs4_channel back_channel;
> +
> + atomic_t ref_count;
> + struct rpc_clnt *clnt;
review 11-14: use clp->cl_rpcclient instead
> + struct nfs_client *clp;
> +};
> +
> +#endif /* CONFIG_NFS_V4_1 */
> +#endif
> diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
> index 80e0fc3..15c0aa5 100644
> --- a/include/linux/nfs_fs_sb.h
> +++ b/include/linux/nfs_fs_sb.h
> @@ -7,6 +7,7 @@
>
> #include <asm/atomic.h>
>
> +struct nfs4_session;
> struct nfs_iostats;
> struct nlm_host;
>
> @@ -72,6 +73,10 @@ struct nfs_client {
> unsigned char cl_id_uniquifier;
> u32 cl_minorversion;
> #endif /* CONFIG_NFS_V4 */
> +
> +#ifdef CONFIG_NFS_V4_1
> + struct nfs4_session *cl_session; /* sharred session */
> +#endif /* CONFIG_NFS_V4_1 */
> };
>
> #ifdef CONFIG_NFS_V4
next prev parent reply other threads:[~2008-11-17 13:44 UTC|newest]
Thread overview: 115+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-10 19:57 [RFC 0/85] nfs41 client patches for review Benny Halevy
2008-11-10 20:05 ` [RFC 03/85] nfs: remove incorrect usage of nfs4 compound response hdr.status Benny Halevy
2008-11-17 13:24 ` [pnfs] " Benny Halevy
2008-11-10 20:18 ` [RFC 04/85] FIXME: NFS: Increment operation number in each encode_* routine Benny Halevy
2008-11-17 13:26 ` [pnfs] " Benny Halevy
2008-11-10 20:18 ` [RFC 05/85] nfs41: Add Kconfig symbols for NFSv4.1 Benny Halevy
2008-11-17 13:27 ` [pnfs] " Benny Halevy
2008-11-10 20:18 ` [RFC 06/85] nfs41: common protocol definitions Benny Halevy
2008-11-17 13:28 ` [pnfs] " Benny Halevy
2008-11-10 20:19 ` [RFC 07/85] nfs41: define NFS4_MAX_MINOR_VERSION based on CONFIG_NFS_V4_1 Benny Halevy
2008-11-10 20:19 ` [RFC 08/85] nfs41: client xdr definitions Benny Halevy
2008-11-17 13:31 ` [pnfs] " Benny Halevy
2008-11-10 20:19 ` [RFC 09/85] nfs41: add mount command option minorvers Benny Halevy
2008-11-17 13:34 ` [pnfs] " Benny Halevy
2008-11-10 20:19 ` [RFC 10/85] nfs41: struct nfs_server minorversion Benny Halevy
2008-11-17 13:34 ` [pnfs] " Benny Halevy
2008-11-10 20:19 ` [RFC 11/85] nfs41: nfs_client.cl_minorversion Benny Halevy
2008-11-17 13:37 ` [pnfs] " Benny Halevy
2008-11-10 20:19 ` [RFC 12/85] nfs41: set nfs_client rpc_ops based on minorversion Benny Halevy
2008-11-10 20:20 ` [RFC 13/85] nfs41: use ptr to rpc procedures via struct nfs_client Benny Halevy
2008-11-17 13:40 ` [pnfs] " Benny Halevy
2008-11-10 20:20 ` [RFC 14/85] nfs41: sunrpc: support minorversion for rpc_clnt version table Benny Halevy
2008-11-17 13:41 ` [pnfs] " Benny Halevy
2008-11-10 20:20 ` [RFC 15/85] nfs41: Proper initialization of nfs_client_initdata.rpc_ops Benny Halevy
2008-11-17 13:41 ` [pnfs] " Benny Halevy
2008-11-10 20:20 ` [RFC 16/85] nfs41: pass recovery status from reclaimer kthread up to nfs4_wait_clnt_recover Benny Halevy
2008-11-17 13:42 ` [pnfs] " Benny Halevy
2008-11-10 20:20 ` [RFC 17/85] nfs41: fallback to lower minorversion if nfs4_create_server fails Benny Halevy
2008-11-17 13:43 ` [pnfs] " Benny Halevy
2008-11-10 20:20 ` [RFC 18/85] nfs41: sessions client infrastructure Benny Halevy
2008-11-17 13:44 ` Benny Halevy [this message]
2008-11-10 20:21 ` [RFC 19/85] nfs41: share client sessions across mounts Benny Halevy
2008-11-17 13:45 ` [pnfs] " Benny Halevy
2008-11-10 20:21 ` [RFC 20/85] nfs41: slot table init and destroy Benny Halevy
2008-11-17 13:46 ` [pnfs] " Benny Halevy
2008-11-10 20:21 ` [RFC 21/85] nfs41: find slot Benny Halevy
2008-11-17 13:46 ` [pnfs] " Benny Halevy
2008-11-10 20:21 ` [RFC 22/85] nfs41: free slot Benny Halevy
2008-11-17 13:47 ` [pnfs] " Benny Halevy
2008-11-10 20:21 ` [RFC 23/85] nfs41: minorversion support for xdr Benny Halevy
2008-11-17 13:48 ` [pnfs] " Benny Halevy
2008-11-10 20:22 ` [RFC 24/85] nfs41: stubs for nfs41 procedures Benny Halevy
2008-11-10 20:22 ` [RFC 25/85] nfs41: make nfs4_wait_bit_killable public Benny Halevy
2008-11-10 20:22 ` [RFC 26/85] nfs41: introduce nfs4_call_sync Benny Halevy
2008-11-17 13:49 ` [pnfs] " Benny Halevy
2008-11-10 20:22 ` [RFC 27/85] nfs41: nfs4_setup_sequence Benny Halevy
2008-11-17 13:49 ` [pnfs] " Benny Halevy
2008-11-10 20:22 ` [RFC 28/85] nfs41: setup_sequence method Benny Halevy
2008-11-10 20:23 ` [RFC 02/85] nfs: return compound hdr.status when there are no op replies Benny Halevy
2008-11-10 20:23 ` [RFC 29/85] nfs41: nfs41_sequence_done Benny Halevy
2008-11-17 13:50 ` [pnfs] " Benny Halevy
2008-11-10 20:23 ` [RFC 30/85] nfs41: nfs41_call_sync_done Benny Halevy
2008-11-10 20:23 ` [RFC 31/85] nfs41: separate free slot from sequence done Benny Halevy
2008-11-10 20:23 ` [RFC 32/85] nfs41: sequence setup/done support Benny Halevy
2008-11-10 20:23 ` [RFC 33/85] nfs41: Support sessions with O_DIRECT Benny Halevy
2008-11-10 20:24 ` [RFC 34/85] nfs41: exchange_id operation Benny Halevy
2008-11-10 20:24 ` [RFC 35/85] nfs41: get_lease_time Benny Halevy
2008-11-10 20:24 ` [RFC 36/85] nfs41: create_session operation Benny Halevy
2008-11-10 20:24 ` [RFC 37/85] nfs41: destroy_session operation Benny Halevy
2008-11-10 20:24 ` [RFC 38/85] nfs41: sequence operation Benny Halevy
2008-11-10 20:25 ` [RFC 39/85] nfs41: session recovery infrastructure Benny Halevy
2008-11-10 20:25 ` [RFC 40/85] nfs41: schedule async session reset Benny Halevy
2008-11-10 20:25 ` [RFC 41/85] nfs41: lease renewal Benny Halevy
2008-11-10 20:25 ` [RFC 42/85] nfs41: sunrpc: Export the call prepare state for session reset Benny Halevy
2008-11-10 20:25 ` [RFC 43/85] nfs41: use rpc prepare call " Benny Halevy
2008-11-11 8:01 ` [pnfs] [RFC 43/85] nfs41: use rpc prepare call state for sessionreset Halevy, Benny
2008-11-10 20:25 ` [RFC 44/85] nfs41: kick start nfs41 session recovery when handling errors Benny Halevy
2008-11-10 20:26 ` [RFC 45/85] nfs41: start session recovery from nfs4_setup_sequence Benny Halevy
2008-11-10 20:26 ` [RFC 46/85] nfs41: introduce get_state_renewal_cred Benny Halevy
2008-11-10 20:26 ` [RFC 47/85] nfs41: get cred in exchange_id when cred arg is NULL Benny Halevy
2008-11-10 20:26 ` [RFC 48/85] nfs41: establish sessions-based clientid Benny Halevy
2008-11-10 20:26 ` [RFC 49/85] nfs41: recover lease in _nfs4_lookup_root Benny Halevy
2008-11-17 13:51 ` [pnfs] " Benny Halevy
2008-11-10 20:27 ` [RFC 50/85] nfs41: schedule state recovery on BAD or DEAD session Benny Halevy
2008-11-10 20:27 ` [RFC 51/85] nfs41: state reclaimer renew lease error handling Benny Halevy
2008-11-10 20:27 ` [RFC 52/85] nfs41: increment_{open,lock}_seqid Benny Halevy
2008-11-10 20:27 ` [RFC 53/85] nfs41: Add ability to read RPC call direction on TCP stream Benny Halevy
2008-11-17 13:52 ` [pnfs] " Benny Halevy
2008-11-10 20:27 ` [RFC 54/85] nfs41: Skip past the RPC call direction Benny Halevy
2008-11-10 20:27 ` [RFC 55/85] nfs41: Refactor NFSv4 callback service Benny Halevy
2008-11-10 20:28 ` [RFC 56/85] nfs41: client callback structures Benny Halevy
2008-11-10 20:28 ` [RFC 57/85] nfs41: Initialize new rpc_xprt callback related fields Benny Halevy
2008-11-10 20:28 ` [RFC 58/85] nfs41: New backchannel helper routines Benny Halevy
2008-11-10 20:28 ` [RFC 59/85] nfs41: New include/linux/sunrpc/bc_xprt.h Benny Halevy
2008-11-10 20:28 ` [RFC 60/85] nfs41: New xs_tcp_read_data() Benny Halevy
2008-11-10 20:29 ` [RFC 61/85] nfs41: Add backchannel processing support to RPC state machine Benny Halevy
2008-11-17 13:53 ` [pnfs] " Benny Halevy
2008-11-10 20:29 ` [RFC 62/85] nfs41: Backchannel callback service helper routines Benny Halevy
2008-11-10 20:29 ` [RFC 63/85] FIXME: nfs41: sunrpc: handle clnt==NULL in call_status Benny Halevy
2008-11-10 20:29 ` [RFC 64/85] nfs41: Refactor svc_process() Benny Halevy
2008-11-17 13:54 ` [pnfs] " Benny Halevy
2008-11-10 20:29 ` [RFC 65/85] nfs41: Backchannel bc_svc_process() Benny Halevy
2008-11-17 13:55 ` [pnfs] " Benny Halevy
2008-11-10 20:30 ` [RFC 66/85] nfs41: Implement NFSv4.1 callback service process Benny Halevy
2008-11-10 20:30 ` [RFC 67/85] nfs41: sunrpc: provide functions to create and destroy a svc_xprt for backchannel use Benny Halevy
2008-11-10 20:30 ` [RFC 68/85] nfs41: sunrpc: add a struct svc_xprt pointer to struct svc_serv " Benny Halevy
2008-11-10 20:30 ` [RFC 69/85] nfs41: create a svc_xprt for nfs41 callback thread and use for incoming callbacks Benny Halevy
2008-11-10 20:30 ` [RFC 70/85] nfs41: save svc_serv in nfs_callback_info Benny Halevy
2008-11-10 20:30 ` [RFC 71/85] nfs41: Add a reference to svc_serv during callback service bring up Benny Halevy
2008-11-10 20:31 ` [RFC 72/85] nfs41: Allow NFSv4 and NFSv4.1 callback services to coexist Benny Halevy
2008-11-10 20:31 ` [RFC 73/85] nfs41: Setup the backchannel Benny Halevy
2008-11-10 20:31 ` [RFC 74/85] nfs41: Client indicates presence of NFSv4.1 callback channel Benny Halevy
2008-11-10 20:31 ` [RFC 75/85] nfs41: Get the rpc_xprt * from the rpc_rqst instead of the rpc_clnt Benny Halevy
2008-11-10 20:31 ` [RFC 76/85] nfs41: Release backchannel resources associated with session Benny Halevy
2008-11-10 20:31 ` [RFC 77/85] nfs41: store minorversion in cb_compound_hdr_arg Benny Halevy
2008-11-10 20:32 ` [RFC 78/85] nfs41: decode minorversion 1 cb_compound header Benny Halevy
2008-11-10 20:32 ` [RFC 79/85] nfs41: callback numbers definitions Benny Halevy
2008-11-10 20:32 ` [RFC 80/85] nfs41: consider minorversion in callback_xdr:process_op Benny Halevy
2008-11-10 20:32 ` [RFC 81/85] nfs41: define CB_NOTIFY_DEVICEID as not supported Benny Halevy
2008-11-10 20:32 ` [RFC 82/85] nfs41: cb_sequence protocol level data structures Benny Halevy
2008-11-10 20:33 ` [RFC 83/85] nfs41: cb_sequence proc implementation Benny Halevy
2008-11-10 20:33 ` [RFC 84/85] nfs41: cb_sequence xdr implementation Benny Halevy
2008-11-10 20:33 ` [RFC 85/85] nfs41: verify CB_SEQUENCE position in callback compound Benny Halevy
2008-11-10 20:37 ` [pnfs] [RFC 0/85] nfs41 client patches for review Benny Halevy
2008-11-10 20:42 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49217539.2000902@panasas.com \
--to=bhalevy@panasas.com \
--cc=linux-nfs@vger.kernel.org \
--cc=pnfs@linux-nfs.org \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox