]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
metadump: reorder inode record sanity checks and inode buffer read
authorBrian Foster <bfoster@redhat.com>
Thu, 30 Jul 2015 23:18:22 +0000 (09:18 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 30 Jul 2015 23:18:22 +0000 (09:18 +1000)
In preparation to support sparse inode records, refactor
copy_inode_chunk() to perform all record sanity checks before the cursor
is set to the inode chunk and the inode buffer is read.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/metadump.c

index 1543b52201f45e238578cc6e573afe282f07bcd4..0398bfa6f212cbc2a68fc3ff11513aa00fff2734 100644 (file)
@@ -2131,21 +2131,10 @@ copy_inode_chunk(
                return 1;
        }
 
-       push_cur();
-       set_cur(&typtab[TYP_INODE], XFS_AGB_TO_DADDR(mp, agno, agbno),
-                       XFS_FSB_TO_BB(mp, mp->m_ialloc_blks),
-                       DB_RING_IGN, NULL);
-       if (iocur_top->data == NULL) {
-               print_warning("cannot read inode block %u/%u", agno, agbno);
-               rval = !stop_on_read_error;
-               goto pop_out;
-       }
-
        /*
         * check for basic assumptions about inode chunks, and if any
         * assumptions fail, don't process the inode chunk.
         */
-
        if ((mp->m_sb.sb_inopblock <= XFS_INODES_PER_CHUNK && off != 0) ||
                        (mp->m_sb.sb_inopblock > XFS_INODES_PER_CHUNK &&
                                        off % XFS_INODES_PER_CHUNK != 0) ||
@@ -2155,7 +2144,17 @@ copy_inode_chunk(
                if (show_warnings)
                        print_warning("badly aligned inode (start = %llu)",
                                        XFS_AGINO_TO_INO(mp, agno, agino));
-               goto skip_processing;
+               return 1;
+       }
+
+       push_cur();
+       set_cur(&typtab[TYP_INODE], XFS_AGB_TO_DADDR(mp, agno, agbno),
+                       XFS_FSB_TO_BB(mp, mp->m_ialloc_blks),
+                       DB_RING_IGN, NULL);
+       if (iocur_top->data == NULL) {
+               print_warning("cannot read inode block %u/%u", agno, agbno);
+               rval = !stop_on_read_error;
+               goto pop_out;
        }
 
        /*
@@ -2173,7 +2172,7 @@ copy_inode_chunk(
                                   XFS_INOBT_IS_FREE_DISK(rp, i)))
                        goto pop_out;
        }
-skip_processing:
+
        if (write_buf(iocur_top))
                goto pop_out;