]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
metadump: contiguous metadata object need to be split
authorDave Chinner <dchinner@redhat.com>
Mon, 3 Mar 2014 01:29:32 +0000 (12:29 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 3 Mar 2014 01:29:32 +0000 (12:29 +1100)
On crc enabled filesystems with obfuscation enabled we need to be
able to recalculate the CRCs on individual buffers.
process_single_fsb_objects() reads a contiguous range of single
block objects as a singel buffer, and hence we cannot correctly
recalculate the CRCs on them.

Split the loop up into individual buffer reads, processing and
writes rather than a single read, multiple block processing and a
single write.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
db/metadump.c

index 5baf83daf422a42e99cb7608f3121effb0e7d502..14902a727305d0bc7f2530cf7320d1672c6ca813 100644 (file)
@@ -1331,29 +1331,27 @@ process_single_fsb_objects(
        int             ret = 0;
        int             i;
 
-       push_cur();
-       set_cur(&typtab[btype], XFS_FSB_TO_DADDR(mp, s), c * blkbb,
-                       DB_RING_IGN, NULL);
+       for (i = 0; i < c; i++) {
+               push_cur();
+               set_cur(&typtab[btype], XFS_FSB_TO_DADDR(mp, s), blkbb,
+                               DB_RING_IGN, NULL);
 
-       if (!iocur_top->data) {
-               xfs_agnumber_t  agno = XFS_FSB_TO_AGNO(mp, s);
-               xfs_agblock_t   agbno = XFS_FSB_TO_AGBNO(mp, s);
+               if (!iocur_top->data) {
+                       xfs_agnumber_t  agno = XFS_FSB_TO_AGNO(mp, s);
+                       xfs_agblock_t   agbno = XFS_FSB_TO_AGBNO(mp, s);
 
-               print_warning("cannot read %s block %u/%u (%llu)",
-                               typtab[btype].name, agno, agbno, s);
-               if (stop_on_read_error)
-                       ret = -EIO;
-               goto out_pop;
+                       print_warning("cannot read %s block %u/%u (%llu)",
+                                       typtab[btype].name, agno, agbno, s);
+                       if (stop_on_read_error)
+                               ret = -EIO;
+                       goto out_pop;
 
-       }
+               }
 
-       if (dont_obfuscate) {
-               ret = write_buf(iocur_top);
-               goto out_pop;
-       }
+               if (dont_obfuscate)
+                       goto write;
 
-       dp = iocur_top->data;
-       for (i = 0; i < c; i++) {
+               dp = iocur_top->data;
                switch (btype) {
                case TYP_DIR2:
                        if (o >= mp->m_dirleafblk)
@@ -1371,13 +1369,17 @@ process_single_fsb_objects(
                default:
                        break;
                }
+
+write:
+               ret = write_buf(iocur_top);
+out_pop:
+               pop_cur();
+               if (ret)
+                       break;
                o++;
-               dp += mp->m_sb.sb_blocksize;
+               s++;
        }
-       ret = write_buf(iocur_top);
 
-out_pop:
-       pop_cur();
        return ret;
 }