Re: [PATCH v2] zswap: do not crash the kernel on decompression failure

Johannes Weiner
2025-02-27T04:31:51Z

On Thu, Feb 27, 2025 at 01:19:31AM +0000, Yosry Ahmed wrote:
> On Wed, Feb 26, 2025 at 04:14:45PM -0800, Nhat Pham wrote:
> > if (WARN_ON_ONCE(folio_test_large(folio)))
> > return true;
> >
> > + entry = xa_load(tree, offset);
> > + if (!entry)
> > + return false;
> > +
>
> A small comment here pointing out that we are deliberatly not setting
> uptodate because of the failure may make things more obvious, or do you
> think that's not needed?
>
> > + if (!zswap_decompress(entry, folio))
> > + return true;

How about an actual -ev and have this in swap_read_folio():

ret = zswap_load(folio);
if (ret != -ENOENT) {
folio_unlock(folio);
goto finish;
}

read from swapfile...

Then in zswap_load(), move uptodate further up like this (I had
previously suggested this):

if (!zswap_decompress(entry, folio))
return -EIO;

folio_mark_uptodate(folio);

and I think it would be clear, even without or just minimal comments.