Commit 4363834d authored by Zizhi Wo's avatar Zizhi Wo Committed by Baokun Li
Browse files

fscache/cachefiles: add a memory barrier for page_write

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT



--------------------------------

In some functions with wake_up_bit(&cookie->flags, 0), the wake_up depends
on removing the cookie from the radix tree, but there is no memory barrier
between them.

Fix this issue by adding the memory barrier.

Fixes: 201a1542 ("FS-Cache: Handle pages pending storage that get evicted under OOM conditions")
Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
parent 8cfd33ca
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie,
		fscache_stat(&fscache_n_store_vmscan_gone);
	}

	/* Make sure the delete operation is performed before waking. */
	smp_mb();
	wake_up_bit(&cookie->flags, 0);
	trace_fscache_wake_cookie(cookie);
	if (xpage)
@@ -171,6 +173,8 @@ static void fscache_end_page_write(struct fscache_object *object,
			trace_fscache_page(cookie, page, fscache_page_write_end_pend);
		}
		spin_unlock(&cookie->stores_lock);
		/* Make sure the delete operation is performed before waking. */
		smp_mb();
		wake_up_bit(&cookie->flags, 0);
		trace_fscache_wake_cookie(cookie);
	} else {
@@ -988,6 +992,8 @@ void fscache_invalidate_writes(struct fscache_cookie *cookie)
			put_page(results[i]);
	}

	/* Make sure the delete operation is performed before waking. */
	smp_mb();
	wake_up_bit(&cookie->flags, 0);
	trace_fscache_wake_cookie(cookie);