From: trondmy@kernel.org
To: linux-nfs@vger.kernel.org
Subject: [PATCH 5/5] NFS: Fix dentry verifier races
Date: Wed, 29 Sep 2021 09:49:44 -0400 [thread overview]
Message-ID: <20210929134944.632844-5-trondmy@kernel.org> (raw)
In-Reply-To: <20210929134944.632844-4-trondmy@kernel.org>
From: Trond Myklebust <trond.myklebust@hammerspace.com>
If the directory changed while we were revalidating the dentry, then
don't update the dentry verifier. There is no value in setting the
verifier to an older value, and we could end up overwriting a more up to
date verifier from a parallel revalidation.
Fixes: efeda80da38d ("NFSv4: Fix revalidation of dentries with delegations")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/dir.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 358033aea235..033e9b145627 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1276,13 +1276,12 @@ static bool nfs_verifier_is_delegated(struct dentry *dentry)
static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf)
{
struct inode *inode = d_inode(dentry);
+ struct inode *dir = d_inode(dentry->d_parent);
- if (!nfs_verifier_is_delegated(dentry) &&
- !nfs_verify_change_attribute(d_inode(dentry->d_parent), verf))
- goto out;
+ if (!nfs_verify_change_attribute(dir, verf))
+ return;
if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
nfs_set_verifier_delegated(&verf);
-out:
dentry->d_time = verf;
}
--
2.31.1
next prev parent reply other threads:[~2021-09-29 13:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-29 13:49 [PATCH 1/5] NFS: Don't set NFS_INO_DATA_INVAL_DEFER and NFS_INO_INVALID_DATA trondmy
2021-09-29 13:49 ` [PATCH 2/5] NFS: Ignore the directory size when marking for revalidation trondmy
2021-09-29 13:49 ` [PATCH 3/5] NFS: Fix up nfs_readdir_inode_mapping_valid() trondmy
2021-09-29 13:49 ` [PATCH 4/5] NFS: Further optimisations for 'ls -l' trondmy
2021-09-29 13:49 ` trondmy [this message]
2021-09-29 14:56 ` Benjamin Coddington
2021-09-29 16:23 ` Trond Myklebust
2021-09-29 20:21 ` Benjamin Coddington
2021-09-29 20:35 ` Trond Myklebust
2021-09-30 14:29 ` Benjamin Coddington
2021-09-30 14:51 ` 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=20210929134944.632844-5-trondmy@kernel.org \
--to=trondmy@kernel.org \
--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).