Re: [PATCH] xa_load() needs a NULL check before locking check

From: Matthew Wilcox
Date: Wed Feb 15 2023 - 08:32:04 EST


On Wed, Feb 15, 2023 at 09:14:17PM +0800, void0red wrote:
> folio = xa_load(&ractl->mapping->i_pages, ractl->_index);
> + if (!folio) {
> + VM_BUG_ON(!folio);
> + return NULL;
> + }
> VM_BUG_ON_FOLIO(!folio_test_locked(folio), folio);

Why does this need to happen? The caller has inserted all these folios
into the xarray. They're locked, so they can't be removed. If they're
not there, something has gone horribly wrong and crashing is a good
response.

> ractl->_batch_count = folio_nr_pages(folio);
>
> --
> 2.34.1
>