summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-07-30 09:38:51 -0400
committerDavid Howells <dhowells@redhat.com>2019-07-30 09:38:51 -0400
commit5dc84855b0fc7e1db182b55c5564fd539d6eff92 (patch)
tree0290def0100fe4508089c98d0c3f9aea2118dfe0
parent37c0bbb3326674940e657118306ac52364314523 (diff)
afs: Only update d_fsdata if different in afs_d_revalidate()
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>
-rw-r--r--fs/afs/dir.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 20aa18b38a49..618e26cea887 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -1017,7 +1017,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
1017 dir_version = (long)dir->status.data_version; 1017 dir_version = (long)dir->status.data_version;
1018 de_version = (long)dentry->d_fsdata; 1018 de_version = (long)dentry->d_fsdata;
1019 if (de_version == dir_version) 1019 if (de_version == dir_version)
1020 goto out_valid; 1020 goto out_valid_noupdate;
1021 1021
1022 dir_version = (long)dir->invalid_before; 1022 dir_version = (long)dir->invalid_before;
1023 if (de_version - dir_version >= 0) 1023 if (de_version - dir_version >= 0)
@@ -1081,6 +1081,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
1081 1081
1082out_valid: 1082out_valid:
1083 dentry->d_fsdata = (void *)dir_version; 1083 dentry->d_fsdata = (void *)dir_version;
1084out_valid_noupdate:
1084 dput(parent); 1085 dput(parent);
1085 key_put(key); 1086 key_put(key);
1086 _leave(" = 1 [valid]"); 1087 _leave(" = 1 [valid]");