All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success
@ 2015-06-02 10:58 Kinglong Mee
  2015-06-11  1:38 ` Kinglong Mee
  2015-06-12  1:35 ` [PATCH] NFS: Ensure that we update the sequence id under the slot table lock Trond Myklebust
  0 siblings, 2 replies; 5+ messages in thread
From: Kinglong Mee @ 2015-06-02 10:58 UTC (permalink / raw)
  To: Trond Myklebust, linux-nfs
  Cc: Weston Andros Adamson, J. Bruce Fields, kinglongmee, Christoph Hellwig

When testing pnfs layout, nfsd got error NFS4ERR_SEQ_MISORDERED.
It is caused by nfs return NFS4ERR_DELAY before validate_seqid(),
don't update the sequnce id, but nfsd updates the sequnce id !!!

According to RFC5661 20.9.3,
" If CB_SEQUENCE returns an error, then the state of the slot
  (sequence ID, cached reply) MUST NOT change. "

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/nfs/callback_proc.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 197806f..7e9653a 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -327,10 +327,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
 	dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr);
 
 	/* Normal */
-	if (likely(args->csa_sequenceid == slot->seq_nr + 1)) {
-		slot->seq_nr++;
+	if (likely(args->csa_sequenceid == slot->seq_nr + 1))
 		goto out_ok;
-	}
 
 	/* Replay */
 	if (args->csa_sequenceid == slot->seq_nr) {
@@ -418,6 +416,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 			      struct cb_process_state *cps)
 {
 	struct nfs4_slot_table *tbl;
+	struct nfs4_slot *slot;
 	struct nfs_client *clp;
 	int i;
 	__be32 status = htonl(NFS4ERR_BADSESSION);
@@ -429,7 +428,9 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 
 	if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
 		goto out;
+
 	tbl = &clp->cl_session->bc_slot_table;
+	slot = tbl->slots + args->csa_slotid;
 
 	spin_lock(&tbl->slot_tbl_lock);
 	/* state manager is resetting the session */
@@ -444,7 +445,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 		goto out;
 	}
 
-	status = validate_seqid(&clp->cl_session->bc_slot_table, args);
+	status = validate_seqid(tbl, args);
 	spin_unlock(&tbl->slot_tbl_lock);
 	if (status)
 		goto out;
@@ -468,6 +469,13 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
 	res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
 
+	/*
+	 * RFC5661 20.9.3
+	 * If CB_SEQUENCE returns an error, then the state of the slot
+	 * (sequence ID, cached reply) MUST NOT change.
+	 */
+	slot->seq_nr++;
+
 out:
 	cps->clp = clp; /* put in nfs4_callback_compound */
 	for (i = 0; i < args->csa_nrclists; i++)
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success
  2015-06-02 10:58 [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success Kinglong Mee
@ 2015-06-11  1:38 ` Kinglong Mee
  2015-06-11  8:20   ` Christoph Hellwig
  2015-06-12  1:35 ` [PATCH] NFS: Ensure that we update the sequence id under the slot table lock Trond Myklebust
  1 sibling, 1 reply; 5+ messages in thread
From: Kinglong Mee @ 2015-06-11  1:38 UTC (permalink / raw)
  To: Trond Myklebust, linux-nfs
  Cc: Weston Andros Adamson, J. Bruce Fields, Christoph Hellwig

ping .... 

On 6/2/2015 6:58 PM, Kinglong Mee wrote:
> When testing pnfs layout, nfsd got error NFS4ERR_SEQ_MISORDERED.
> It is caused by nfs return NFS4ERR_DELAY before validate_seqid(),
> don't update the sequnce id, but nfsd updates the sequnce id !!!
> 
> According to RFC5661 20.9.3,
> " If CB_SEQUENCE returns an error, then the state of the slot
>   (sequence ID, cached reply) MUST NOT change. "
> 
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  fs/nfs/callback_proc.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
> index 197806f..7e9653a 100644
> --- a/fs/nfs/callback_proc.c
> +++ b/fs/nfs/callback_proc.c
> @@ -327,10 +327,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
>  	dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr);
>  
>  	/* Normal */
> -	if (likely(args->csa_sequenceid == slot->seq_nr + 1)) {
> -		slot->seq_nr++;
> +	if (likely(args->csa_sequenceid == slot->seq_nr + 1))
>  		goto out_ok;
> -	}
>  
>  	/* Replay */
>  	if (args->csa_sequenceid == slot->seq_nr) {
> @@ -418,6 +416,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
>  			      struct cb_process_state *cps)
>  {
>  	struct nfs4_slot_table *tbl;
> +	struct nfs4_slot *slot;
>  	struct nfs_client *clp;
>  	int i;
>  	__be32 status = htonl(NFS4ERR_BADSESSION);
> @@ -429,7 +428,9 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
>  
>  	if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
>  		goto out;
> +
>  	tbl = &clp->cl_session->bc_slot_table;
> +	slot = tbl->slots + args->csa_slotid;
>  
>  	spin_lock(&tbl->slot_tbl_lock);
>  	/* state manager is resetting the session */
> @@ -444,7 +445,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
>  		goto out;
>  	}
>  
> -	status = validate_seqid(&clp->cl_session->bc_slot_table, args);
> +	status = validate_seqid(tbl, args);
>  	spin_unlock(&tbl->slot_tbl_lock);
>  	if (status)
>  		goto out;
> @@ -468,6 +469,13 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
>  	res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
>  	res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
>  
> +	/*
> +	 * RFC5661 20.9.3
> +	 * If CB_SEQUENCE returns an error, then the state of the slot
> +	 * (sequence ID, cached reply) MUST NOT change.
> +	 */
> +	slot->seq_nr++;
> +
>  out:
>  	cps->clp = clp; /* put in nfs4_callback_compound */
>  	for (i = 0; i < args->csa_nrclists; i++)
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success
  2015-06-11  1:38 ` Kinglong Mee
@ 2015-06-11  8:20   ` Christoph Hellwig
  2015-06-11  9:13     ` Kinglong Mee
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2015-06-11  8:20 UTC (permalink / raw)
  To: Kinglong Mee
  Cc: Trond Myklebust, linux-nfs, Weston Andros Adamson, J. Bruce Fields

Hi Kinglong,

when we last brought up this issue the recommendation was to follow
the model in the clients nfs41_sequence_done() which handles even
more corner cases.  Given that my previous fixes in that area were
just a bandaid I probably shouldn't complain about piece mail handling,
but if you have a little spare time available implementing the full
set of checks might be worthwhile.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success
  2015-06-11  8:20   ` Christoph Hellwig
@ 2015-06-11  9:13     ` Kinglong Mee
  0 siblings, 0 replies; 5+ messages in thread
From: Kinglong Mee @ 2015-06-11  9:13 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Trond Myklebust, linux-nfs, Weston Andros Adamson,
	J. Bruce Fields, kinglongmee

On 6/11/2015 4:20 PM, Christoph Hellwig wrote:
> Hi Kinglong,
> 
> when we last brought up this issue the recommendation was to follow
> the model in the clients nfs41_sequence_done() which handles even
> more corner cases.  Given that my previous fixes in that area were
> just a bandaid I probably shouldn't complain about piece mail handling,
> but if you have a little spare time available implementing the full
> set of checks might be worthwhile.

Thank you for your comments.

I have see your patches sits "nfsd: callback fixes". You said process as
nfs41_sequence_done() for handling error cases is server's logical.

Those two patches for NFS client are fix two bugs.

The first one is fix that between validate_seqid() nfs can return error
to nfs server. NFS server cannot make sure whether NFS client has update
the sequence ID.

Also, according to RFC, "If CB_SEQUENCE returns an error, then the state
of the slot (sequence ID, cached reply) MUST NOT change.",
so that this this patch is out.

The second for nfs is fix the initialize problem of cb_sequenceres
when meeting NFS4ERR_RETRY_UNCACHED_REP.

And, other two patches for nfsd, 
The first is fix a infinite loop caused by your last patch I meet.
The second is as you said following to nfs41_sequence_done() maybe better.

thanks
Kinglong Mee

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] NFS: Ensure that we update the sequence id under the slot table lock
  2015-06-02 10:58 [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success Kinglong Mee
  2015-06-11  1:38 ` Kinglong Mee
@ 2015-06-12  1:35 ` Trond Myklebust
  1 sibling, 0 replies; 5+ messages in thread
From: Trond Myklebust @ 2015-06-12  1:35 UTC (permalink / raw)
  To: Kinglong Mee
  Cc: linux-nfs, Weston Andros Adamson, J Bruce Fields, Christoph Hellwig

Fix a callback slot table regression.

Fixes: e937ee714b2d ("nfs: Only update callback sequnce id when CB_SEQUENCE success")
Cc: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfs/callback_proc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index 17a5c571a006..29e3c1b011b7 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -435,14 +435,13 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	spin_lock(&tbl->slot_tbl_lock);
 	/* state manager is resetting the session */
 	if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
-		spin_unlock(&tbl->slot_tbl_lock);
 		status = htonl(NFS4ERR_DELAY);
 		/* Return NFS4ERR_BADSESSION if we're draining the session
 		 * in order to reset it.
 		 */
 		if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
 			status = htonl(NFS4ERR_BADSESSION);
-		goto out;
+		goto out_unlock;
 	}
 
 	memcpy(&res->csr_sessionid, &args->csa_sessionid,
@@ -453,9 +452,8 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
 
 	status = validate_seqid(tbl, args);
-	spin_unlock(&tbl->slot_tbl_lock);
 	if (status)
-		goto out;
+		goto out_unlock;
 
 	cps->slotid = args->csa_slotid;
 
@@ -466,7 +464,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	 */
 	if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
 		status = htonl(NFS4ERR_DELAY);
-		goto out;
+		goto out_unlock;
 	}
 
 	/*
@@ -475,6 +473,8 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 	 * (sequence ID, cached reply) MUST NOT change.
 	 */
 	slot->seq_nr++;
+out_unlock:
+	spin_unlock(&tbl->slot_tbl_lock);
 
 out:
 	cps->clp = clp; /* put in nfs4_callback_compound */
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-06-12  1:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-02 10:58 [PATCH 1/2] nfs: Only update callback sequnce id when CB_SEQUENCE success Kinglong Mee
2015-06-11  1:38 ` Kinglong Mee
2015-06-11  8:20   ` Christoph Hellwig
2015-06-11  9:13     ` Kinglong Mee
2015-06-12  1:35 ` [PATCH] NFS: Ensure that we update the sequence id under the slot table lock Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.