]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_copy: fix up initial sb buffer read on CRC fs
authorEric Sandeen <sandeen@sandeen.net>
Mon, 3 Aug 2015 00:47:02 +0000 (10:47 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 3 Aug 2015 00:47:02 +0000 (10:47 +1000)
My prior commit, aaf90a2 xfs_copy: fix copy of hard 4k devices
causes xfs_copy to emit a CRC error warning when copying a
CRC filesystem.

This is because we are now reading the maximum sector size,
and attempting to verify the CRC based on that (likely incorrect)
length.

In xfs_db, we currently just don't verify this read, so it's
not a problem.  In xfs_copy, we almost certainly want to verify.

So, first do the maximal read with no verifier; once it's read,
drop that buffer, and re-read with the proper sector size and
verifier.

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

index 2f9e4431f564f2f6a0b605f09316b859a04ea479..20d4120dc98b016bb148954465d7b2f4b5c18ff0 100644 (file)
@@ -681,15 +681,22 @@ main(int argc, char **argv)
                exit(1);
        }
 
-       /* prepare the mount structure */
-
        memset(&mbuf, 0, sizeof(xfs_mount_t));
+
+       /* We don't yet know the sector size, so read maximal size */
        libxfs_buftarg_init(&mbuf, xargs.ddev, xargs.logdev, xargs.rtdev);
-       sbp = libxfs_readbuf(mbuf.m_ddev_targp, XFS_SB_DADDR, 1, 0,
-                                                       &xfs_sb_buf_ops);
+       sbp = libxfs_readbuf(mbuf.m_ddev_targp, XFS_SB_DADDR,
+                            1 << (XFS_MAX_SECTORSIZE_LOG - BBSHIFT), 0, NULL);
        sb = &mbuf.m_sb;
        libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbp));
 
+       /* Do it again, now with proper length and verifier */
+       libxfs_putbuf(sbp);
+       libxfs_purgebuf(sbp);
+       sbp = libxfs_readbuf(mbuf.m_ddev_targp, XFS_SB_DADDR,
+                            1 << (sb->sb_sectlog - BBSHIFT),
+                            0, &xfs_sb_buf_ops);
+
        mp = libxfs_mount(&mbuf, sb, xargs.ddev, xargs.logdev, xargs.rtdev, 0);
        if (mp == NULL) {
                do_log(_("%s: %s filesystem failed to initialize\n"