Linux NFS development
 help / color / mirror / Atom feed
From: Benny Halevy <bhalevy@panasas.com>
To: pnfs@linux-nfs.org
Cc: "J. Bruce Fields" <bfields@fieldses.org>, linux-nfs@vger.kernel.org
Subject: Re: [pnfs] [RFC 27/51] nfsd41: sequence operation
Date: Mon, 17 Nov 2008 16:10:44 +0200	[thread overview]
Message-ID: <49217B64.5010400@panasas.com> (raw)
In-Reply-To: <1226350195-11112-1-git-send-email-bhalevy@panasas.com>

On Nov. 10, 2008, 22:49 +0200, Benny Halevy <bhalevy@panasas.com> wrote:
> Implement the sequece operation conforming to
> http://tools.ietf.org/html/draft-ietf-nfsv4-minorversion1-26
> 
> Check for stale clientid (as derived from the sessionid).
> Enforce slotid range and exactly-once semantics using
> the slotid and seqid.
> 
> If everything went well renew the client lease and
> mark the slot INPROGRESS.
> 
> Signed-off-by: Andy Adamson<andros@netapp.com>
> Signed-off-by: Benny Halevy <bhalevy@panasas.com>
> ---
>  fs/nfsd/nfs4state.c       |   88 ++++++++++++++++++++++++++++++++++++++++++++-
>  fs/nfsd/nfs4xdr.c         |   27 +++++++++++++-
>  include/linux/nfsd/xdr4.h |    8 ++++-
>  3 files changed, 119 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 77b89b6..1a9d121 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1077,12 +1077,98 @@ out:
>  	return status;
>  }
>  
> +static int
> +check_slot_seqid(u32 seqid, struct nfs41_slot *slot)
> +{
> +	dprintk("%s enter. seqid %d slot->sl_seqid %d\n", __func__, seqid,
> +		slot->sl_seqid);
> +	/* Normal */
> +	if (likely(seqid == slot->sl_seqid + 1))
> +		return nfs_ok;
> +	/* Replay */
> +	if (seqid == slot->sl_seqid)
> +		return NFSERR_REPLAY_ME;
> +	/* Wraparound */
> +	if (seqid == 1 && (slot->sl_seqid + 1) == 0)
> +		return nfs_ok;
> +	/* Misordered replay or misordered new request */
> +	return nfserr_seq_misordered;
> +}
> +
>  __be32
>  nfsd4_sequence(struct svc_rqst *r,
>  	       struct nfsd4_compound_state *cstate,
>  	       struct nfsd4_sequence *seq)
>  {
> -	return -1;	/* stub */
> +	struct nfs41_session *elem;
> +	struct nfs41_slot *slot;
> +	struct current_session *c_ses = cstate->current_ses;
> +	int status;
> +
> +	if (STALE_CLIENTID((clientid_t *)seq->sessionid))
> +		return nfserr_badsession;

review 11-13: get rid of that.
the sessionid mustn't be in the hash table.

> +
> +	nfs4_lock_state();
> +	status = nfserr_badsession;
> +	elem = find_in_sessionid_hashtbl(&seq->sessionid);

review 11-13: s/elem/session/

> +	if (!elem)
> +		goto out;
> +
> +	status = nfserr_badslot;
> +	if (seq->slotid >= elem->se_fnumslots)
> +		goto out;
> +
> +	slot = &elem->se_slots[seq->slotid];
> +	dprintk("%s: slotid %d\n", __func__, seq->slotid);
> +
> +	/* Server post op_sequence compound processing had an upcall which
> +	 * resulted in replaying the compound processing including the
> +	 * already processed op_sequence. Set current_session
> +	 * but don't bump slot->sl_seqid which was incremented in successful
> +	 * op_sequence processing prior to upcall.
> +	 */
> +	if (nfs41_get_slot_state(slot) == NFS4_SLOT_INPROGRESS) {
> +		dprintk("%s: NFS4_SLOT_INPROGRESS. set current_session\n",
> +			__func__);
> +		goto set_curr_ses;
> +	}

squash DRC changes in here.

> +
> +	status = check_slot_seqid(seq->seqid, slot);
> +	if (status == NFSERR_REPLAY_ME)
> +		goto replay;
> +	else if (status)
> +		goto out;
> +
> +	/* Success! bump slot seqid and renew clientid */
> +	slot->sl_seqid = seq->seqid;
> +	renew_client(elem->se_client);
> +	dprintk("%s: set NFS4_SLOT_INPROGRESS\n", __func__);
> +	nfs41_set_slot_state(slot, NFS4_SLOT_INPROGRESS);
> +
> +set_curr_ses:
> +	/* Set current_session. hold reference until done processing compound.
> +	 * nfs41_put_session called only if cs_slot is set
> +	 */
> +	memcpy(&c_ses->cs_sid, &seq->sessionid, sizeof(c_ses->cs_sid));
> +	BUG_ON(sizeof(c_ses->cs_sid) != sizeof(seq->sessionid));

get rid of this BUG_ON.

> +	c_ses->cs_slot = slot;
> +	nfs41_get_session(slot->sl_session);
> +
> +	/* FIXME: for now just initialize target_highest_slotid and flags
> +	 * response fields */
> +	seq->target_maxslots = seq->maxslots;
> +	seq->status_flags = 0;
> +
> +	status = nfs_ok;
> +out:
> +	dprintk("%s: return %d\n", __func__, ntohl(status));
> +	nfs4_unlock_state();
> +	return status;
> +replay:
> +	dprintk("%s: REPLAY - AKKKK! no code yet! return BAD SESSION\n",
> +		__func__);
> +	status = nfserr_badsession;
> +	goto out;
>  }
>  #endif /* CONFIG_NFSD_V4_1 */
>  
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index f49ddde..6db74f7 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -1238,7 +1238,16 @@ static __be32
>  nfsd4_decode_sequence(struct nfsd4_compoundargs *argp,
>  		      struct nfsd4_sequence *seq)
>  {
> -	return nfserr_opnotsupp;	/* stub */
> +	DECODE_HEAD;
> +
> +	READ_BUF(NFS4_MAX_SESSIONID_LEN + 16);
> +	COPYMEM(seq->sessionid, NFS4_MAX_SESSIONID_LEN);
> +	READ32(seq->seqid);
> +	READ32(seq->slotid);
> +	READ32(seq->maxslots);
> +	READ32(seq->catchthis);
> +
> +	DECODE_TAIL;
>  }
>  #endif /* CONFIG_NFSD_V4_1 */
>  
> @@ -3001,7 +3010,21 @@ static __be32
>  nfsd4_encode_sequence(struct nfsd4_compoundres *resp, int nfserr,
>  		      struct nfsd4_sequence *seq)
>  {
> -	/* stub */
> +	ENCODE_HEAD;
> +
> +	if (nfserr)
> +		goto out;
> +
> +	RESERVE_SPACE(NFS4_MAX_SESSIONID_LEN + 20);
> +	WRITEMEM(seq->sessionid, NFS4_MAX_SESSIONID_LEN);
> +	WRITE32(seq->seqid);
> +	WRITE32(seq->slotid);
> +	WRITE32(seq->maxslots);
> +	WRITE32(seq->target_maxslots);
> +	WRITE32(seq->status_flags);
> +
> +	ADJUST_ARGS();
> +out:
>  	return nfserr;
>  }
>  #endif /* CONFIG_NFSD_V4_1 */
> diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
> index 8b166d8..d78ba3c 100644
> --- a/include/linux/nfsd/xdr4.h
> +++ b/include/linux/nfsd/xdr4.h
> @@ -386,7 +386,13 @@ struct nfsd4_create_session {
>  };
>  
>  struct nfsd4_sequence {
> -	int	foo;	/* stub */
> +	nfs41_sessionid		sessionid;		/* request/response */
> +	u32			seqid;			/* request/response */
> +	u32			slotid;			/* request/response */
> +	u32			maxslots;		/* request/response */
> +	u32			catchthis;		/* request */
> +	u32			target_maxslots;	/* response */
> +	u32			status_flags;		/* response */

review 11-13: get rid of target_maxslots and status_flags for now.

>  };
>  
>  struct nfsd4_destroy_session {

  reply	other threads:[~2008-11-17 14:10 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-10 20:12 [RFC 0/51] nfs41 server patches for review Benny Halevy
2008-11-10 20:16 ` [RFC 01/51] nfsd: add etoosmall to nfserrno Benny Halevy
2008-11-10 20:39 ` [pnfs] [RFC 0/51] nfs41 server patches for review Benny Halevy
2008-11-10 20:40 ` [RFC 01/51] nfsd: add etoosmall to nfserrno Benny Halevy
2008-11-10 20:41 ` [RFC 02/51] nfsd: dprint each op status in nfsd4_proc_compound Benny Halevy
2008-11-17 13:56   ` [pnfs] " Benny Halevy
2008-11-10 20:41 ` [RFC 03/51] nfsd: git rid of nfs4_cb_null_ops declaration Benny Halevy
2008-11-10 20:41 ` [RFC 04/51] nfsd: fix file comment in fs/nfsd/nfs4xdr.c Benny Halevy
2008-11-17 13:56   ` [pnfs] " Benny Halevy
2008-11-10 20:42 ` [RFC 05/51] nfsd41: Add Kconfig symbols for NFSv4.1 Benny Halevy
2008-11-10 20:42 ` [RFC 06/51] nfsd41: define nfs41 error codes Benny Halevy
2008-11-10 20:43 ` [RFC 07/51] nfsd41: sessions basic data types Benny Halevy
2008-11-17 13:57   ` [pnfs] " Benny Halevy
2008-11-10 20:43 ` [RFC 08/51] nfsd41: introduce nfs4_client cl_sessions list Benny Halevy
2008-11-17 13:58   ` [pnfs] " Benny Halevy
2008-11-10 20:43 ` [RFC 09/51] nfsd41: destroy_session when client is expired Benny Halevy
2008-11-10 20:44 ` [RFC 10/51] nfsd41: sessionid hashing Benny Halevy
2008-11-17 13:58   ` [pnfs] " Benny Halevy
2008-11-10 20:44 ` [RFC 11/51] FIXME: nfsd41: reduce server lease time for nfs41 Benny Halevy
2008-11-17 13:59   ` [pnfs] " Benny Halevy
2008-11-10 20:44 ` [RFC 12/51] nfsd41: provide support for minor version 1 at rpc level Benny Halevy
2008-11-17 14:00   ` [pnfs] " Benny Halevy
2008-11-10 20:45 ` [RFC 13/51] FIXME: nfsd41: introduce current_session Benny Halevy
2008-11-17 14:00   ` [pnfs] " Benny Halevy
2008-11-10 20:45 ` [RFC 14/51] nfsd41: introduce nfs41_{get,set}_slot_state Benny Halevy
2008-11-17 14:01   ` [pnfs] " Benny Halevy
2008-11-10 20:45 ` [RFC 15/51] FIXME: nfsd41: free up slot unless operation is dropped Benny Halevy
2008-11-17 14:01   ` [pnfs] " Benny Halevy
2008-11-10 20:46 ` [RFC 16/51] nfsd41: stateid handling Benny Halevy
2008-11-17 14:02   ` [pnfs] " Benny Halevy
2008-11-10 20:46 ` [RFC 17/51] nfsd41: clientid handling Benny Halevy
2008-11-17 14:03   ` [pnfs] " Benny Halevy
2008-11-10 20:46 ` [RFC 18/51] nfsd41: access_valid Benny Halevy
2008-11-17 14:04   ` [pnfs] " Benny Halevy
2008-11-10 20:47 ` [RFC 19/51] nfsd41: add OPEN4_SHARE_ACCESS_WANT nfs4_stateid bmap Benny Halevy
2008-11-17 14:05   ` [pnfs] " Benny Halevy
2008-11-10 20:47 ` [RFC 20/51] nfsd: last_byte_offset Benny Halevy
2008-11-17 14:06   ` [pnfs] " Benny Halevy
2008-11-10 20:47 ` [RFC 21/51] nfsd41: xdr stubs Benny Halevy
2008-11-17 14:06   ` [pnfs] " Benny Halevy
2008-11-10 20:48 ` [RFC 22/51] nfsd41: proc stubs Benny Halevy
2008-11-17 14:07   ` [pnfs] " Benny Halevy
2008-11-10 20:48 ` [RFC 23/51] nfsd41: exchange_id operation Benny Halevy
2008-11-17 14:07   ` [pnfs] " Benny Halevy
2008-11-10 20:48 ` [RFC 24/51] nfsd41: print exchange flags when purging client Benny Halevy
2008-11-17 14:08   ` [pnfs] " Benny Halevy
2008-11-10 20:49 ` [RFC 25/51] nfsd41: create_session operation Benny Halevy
2008-11-17 14:09   ` [pnfs] " Benny Halevy
2008-11-10 20:49 ` [RFC 26/51] nfsd41: destroy_session operation Benny Halevy
2008-11-17 14:10   ` [pnfs] " Benny Halevy
2008-11-10 20:49 ` [RFC 27/51] nfsd41: sequence operation Benny Halevy
2008-11-17 14:10   ` Benny Halevy [this message]
2008-11-10 20:50 ` [RFC 28/51] FIXME: nfsd41: sunrpc: Added rpc server-side backchannel handling Benny Halevy
2008-11-17 14:11   ` [pnfs] " Benny Halevy
2008-11-10 20:50 ` [RFC 29/51] nfsd: BUG_ON_UNLOCKED_STATE Benny Halevy
2008-11-10 20:50 ` [RFC 30/51] nfsd: lock state around nfs4_put_delegation in nfsd_break_deleg_cb err path Benny Halevy
2008-11-10 20:51 ` [RFC 31/51] FIXME: nfsd: kref_get cb_client while doing the callback Benny Halevy
2008-11-10 20:51 ` [RFC 32/51] nfsd41: callback infrastructure Benny Halevy
2008-11-17 14:12   ` [pnfs] " Benny Halevy
2008-11-10 20:52 ` [RFC 33/51] nfsd41: introduce cl_cb_mutex Benny Halevy
2008-11-10 20:52 ` [RFC 34/51] nfsd41: cb_sequence callback Benny Halevy
2008-11-10 20:52 ` [RFC 35/51] nfsd41: introduce nfs4_cb_call_sync for nfs4 and nfs41 Benny Halevy
2008-11-10 20:53 ` [RFC 36/51] nfsd41: cb_recall callback Benny Halevy
2008-11-10 20:53 ` [RFC 37/51] nfsd41: pass writable attrs mask to nfsd4_decode_fattr Benny Halevy
2008-11-10 20:53 ` [RFC 38/51] nfsd41: support for 3-word long attribute bitmask Benny Halevy
2008-11-17 14:13   ` [pnfs] " Benny Halevy
2008-11-10 20:54 ` [RFC 39/51] nfsd41: SUPPATTR_EXCLCREAT attribute Benny Halevy
2008-11-10 20:54 ` [RFC 40/51] nfsd41: CREATE_EXCLUSIVE4_1 Benny Halevy
2008-11-17 14:13   ` [pnfs] " Benny Halevy
2008-11-10 20:54 ` [RFC 41/51] sunrpc: Add deferral save and restore state callback Benny Halevy
2008-11-10 20:55 ` [RFC 42/51] nfsd: save and restore defer result pages Benny Halevy
2008-11-10 20:55 ` [RFC 43/51] nfsd: deferral processing Benny Halevy
2008-11-10 20:55 ` [RFC 44/51] nfsd41: slab cache for current session Benny Halevy
2008-11-17 14:14   ` [pnfs] " Benny Halevy
2008-11-10 20:56 ` [RFC 45/51] nfsd41: DRC save, restore, and clear functions Benny Halevy
2008-11-17 14:14   ` [pnfs] " Benny Halevy
2008-11-10 20:56 ` [RFC 46/51] nfsd41: nfsd nfsd4_sequence DRC logic Benny Halevy
2008-11-10 20:56 ` [RFC 47/51] nfsd41: enforce NFS4ERR_SEQUENCE_POS operation order rules Benny Halevy
2008-11-17 14:15   ` [pnfs] " Benny Halevy
2008-11-10 20:57 ` [RFC 48/51] nfsd41: nfsd DRC logic Benny Halevy
2008-11-10 20:57 ` [RFC 49/51] nfsd41: clear DRC cache on free_session Benny Halevy
2008-11-10 20:57 ` [RFC 50/51] nfsd41: Add a create session replay cache Benny Halevy
2008-11-17 14:16   ` [pnfs] " Benny Halevy
2008-11-10 20:58 ` [RFC 51/51] nfsd41: print DRC statistics Benny Halevy
2008-11-17 14:17   ` [pnfs] " Benny Halevy

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=49217B64.5010400@panasas.com \
    --to=bhalevy@panasas.com \
    --cc=bfields@fieldses.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=pnfs@linux-nfs.org \
    /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