linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@poochiereds.net>
To: trond.myklebust@primarydata.com
Cc: linux-nfs@vger.kernel.org, Anna Schumaker <Anna.Schumaker@netapp.com>
Subject: [RFC PATCH] nfs4: clear delegation from open states when returning delegation voluntarily
Date: Fri,  2 Oct 2015 07:18:59 -0400	[thread overview]
Message-ID: <1443784739-8565-1-git-send-email-jeff.layton@primarydata.com> (raw)

When the client goes to return a delegation, it should always update any
nfs4_state currently set up to use that delegation stateid to instead
use the open stateid. It already does do this in some cases,
particularly in the state recovery code, but not currently when the
delegation is voluntarily returned (e.g. in advance of a RENAME).

This causes the client to try to continue using the delegation stateid
after the DELEGRETURN, e.g. in LAYOUTGET. This patch fixes this by
ensuring to set the nfs4_state back to using the open stateid in
nfs_delegation_claim_opens.

That said, this code is quite difficult to follow and it's not 100%
clear to me why the delegreturn handling and the state recovery code are
squashed together like this. So, consider this an RFC patch and please
let me know if there's a better way to fix this.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
---
 fs/nfs/delegation.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index be806ead7f4d..aba906c50e8e 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -147,6 +147,10 @@ again:
 		if (!err && read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
 			err = -EAGAIN;
 		mutex_unlock(&sp->so_delegreturn_mutex);
+		write_seqlock(&state->seqlock);
+		nfs4_stateid_copy(&state->stateid, &state->open_stateid);
+		write_sequnlock(&state->seqlock);
+		clear_bit(NFS_DELEGATED_STATE, &state->flags);
 		put_nfs_open_context(ctx);
 		if (err != 0)
 			return err;
-- 
2.4.3


             reply	other threads:[~2015-10-02 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 11:18 Jeff Layton [this message]
2015-10-02 17:14 ` [PATCH v2] nfs4: reset states to use open_stateid when returning delegation voluntarily Jeff Layton
2015-10-02 19:53   ` Trond Myklebust

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=1443784739-8565-1-git-send-email-jeff.layton@primarydata.com \
    --to=jlayton@poochiereds.net \
    --cc=Anna.Schumaker@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    /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;
as well as URLs for NNTP newsgroup(s).