]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: Fix up warning strings in da_util.c
authorEric Sandeen <sandeen@sandeen.net>
Tue, 13 Oct 2015 23:33:19 +0000 (10:33 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 13 Oct 2015 23:33:19 +0000 (10:33 +1100)
Switch the warning messages based on which fork has
encountered the problem.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/attr_repair.c
repair/da_util.c
repair/da_util.h
repair/dir2.c

index 0d3b7a59b6a74acae83758728904041b21e2f3fa..da2800db4df19efc44de0752da9db2e08d78eb5a 100644 (file)
@@ -849,7 +849,7 @@ process_leaf_attr_level(xfs_mount_t *mp,
                        libxfs_putbuf(bp);
        } while (da_bno != 0);
 
-       if (verify_final_da_path(mp, da_cursor, 0))  {
+       if (verify_final_da_path(mp, da_cursor, 0, XFS_ATTR_FORK))  {
                /*
                 * verify the final path up (right-hand-side) if still ok
                 */
index e5d553502b40cb967abc6bd0a1e44ff133638c60..89d41cccb95c04abd20e8d44ecea15e4fc5286d5 100644 (file)
@@ -67,6 +67,7 @@ namecheck(char *name, int length)
 /*
  * Multibuffer handling.
  * V2 directory blocks can be noncontiguous, needing multiple buffers.
+ * attr blocks are single blocks; this code handles that as well.
  */
 struct xfs_buf *
 da_read_buf(
@@ -101,6 +102,8 @@ da_read_buf(
        return bp;
 }
 
+#define FORKNAME(type) (type == XFS_DATA_FORK ? _("directory") : _("attribute"))
+
 /*
  * walk tree from root to the left-most leaf block reading in
  * blocks and setting up cursor.  passes back file block number of the
@@ -158,8 +161,8 @@ traverse_int_dablock(
 
                if (!bp) {
                        do_warn(
-_("can't read block %u for directory inode %" PRIu64 "\n"),
-                               bno, da_cursor->ino);
+_("can't read %s block %u for inode %" PRIu64 "\n"),
+                               FORKNAME(whichfork), bno, da_cursor->ino);
                        goto error_out;
                }
 
@@ -182,8 +185,8 @@ _("found non-root LEAFN node in inode %" PRIu64 " bno = %u\n"),
                if (nodehdr.magic != XFS_DA_NODE_MAGIC &&
                    nodehdr.magic != XFS_DA3_NODE_MAGIC) {
                        do_warn(
-_("bad dir magic number 0x%x in inode %" PRIu64 " bno = %u\n"),
-                                       nodehdr.magic,
+_("bad %s magic number 0x%x in inode %" PRIu64 " bno = %u\n"),
+                                       FORKNAME(whichfork), nodehdr.magic,
                                        da_cursor->ino, bno);
                        libxfs_putbuf(bp);
                        goto error_out;
@@ -193,16 +196,17 @@ _("bad dir magic number 0x%x in inode %" PRIu64 " bno = %u\n"),
                if (bp->b_error == -EFSBADCRC || bp->b_error == -EFSCORRUPTED) {
                        libxfs_putbuf(bp);
                        do_warn(
-_("corrupt tree block %u for directory inode %" PRIu64 "\n"),
-                               bno, da_cursor->ino);
+_("corrupt %s tree block %u for inode %" PRIu64 "\n"),
+                               FORKNAME(whichfork), bno, da_cursor->ino);
                        goto error_out;
                }
 
                btree = M_DIROPS(mp)->node_tree_p(node);
                if (nodehdr.count > geo->node_ents) {
                        do_warn(
-_("bad record count in inode %" PRIu64 ", count = %d, max = %d\n"),
-                               da_cursor->ino, nodehdr.count, geo->node_ents);
+_("bad %s record count in inode %" PRIu64 ", count = %d, max = %d\n"),
+                               FORKNAME(whichfork), da_cursor->ino,
+                               nodehdr.count, geo->node_ents);
                        libxfs_putbuf(bp);
                        goto error_out;
                }
@@ -225,8 +229,8 @@ _("bad header depth for directory inode %" PRIu64 "\n"),
                                i--;
                        } else {
                                do_warn(
-_("bad directory btree for directory inode %" PRIu64 "\n"),
-                                       da_cursor->ino);
+_("bad %s btree for inode %" PRIu64 "\n"),
+                                       FORKNAME(whichfork), da_cursor->ino);
                                libxfs_putbuf(bp);
                                goto error_out;
                        }
@@ -321,7 +325,8 @@ int
 verify_final_da_path(
        xfs_mount_t             *mp,
        da_bt_cursor_t          *cursor,
-       const int               p_level)
+       const int               p_level,
+       int                     whichfork)
 {
        xfs_da_intnode_t        *node;
        xfs_dahash_t            hashval;
@@ -352,8 +357,8 @@ verify_final_da_path(
         */
        if (entry != nodehdr.count - 1) {
                do_warn(
-               _("directory block used/count inconsistency - %d/%hu\n"),
-                       entry, nodehdr.count);
+_("%s block used/count inconsistency - %d/%hu\n"),
+                       FORKNAME(whichfork), entry, nodehdr.count);
                bad++;
        }
        /*
@@ -361,25 +366,27 @@ verify_final_da_path(
         */
        if (cursor->level[this_level].hashval >=
                                be32_to_cpu(btree[entry].hashval)) {
-               do_warn(_("directory/attribute block hashvalue inconsistency, "
-                         "expected > %u / saw %u\n"),
+               do_warn(
+_("%s block hashvalue inconsistency, expected > %u / saw %u\n"),
+                       FORKNAME(whichfork),
                        cursor->level[this_level].hashval,
                        be32_to_cpu(btree[entry].hashval));
                bad++;
        }
        if (nodehdr.forw != 0) {
-               do_warn(_("bad directory/attribute forward block pointer, "
-                         "expected 0, saw %u\n"),
-                       nodehdr.forw);
+               do_warn(
+_("bad %s forward block pointer, expected 0, saw %u\n"),
+                       FORKNAME(whichfork), nodehdr.forw);
                bad++;
        }
        if (bad) {
-               do_warn(_("bad directory block in inode %" PRIu64 "\n"), cursor->ino);
+               do_warn(_("bad %s block in inode %" PRIu64 "\n"),
+                       FORKNAME(whichfork), cursor->ino);
                return 1;
        }
        /*
         * keep track of greatest block # -- that gets
-        * us the length of the directory
+        * us the length of the directory/attribute 
         */
        if (cursor->level[this_level].bno > cursor->greatest_bno)
                cursor->greatest_bno = cursor->level[this_level].bno;
@@ -389,9 +396,9 @@ verify_final_da_path(
         */
        if (cursor->level[p_level].bno != be32_to_cpu(btree[entry].before)) {
 #ifdef XR_DIR_TRACE
-               fprintf(stderr, "bad directory btree pointer, child bno should "
+               fprintf(stderr, "bad %s btree pointer, child bno should "
                                "be %d, block bno is %d, hashval is %u\n",
-                       be16_to_cpu(btree[entry].before),
+                       FORKNAME(whichfork), be16_to_cpu(btree[entry].before),
                        cursor->level[p_level].bno,
                        cursor->level[p_level].hashval);
                fprintf(stderr, "verify_final_da_path returns 1 (bad) #1a\n");
@@ -403,17 +410,17 @@ verify_final_da_path(
                                be32_to_cpu(btree[entry].hashval)) {
                if (!no_modify) {
                        do_warn(
-_("correcting bad hashval in non-leaf dir block\n"
+_("correcting bad hashval in non-leaf %s block\n"
  "\tin (level %d) in inode %" PRIu64 ".\n"),
-                               this_level, cursor->ino);
+                               FORKNAME(whichfork), this_level, cursor->ino);
                        btree[entry].hashval = cpu_to_be32(
                                                cursor->level[p_level].hashval);
                        cursor->level[this_level].dirty++;
                } else {
                        do_warn(
-_("would correct bad hashval in non-leaf dir block\n"
+_("would correct bad hashval in non-leaf %s block\n"
  "\tin (level %d) in inode %" PRIu64 ".\n"),
-                               this_level, cursor->ino);
+                               FORKNAME(whichfork), this_level, cursor->ino);
                }
        }
 
@@ -451,7 +458,7 @@ _("would correct bad hashval in non-leaf dir block\n"
         */
        cursor->level[this_level].hashval = hashval;
 
-       return verify_final_da_path(mp, cursor, this_level);
+       return verify_final_da_path(mp, cursor, this_level, whichfork);
 }
 
 /*
@@ -564,8 +571,8 @@ verify_da_path(
                        &bmp, &lbmp);
                if (nex == 0) {
                        do_warn(
-_("can't get map info for block %u of directory inode %" PRIu64 "\n"),
-                               dabno, cursor->ino);
+_("can't get map info for %s block %u of inode %" PRIu64 "\n"),
+                               FORKNAME(whichfork), dabno, cursor->ino);
                        return 1;
                }
 
@@ -575,8 +582,8 @@ _("can't get map info for block %u of directory inode %" PRIu64 "\n"),
 
                if (!bp) {
                        do_warn(
-_("can't read block %u for directory inode %" PRIu64 "\n"),
-                               dabno, cursor->ino);
+_("can't read %s block %u for inode %" PRIu64 "\n"),
+                               FORKNAME(whichfork), dabno, cursor->ino);
                        return 1;
                }
 
@@ -592,28 +599,28 @@ _("can't read block %u for directory inode %" PRIu64 "\n"),
                if (nodehdr.magic != XFS_DA_NODE_MAGIC &&
                    nodehdr.magic != XFS_DA3_NODE_MAGIC) {
                        do_warn(
-_("bad magic number %x in block %u for directory inode %" PRIu64 "\n"),
-                               nodehdr.magic,
+_("bad magic number %x in %s block %u for inode %" PRIu64 "\n"),
+                               nodehdr.magic, FORKNAME(whichfork),
                                dabno, cursor->ino);
                        bad++;
                }
                if (nodehdr.back != cursor->level[this_level].bno) {
                        do_warn(
-_("bad back pointer in block %u for directory inode %" PRIu64 "\n"),
-                               dabno, cursor->ino);
+_("bad back pointer in %s block %u for inode %" PRIu64 "\n"),
+                               FORKNAME(whichfork), dabno, cursor->ino);
                        bad++;
                }
                if (nodehdr.count > geo->node_ents) {
                        do_warn(
-_("entry count %d too large in block %u for directory inode %" PRIu64 "\n"),
-                               nodehdr.count,
+_("entry count %d too large in %s block %u for inode %" PRIu64 "\n"),
+                               nodehdr.count, FORKNAME(whichfork),
                                dabno, cursor->ino);
                        bad++;
                }
                if (nodehdr.level != this_level) {
                        do_warn(
-_("bad level %d in block %u for directory inode %" PRIu64 "\n"),
-                               nodehdr.level,
+_("bad level %d in %s block %u for inode %" PRIu64 "\n"),
+                               nodehdr.level, FORKNAME(whichfork),
                                dabno, cursor->ino);
                        bad++;
                }
@@ -659,9 +666,9 @@ _("bad level %d in block %u for directory inode %" PRIu64 "\n"),
         */
        if (cursor->level[p_level].bno != be32_to_cpu(btree[entry].before)) {
 #ifdef XR_DIR_TRACE
-               fprintf(stderr, "bad directory btree pointer, child bno "
+               fprintf(stderr, "bad %s btree pointer, child bno "
                        "should be %d, block bno is %d, hashval is %u\n",
-                       be32_to_cpu(btree[entry].before),
+                       FORKNAME(whichfork), be32_to_cpu(btree[entry].before),
                        cursor->level[p_level].bno,
                        cursor->level[p_level].hashval);
                fprintf(stderr, "verify_da_path returns 1 (bad) #1a\n");
@@ -676,17 +683,17 @@ _("bad level %d in block %u for directory inode %" PRIu64 "\n"),
                                be32_to_cpu(btree[entry].hashval)) {
                if (!no_modify) {
                        do_warn(
-_("correcting bad hashval in interior dir block\n"
+_("correcting bad hashval in interior %s block\n"
   "\tin (level %d) in inode %" PRIu64 ".\n"),
-                               this_level, cursor->ino);
+                               FORKNAME(whichfork), this_level, cursor->ino);
                        btree[entry].hashval = cpu_to_be32(
                                                cursor->level[p_level].hashval);
                        cursor->level[this_level].dirty++;
                } else {
                        do_warn(
-_("would correct bad hashval in interior dir block\n"
+_("would correct bad hashval in interior %s block\n"
   "\tin (level %d) in inode %" PRIu64 ".\n"),
-                               this_level, cursor->ino);
+                               FORKNAME(whichfork), this_level, cursor->ino);
                }
        }
        /*
index 7971d6381189f54cbd7c3592d259ab0edf09c164..442f9f17355d6c0fb1769fb172e6281495b64e73 100644 (file)
@@ -78,5 +78,6 @@ int
 verify_final_da_path(
        xfs_mount_t     *mp,
        da_bt_cursor_t  *cursor,
-       const int       p_level);
+       const int       p_level,
+       int             whichfork);
 #endif /* _XR_DA_UTIL_H */
index 492b3e7b46bedf4f7764d4190e073f85cd9cb5e4..61912d1056cd0adb89507b26594ecea9d26b476f 100644 (file)
@@ -1179,7 +1179,7 @@ _("bad sibling back pointer for block %u in directory inode %" PRIu64 "\n"),
                } else
                        libxfs_putbuf(bp);
        } while (da_bno != 0);
-       if (verify_final_da_path(mp, da_cursor, 0)) {
+       if (verify_final_da_path(mp, da_cursor, 0, XFS_DATA_FORK)) {
                /*
                 * Verify the final path up (right-hand-side) if still ok.
                 */