Skip to content

Commit 678e54d

Browse files
Chengming Zhouakpm00
authored andcommitted
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: 42c06a0 ("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>
1 parent 1eb1e98 commit 678e54d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mm/zswap.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1518,7 +1518,7 @@ bool zswap_store(struct folio *folio)
15181518
if (folio_test_large(folio))
15191519
return false;
15201520

1521-
if (!zswap_enabled || !tree)
1521+
if (!tree)
15221522
return false;
15231523

15241524
/*
@@ -1533,6 +1533,10 @@ bool zswap_store(struct folio *folio)
15331533
zswap_invalidate_entry(tree, dupentry);
15341534
}
15351535
spin_unlock(&tree->lock);
1536+
1537+
if (!zswap_enabled)
1538+
return false;
1539+
15361540
objcg = get_obj_cgroup_from_folio(folio);
15371541
if (objcg && !obj_cgroup_may_zswap(objcg)) {
15381542
memcg = get_mem_cgroup_from_objcg(objcg);

0 commit comments

Comments
 (0)