summaryrefslogtreecommitdiff
path: root/fs/afs
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2019-07-30 16:38:51 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-09-06 11:21:55 +0300
commit9c55dc85d890b6705f3a7f801ca59c8a7059c4f4 (patch)
tree8204eacd217e96865c1dc8c0ac47530f000fc086 /fs/afs
parent24e093b9690588c41522245dfc777f7f9b210d52 (diff)
downloadlinux-9c55dc85d890b6705f3a7f801ca59c8a7059c4f4.tar.xz
afs: Only update d_fsdata if different in afs_d_revalidate()
[ Upstream commit 5dc84855b0fc7e1db182b55c5564fd539d6eff92 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/afs')
-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 855bf2b79fed..54e7f6f1405e 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -937,7 +937,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)
@@ -1001,6 +1001,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]");