Re: [PATCH v4 04/11] mm: zswap: add range lookup for large-folio swapin
From: Yosry Ahmed
Date: Mon Jul 13 2026 - 12:08:11 EST
> /**
> * zswap_load() - load a folio from zswap
> * @folio: folio to load
> @@ -1571,10 +1588,9 @@ bool zswap_store(struct folio *folio)
> * NOT marked up-to-date, so that an IO error is emitted (e.g. do_swap_page()
> * will SIGBUS).
> *
> - * -EINVAL: if the swapped out content was in zswap, but the page belongs
> - * to a large folio, which is not supported by zswap. The folio is unlocked,
> - * but NOT marked up-to-date, so that an IO error is emitted (e.g.
> - * do_swap_page() will SIGBUS).
> + * -EIO: if a slot in a large-folio range is unexpectedly still in zswap.
> + * The folio is unlocked, but NOT marked up-to-date, so that an IO
> + * error is emitted (e.g. do_swap_page() will SIGBUS).
Just curious, why the change from -EINVAL to -EIO here? Does it matter
in practice or is it just a matter of personal taste? :)
> *
> * -ENOENT: if the swapped out content was not in zswap. The folio remains
> * locked on return.
> @@ -1593,13 +1609,19 @@ int zswap_load(struct folio *folio)
> return -ENOENT;
>
> /*
> - * Large folios should not be swapped in while zswap is being used, as
> - * they are not properly handled. Zswap does not properly load large
> - * folios, and a large folio may only be partially in zswap.
> + * A large folio reaches zswap_load() only when its whole range is
> + * expected to be on disk: PMD swap-entry consumers split before
> + * calling into PMD-order swapin whenever any slot is still in zswap.
> + * Confirm the range is entirely absent from zswap and return -ENOENT
> + * so the caller reads it from disk; if a slot is unexpectedly still in
> + * zswap, fail the read rather than return partially-initialized data.
> */
> - if (WARN_ON_ONCE(folio_test_large(folio))) {
> - folio_unlock(folio);
> - return -EINVAL;
> + if (folio_test_large(folio)) {
> + if (zswap_is_present(swp, folio_nr_pages(folio))) {
> + folio_unlock(folio);
> + return -EIO;
> + }
> + return -ENOENT;
> }
>
> entry = xa_load(tree, offset);
> --
> 2.53.0-Meta
>