From ce746a2928d43face98cdb6684dea343b8e9b481 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 25 Jan 2017 20:02:43 -0600 Subject: [PATCH] xfs_repair: trash dirattr btrees that cycle to the root If xfs_repair detects a dir/attr btree that cycles back to the root, the tree should be cleared and/or rebuilt instead of simply aborting the repair program. [sandeen: move check outside main loop] Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- repair/attr_repair.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/repair/attr_repair.c b/repair/attr_repair.c index b855a1018..158e31a14 100644 --- a/repair/attr_repair.c +++ b/repair/attr_repair.c @@ -753,18 +753,23 @@ process_leaf_attr_level(xfs_mount_t *mp, struct xfs_attr3_icleaf_hdr leafhdr; da_bno = da_cursor->level[0].bno; + /* + * 0 is the root block and no block + * pointer can point to the root block of the btree + */ + if (da_bno == 0) { + do_warn( + _("btree cycle detected in attribute fork for inode %" PRIu64 "\n"), + ino); + goto error_out; + } + ino = da_cursor->ino; prev_bno = 0; do { repair = 0; dev_bno = blkmap_get(da_cursor->blkmap, da_bno); - /* - * 0 is the root block and no block - * pointer can point to the root block of the btree - */ - ASSERT(da_bno != 0); - if (dev_bno == NULLFSBLOCK) { do_warn( _("can't map block %u for attribute fork for inode %" PRIu64 "\n"), -- 2.47.2