From: Brian Foster Date: Tue, 23 Jun 2015 05:08:48 +0000 (+1000) Subject: metadump: reorder inode record sanity checks and inode buffer read X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3fe33d921220b7e9ee5801f63c38c83714d8e914;p=thirdparty%2Fxfsprogs-dev.git metadump: reorder inode record sanity checks and inode buffer read 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 Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/db/metadump.c b/db/metadump.c index 94f92bcba..e101501df 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -1846,21 +1846,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) || @@ -1870,7 +1859,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; } /* @@ -1889,7 +1888,7 @@ copy_inode_chunk( if (!process_inode(agno, agino + i, dip)) goto pop_out; } -skip_processing: + if (write_buf(iocur_top)) goto pop_out;