]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
db: add finobt support to metadump
authorBrian Foster <bfoster@redhat.com>
Mon, 26 May 2014 23:07:36 +0000 (09:07 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 26 May 2014 23:07:36 +0000 (09:07 +1000)
Include the free inode btree in metadump images. If the source fs
is finobt-enabled, run an additional scan_btree() of the finobt.
Since the private 'agi' scanfunc_ino() parameter is unused, change
the private parameter to a flag that indicates whether the current
scan is for the inobt or finobt. If the latter, we skip copying the
actual inode chunks as this work is already performed by the inobt
scan.

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 09bb85ac014db53e76664b819c051292a7378a16..38cd441cbeba291092298c253d2b10d6648857c7 100644 (file)
@@ -1917,6 +1917,7 @@ scanfunc_ino(
        xfs_inobt_ptr_t         *pp;
        int                     i;
        int                     numrecs;
+       int                     finobt = *(int *) arg;
 
        numrecs = be16_to_cpu(block->bb_numrecs);
 
@@ -1928,6 +1929,14 @@ scanfunc_ino(
                                        typtab[btype].name, agno, agbno);
                        numrecs = mp->m_inobt_mxr[0];
                }
+
+               /*
+                * Only copy the btree blocks for the finobt. The inobt scan
+                * copies the inode chunks.
+                */
+               if (finobt)
+                       return 1;
+
                rp = XFS_INOBT_REC_ADDR(mp, block, 1);
                for (i = 0; i < numrecs; i++, rp++) {
                        if (!copy_inode_chunk(agno, rp))
@@ -1967,6 +1976,7 @@ copy_inodes(
 {
        xfs_agblock_t           root;
        int                     levels;
+       int                     finobt = 0;
 
        root = be32_to_cpu(agi->agi_root);
        levels = be32_to_cpu(agi->agi_level);
@@ -1985,7 +1995,20 @@ copy_inodes(
                return 1;
        }
 
-       return scan_btree(agno, root, levels, TYP_INOBT, agi, scanfunc_ino);
+       if (!scan_btree(agno, root, levels, TYP_INOBT, &finobt, scanfunc_ino))
+               return 0;
+
+       if (xfs_sb_version_hasfinobt(&mp->m_sb)) {
+               root = be32_to_cpu(agi->agi_free_root);
+               levels = be32_to_cpu(agi->agi_free_level);
+
+               finobt = 1;
+               if (!scan_btree(agno, root, levels, TYP_INOBT, &finobt,
+                               scanfunc_ino))
+                       return 0;
+       }
+
+       return 1;
 }
 
 static int