The check_old path in zswap_store() open-codes the same per-slot
xarray lookup and entry free that zswap_invalidate() already does.
Reuse zswap_invalidate() whose xa_empty() check skips empty per-area
trees to avoid unnecessary xarray lookup and code duplication.
Signed-off-by: Kefeng Wang <redacted>
---
mm/zswap.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/mm/zswap.c b/mm/zswap.c
index 420c405d0402..2c06e4e0e130 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1549,15 +1549,9 @@ bool zswap_store(struct folio *folio)
if (!ret) {
unsigned type = swp_type(swp);
pgoff_t offset = swp_offset(swp);
- struct zswap_entry *entry;
- struct xarray *tree;
-
- for (index = 0; index < nr_pages; ++index) {
- tree = swap_zswap_tree(swp_entry(type, offset + index));
- entry = xa_erase(tree, offset + index);
- if (entry)
- zswap_entry_free(entry);
- }
+
+ for (index = 0; index < nr_pages; ++index)
+ zswap_invalidate(type, offset + index);
}
return ret;--
2.55.0