Skip to content

Commit

Permalink
mm/zswap: invalidate duplicate entry when !zswap_enabled
Browse files Browse the repository at this point in the history
commit 678e54d upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Chengming Zhou authored and gregkh committed Mar 1, 2024
1 parent a259173 commit 7a36109
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mm/zswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ bool zswap_store(struct folio *folio)
if (folio_test_large(folio))
return false;

if (!zswap_enabled || !tree)
if (!tree)
return false;

/*
Expand All @@ -1231,6 +1231,9 @@ bool zswap_store(struct folio *folio)
}
spin_unlock(&tree->lock);

if (!zswap_enabled)
return false;

/*
* XXX: zswap reclaim does not work with cgroups yet. Without a
* cgroup-aware entry LRU, we will push out entries system-wide based on
Expand Down

0 comments on commit 7a36109

Please sign in to comment.