linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stan Hu <stanhu@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: Stan Hu <stanhu@gmail.com>
Subject: [PATCH] NFSv4: Revalidate inode if any of its cache flags are dirty
Date: Thu, 27 Sep 2018 18:14:37 +0000	[thread overview]
Message-ID: <20180927181437.26284-1-stanhu@gmail.com> (raw)

If a file is opened on one host before it is renamed or unlinked on another,
an NFS 4.0 client will continue to use the original file handle. On some NFS
servers (e.g. Isilon), this can cause "Stale file errors" until the original
file is closed or the directory cache is refreshed.

Note that this problem does not occur with an NFS 4.1 client since the
revalidation will always occur because the NFS_CAP_ATOMIC_OPEN_V1 flag is
enabled.
---
 fs/nfs/dir.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 8bfaa658b2c1..25259b0b41f9 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1626,6 +1626,9 @@ static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags)
 	/* We cannot do exclusive creation on a positive dentry */
 	if (flags & LOOKUP_EXCL)
 		goto no_open;
+	/* Revalidate if any cache flags are dirty */
+	if (NFS_I(inode)->cache_validity)
+		goto no_open;
 
 	/* Let f_op->open() actually open (and revalidate) the file */
 	ret = 1;
-- 
2.16.2

                 reply	other threads:[~2018-09-28  0:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180927181437.26284-1-stanhu@gmail.com \
    --to=stanhu@gmail.com \
    --cc=linux-nfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).