]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: trash dirattr btrees that cycle to the root
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 26 Jan 2017 02:02:43 +0000 (20:02 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 26 Jan 2017 02:02:43 +0000 (20:02 -0600)
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 <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
repair/attr_repair.c

index b855a101864c5a31a3011071e4da6ce963f1954c..158e31a14184a66f231130e5bc781c583020543b 100644 (file)
@@ -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"),