A user on #xfs reported that a log replay was oopsing in
__rb_rotate_left() with a null pointer deref, and provided
an xfs_metadump image for reproduction and testing.
I traced this down to the fact that in xfs_alloc_busy_insert(),
we erased a node with rb_erase() when the new node overlapped,
but left the erased node specified as the parent node for the
So when we try to insert a new node with an erased node as
its parent, obviously things go very wrong.
97d3ac75e5e0ebf7ca38ae74cebd201c09b97ab2 xfs: exact busy extent tracking
actually fixed this, but as part of a much larger change. Here's
the relevant code from that commit:
* We also need to restart the busy extent search from the
* tree root, because erasing the node can rearrange the
* tree topology.
busyp->length = 0;
We can do essentially the same thing to older codebases by restarting
the tree search after the erase.
This should apply to .35.y through .39.y, and was tested on .39
with the oopsing replay reproducer.
Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Reviewed-by: Alex Elder <aelder@xxxxxxx>
@@ -2664,6 +2664,12 @@ restart:
new->bno + new->length) -
new->bno = min(busyp->bno, new->bno);
+ * Start the search over from the tree root, because
+ * erasing the node can rearrange the tree topology.
+ goto restart;
busyp = NULL;