Thread (13 messages) 13 messages, 2 authors, 2018-08-10
STALE2896d

[PATCH 1/4] xfs: xrep_findroot_block should reject root blocks with siblings

From: Darrick J. Wong <hidden>
Date: 2018-08-08 06:14:48
Subsystem: filesystems (vfs and infrastructure), the rest, xfs filesystem · Maintainers: Alexander Viro, Christian Brauner, Linus Torvalds, Carlos Maiolino

From: Darrick J. Wong <redacted>

In xrep_findroot_block, if we find a candidate root block with sibling
pointers or sibling blocks on the same tree level, we should not return
that block as a tree root because root blocks cannot have siblings.

Signed-off-by: Darrick J. Wong <redacted>
---
 fs/xfs/scrub/repair.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 85b048b341a0..6c199e2ebb81 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -727,6 +727,23 @@ xrep_findroot_block(
 	bp->b_ops->verify_read(bp);
 	if (bp->b_error)
 		goto out;
+
+	/* Root blocks can't have siblings. */
+	if (btblock->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) ||
+	    btblock->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK))
+		goto out;
+
+	/*
+	 * If we find a second block at this level, ignore this level because
+	 * it can't possibly be a root level.  Maybe we'll find a higher level,
+	 * or maybe the rmap information is garbage.
+	 */
+	if (fab->root != NULLAGBLOCK &&
+	    fab->height == xfs_btree_get_level(btblock) + 1) {
+		fab->root = NULLAGBLOCK;
+		goto out;
+	}
+
 	fab->root = agbno;
 	fab->height = xfs_btree_get_level(btblock) + 1;
 	*found_it = true;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help