]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: Remove more differences between attr & dir2
authorEric Sandeen <sandeen@sandeen.net>
Tue, 13 Oct 2015 23:32:16 +0000 (10:32 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 13 Oct 2015 23:32:16 +0000 (10:32 +1100)
This is a hodgepodge of unrelated but not-completely-trivial
chagnes to both the dir2 and attr code to make their common
code more similar.

* It removes the whichfork checking in attr_repair, because we
  only get there with XFS_ATTR_FORK.
* It changes the magic-checking logic slightly to match.
* It swaps some (bp == NULL) tests for (!bp)

These should be purely cosmetic changes.

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

index c8ba484135df0eba3007881c40f00060458d31ca..26a0e71faebdf0aad5b2e323100f05b9e0f77ac8 100644 (file)
@@ -177,19 +177,13 @@ traverse_int_dablock(xfs_mount_t  *mp,
                        free(bmp);
 
                if (!bp) {
-                       if (whichfork == XFS_DATA_FORK)
-                               do_warn(
-       _("can't read block %u (fsbno %" PRIu64 ") for directory inode %" PRIu64 "\n"),
-                                       bno, fsbno, da_cursor->ino);
-                       else
-                               do_warn(
+                       do_warn(
        _("can't read block %u (fsbno %" PRIu64 ") for attrbute fork of inode %" PRIu64 "\n"),
                                        bno, fsbno, da_cursor->ino);
                        goto error_out;
                }
 
                node = bp->b_addr;
-               btree = M_DIROPS(mp)->node_tree_p(node);
                M_DIROPS(mp)->node_hdr_from_disk(&nodehdr, node);
 
                if (nodehdr.magic != XFS_DA_NODE_MAGIC &&
@@ -210,6 +204,7 @@ _("corrupt tree block %u for directory inode %" PRIu64 "\n"),
                        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"),
@@ -235,14 +230,9 @@ _("bad header depth for directory inode %" PRIu64 "\n"),
                        if (nodehdr.level == i - 1)  {
                                i--;
                        } else  {
-                               if (whichfork == XFS_DATA_FORK)
-                                       do_warn(_("bad directory btree for "
-                                                 "directory inode %" PRIu64 "\n"),
-                                               da_cursor->ino);
-                               else
-                                       do_warn(_("bad attribute fork btree "
-                                                 "for inode %" PRIu64 "\n"),
-                                               da_cursor->ino);
+                               do_warn(_("bad attribute fork btree "
+                                         "for inode %" PRIu64 "\n"),
+                                       da_cursor->ino);
                                libxfs_putbuf(bp);
                                goto error_out;
                        }
index 9398df55c6a75589d53f74de88776710a8a1be3e..8cf981fdd8d3a964d99fbfb34fc04588c9edcb1d 100644 (file)
@@ -172,7 +172,7 @@ traverse_int_dir2block(xfs_mount_t  *mp,
                bp = da_read_buf(mp, nex, bmp, &xfs_da3_node_buf_ops);
                if (bmp != &lbmp)
                        free(bmp);
-               if (bp == NULL) {
+               if (!bp) {
                        do_warn(
 _("can't read block %u for directory inode %" PRIu64 "\n"),
                                bno, da_cursor->ino);
@@ -192,8 +192,10 @@ _("found non-root LEAFN node in inode %" PRIu64 " bno = %u\n"),
                        *rbno = 0;
                        libxfs_putbuf(bp);
                        return(1);
-               } else if (!(nodehdr.magic == XFS_DA_NODE_MAGIC ||
-                            nodehdr.magic == XFS_DA3_NODE_MAGIC))  {
+               }
+
+               if (nodehdr.magic != XFS_DA_NODE_MAGIC &&
+                   nodehdr.magic != XFS_DA3_NODE_MAGIC)  {
                        libxfs_putbuf(bp);
                        do_warn(
 _("bad dir magic number 0x%x in inode %" PRIu64 " bno = %u\n"),
@@ -574,7 +576,7 @@ _("can't get map info for block %u of directory inode %" PRIu64 "\n"),
                if (bmp != &lbmp)
                        free(bmp);
 
-               if (bp == NULL) {
+               if (!bp) {
                        do_warn(
 _("can't read block %u for directory inode %" PRIu64 "\n"),
                                dabno, cursor->ino);
@@ -589,8 +591,8 @@ _("can't read block %u for directory inode %" PRIu64 "\n"),
                 * entry count, verify level
                 */
                bad = 0;
-               if (!(nodehdr.magic == XFS_DA_NODE_MAGIC ||
-                     nodehdr.magic == XFS_DA3_NODE_MAGIC)) {
+               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,