xfs
[Top] [All Lists]

[PATCH 41/48] xfs_mdrestore: recalculate sb CRC before writing

To: xfs@xxxxxxxxxxx
Subject: [PATCH 41/48] xfs_mdrestore: recalculate sb CRC before writing
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 7 Jun 2013 10:26:04 +1000
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1370564771-4929-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1370564771-4929-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 mdrestore/xfs_mdrestore.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index 479e677..e57bdb2 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -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));
 
-- 
1.7.10.4

<Prev in Thread] Current Thread [Next in Thread>