]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_mdrestore: recalculate sb CRC before writing
authorDave Chinner <dchinner@redhat.com>
Fri, 7 Jun 2013 00:26:04 +0000 (10:26 +1000)
committerBen Myers <bpm@sgi.com>
Tue, 6 Aug 2013 20:57:35 +0000 (15:57 -0500)
xfs_mdrestore writes the superblock after modifying it, and so the
CRC is not necessarily correct.  Make sure the CRC is correct
before we write the superblock back.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
mdrestore/xfs_mdrestore.c

index 479e677db16f3d04fe53d3ccce86a3efa57b1493..e57bdb2100534aafda2cdd0c13ca5af7095f7a15 100644 (file)
@@ -169,6 +169,11 @@ perform_restore(
        memset(block_buffer, 0, sb.sb_sectsize);
        sb.sb_inprogress = 0;
        libxfs_sb_to_disk((xfs_dsb_t *)block_buffer, &sb, XFS_SB_ALL_BITS);
+       if (xfs_sb_version_hascrc(&sb)) {
+               xfs_update_cksum(block_buffer, sb.sb_sectsize,
+                                offsetof(struct xfs_sb, sb_crc));
+       }
+
        if (pwrite(dst_fd, block_buffer, sb.sb_sectsize, 0) < 0)
                fatal("error writing primary superblock: %s\n", strerror(errno));