]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
libxfs: fix crc field handling in xfs_sb_to/from_disk
authorEric Sandeen <sandeen@redhat.com>
Thu, 19 Jun 2014 02:15:33 +0000 (12:15 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 19 Jun 2014 02:15:33 +0000 (12:15 +1000)
commit75c270a668252b56e8bd194c894b437358e2a6bd
treeafd7b6c3ca94c036c4b9f1bc11ccc478648aec58
parent35f2764a85e182de9eafe183c80660ed5f9d932b
libxfs: fix crc field handling in xfs_sb_to/from_disk

If we xfs_mdrestore an image from a non-crc filesystem, lo
and behold the restored image has gained a CRC:

# db/xfs_metadump.sh -o /dev/sdc1 - | xfs_mdrestore - test.img
# xfs_db -c "sb 0" -c "p crc" /dev/sdc1
crc = 0 (correct)
# xfs_db -c "sb 0" -c "p crc" test.img
crc = 0xb6f8d6a0 (correct)

This is because xfs_sb_from_disk doesn't fill in sb_crc,
but xfs_sb_to_disk(XFS_SB_ALL_BITS) does write the in-memory
CRC to disk - so we get uninitialized memory on disk.

Fix this by always initializing sb_crc to 0 when we read
the superblock, and masking out the CRC bit from ALL_BITS
when we write it.

This same fix has already been sent for kernelspace.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/xfs_sb.c