From: Zizhi Wo wozizhi@huawei.com
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: 201a15428bd5 ("FS-Cache: Handle pages pending storage that get evicted under OOM conditions") Signed-off-by: Zizhi Wo wozizhi@huawei.com Signed-off-by: Baokun Li libaokun1@huawei.com --- fs/fscache/page.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/fs/fscache/page.c b/fs/fscache/page.c index 95490d809b5e..0b5e477cf62b 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -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);