diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2014-10-14 02:35:49 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-10-14 02:35:49 -0400 |
commit | 813d32f91333e4c33d5a19b67167c4bae42dae75 (patch) | |
tree | 09e1183d369c6b42a6fc3edcb73017ff54aa8a36 /fs/ext4/super.c | |
parent | aef4885ae14f1df75b58395c5314d71f613d26d9 (diff) | |
download | linux-813d32f91333e4c33d5a19b67167c4bae42dae75.tar.bz2 |
ext4: check s_chksum_driver when looking for bg csum presence
Convert the ext4_has_group_desc_csum predicate to look for a checksum
driver instead of the metadata_csum flag and change the bg checksum
calculation function to look for GDT_CSUM before taking the crc16
path.
Without this patch, if we mount with ^uninit_bg,^metadata_csum and
later metadata_csum gets turned on by accident, the block group
checksum functions will incorrectly assume that checksumming is
enabled (metadata_csum) but that crc16 should be used
(!s_chksum_driver). This is totally wrong, so fix the predicate
and the checksum formula selection.
(Granted, if the metadata_csum feature bit gets enabled on a live FS
then something underhanded is going on, but we could at least avoid
writing garbage into the on-disk fields.)
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 5afe42db303c..e96b6ecc8d34 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2005,6 +2005,10 @@ static __le16 ext4_group_desc_csum(struct ext4_sb_info *sbi, __u32 block_group, } /* old crc16 code */ + if (!(sbi->s_es->s_feature_ro_compat & + cpu_to_le32(EXT4_FEATURE_RO_COMPAT_GDT_CSUM))) + return 0; + offset = offsetof(struct ext4_group_desc, bg_checksum); crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid)); |