VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   33 Branches   57 Tags
author: Will Deacon <will.deacon@arm.com> 2018-02-19 14:55:54 +0000 committer: Al Viro <viro@zeniv.linux.org.uk> 2018-02-25 12:51:09 -0500 commit: 015555fd4d2930bc0c86952c46ad88b3392f66e4 parent: 3b821409632ab778d46e807516b457dfa72736ed
Commit Summary:
fs: dcache: Avoid livelock between d_alloc_parallel and __d_add
Diffstat:
1 file changed, 6 insertions, 1 deletion
diff --git a/fs/dcache.c b/fs/dcache.c
index 32aaab21e648..bde3b6662601 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2479,7 +2479,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent,
 
 retry:
 	rcu_read_lock();
-	seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1;
+	seq = smp_load_acquire(&parent->d_inode->i_dir_seq);
 	r_seq = read_seqbegin(&rename_lock);
 	dentry = __d_lookup_rcu(parent, name, &d_seq);
 	if (unlikely(dentry)) {
@@ -2500,6 +2500,12 @@ retry:
 		rcu_read_unlock();
 		goto retry;
 	}
+
+	if (unlikely(seq & 1)) {
+		rcu_read_unlock();
+		goto retry;
+	}
+
 	hlist_bl_lock(b);
 	if (unlikely(parent->d_inode->i_dir_seq != seq)) {
 		hlist_bl_unlock(b);