mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 04:34:08 +08:00
mm/zswap: invalidate duplicate entry when !zswap_enabled
We have to invalidate any duplicate entry even when !zswap_enabled since
zswap can be disabled anytime. If the folio store success before, then
got dirtied again but zswap disabled, we won't invalidate the old
duplicate entry in the zswap_store(). So later lru writeback may
overwrite the new data in swapfile.
Link: https://lkml.kernel.org/r/20240208023254.3873823-1-chengming.zhou@linux.dev
Fixes: 42c06a0e8e
("mm: kill frontswap")
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
1eb1e98437
commit
678e54d4bb
@ -1518,7 +1518,7 @@ bool zswap_store(struct folio *folio)
|
||||
if (folio_test_large(folio))
|
||||
return false;
|
||||
|
||||
if (!zswap_enabled || !tree)
|
||||
if (!tree)
|
||||
return false;
|
||||
|
||||
/*
|
||||
@ -1533,6 +1533,10 @@ bool zswap_store(struct folio *folio)
|
||||
zswap_invalidate_entry(tree, dupentry);
|
||||
}
|
||||
spin_unlock(&tree->lock);
|
||||
|
||||
if (!zswap_enabled)
|
||||
return false;
|
||||
|
||||
objcg = get_obj_cgroup_from_folio(folio);
|
||||
if (objcg && !obj_cgroup_may_zswap(objcg)) {
|
||||
memcg = get_mem_cgroup_from_objcg(objcg);
|
||||
|
Loading…
Reference in New Issue
Block a user