]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
afs: Only update d_fsdata if different in afs_d_revalidate()
authorDavid Howells <dhowells@redhat.com>
Tue, 30 Jul 2019 13:38:51 +0000 (14:38 +0100)
committerDavid Howells <dhowells@redhat.com>
Tue, 30 Jul 2019 13:38:51 +0000 (14:38 +0100)
In the in-kernel afs filesystem, d_fsdata is set with the data version of
the parent directory.  afs_d_revalidate() will update this to the current
directory version, but it shouldn't do this if it the value it read from
d_fsdata is the same as no lock is held and cmpxchg() is not used.

Fix the code to only change the value if it is different from the current
directory version.

Fixes: 260a980317da ("[AFS]: Add "directory write" support.")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/dir.c

index 20aa18b38a493da24b8b8b097d03c0b4c9d3bde7..618e26cea88782f249417767ba76169a66cf58fe 100644 (file)
@@ -1017,7 +1017,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
        dir_version = (long)dir->status.data_version;
        de_version = (long)dentry->d_fsdata;
        if (de_version == dir_version)
-               goto out_valid;
+               goto out_valid_noupdate;
 
        dir_version = (long)dir->invalid_before;
        if (de_version - dir_version >= 0)
@@ -1081,6 +1081,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
 
 out_valid:
        dentry->d_fsdata = (void *)dir_version;
+out_valid_noupdate:
        dput(parent);
        key_put(key);
        _leave(" = 1 [valid]");