[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210401170615.GH351017@casper.infradead.org>
Date: Thu, 1 Apr 2021 18:06:15 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Hugh Dickins <hughd@...gle.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org, linux-nvdimm@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: Re: BUG_ON(!mapping_empty(&inode->i_data))
On Wed, Mar 31, 2021 at 02:58:12PM -0700, Hugh Dickins wrote:
> I suspect there's a bug in the XArray handling in collapse_file(),
> which sometimes leaves empty nodes behind.
Urp, yes, that can easily happen.
/* This will be less messy when we use multi-index entries */
do {
xas_lock_irq(&xas);
xas_create_range(&xas);
if (!xas_error(&xas))
break;
if (!xas_nomem(&xas, GFP_KERNEL)) {
result = SCAN_FAIL;
goto out;
}
xas_create_range() can absolutely create nodes with zero entries.
So if we create m/n nodes and then it runs out of memory (or cgroup
denies it), we can leave nodes in the tree with zero entries.
There are three options for fixing it ...
- Switch to using multi-index entries. We need to do this anyway, but
I don't yet have a handle on the bugs that you found last time I
pushed this into linux-next. At -rc5 seems like a late stage to be
trying this solution.
- Add an xas_prune_range() that gets called on failure. Should be
straightforward to write, but will be obsolete as soon as we do the
above and it's a pain for the callers.
- Change how xas_create_range() works to merely preallocate the xa_nodes
and not insert them into the tree until we're trying to insert data into
them. I favour this option, and this scenario is amenable to writing
a test that will simulate failure halfway through.
I'm going to start on option 3 now.
Powered by blists - more mailing lists