On Fri, Apr 02, 2021 at 04:13:05AM +0100, Matthew Wilcox wrote: > + for (;;) { > + xas_load(xas); > + if (!xas_is_node(xas)) > + break; > + xas_delete_node(xas); > + xas->xa_index -= XA_CHUNK_SIZE; > + if (xas->xa_index < index) > + break; That's a bug. index can be 0, so the condition would never be true. It should be: if (xas->xa_index <= (index | XA_CHUNK_MASK)) break; xas->xa_index -= XA_CHUNK_SIZE; The test doesn't notice this bug because the tree is otherwise empty, and the !xas_is_node(xas) condition is hit first. The next test will notice this.