Skip to content

Commit

Permalink
NFS: Fix dentry verifier races
Browse files Browse the repository at this point in the history
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: efeda80 ("NFSv4: Fix revalidation of dentries with delegations")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Tested-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
  • Loading branch information
Trond Myklebust committed Oct 4, 2021
1 parent ff81dfb commit cec08f4
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit cec08f4

Please sign in to comment.