Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: record the checksum algorithm in use in the superblock

Record the type of checksum algorithm we're using for metadata in the
superblock, in case we ever want/need to change the algorithm.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

authored by

Darrick J. Wong and committed by
Theodore Ts'o
d25425f8 e6153918

+18
+18
fs/ext4/super.c
··· 112 112 #define IS_EXT3_SB(sb) (0) 113 113 #endif 114 114 115 + static int ext4_verify_csum_type(struct super_block *sb, 116 + struct ext4_super_block *es) 117 + { 118 + if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 119 + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) 120 + return 1; 121 + 122 + return es->s_checksum_type == EXT4_CRC32C_CHKSUM; 123 + } 124 + 115 125 void *ext4_kvmalloc(size_t size, gfp_t flags) 116 126 { 117 127 void *ret; ··· 3034 3024 if (sb->s_magic != EXT4_SUPER_MAGIC) 3035 3025 goto cantfind_ext4; 3036 3026 sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written); 3027 + 3028 + /* Check for a known checksum algorithm */ 3029 + if (!ext4_verify_csum_type(sb, es)) { 3030 + ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with " 3031 + "unknown checksum algorithm."); 3032 + silent = 1; 3033 + goto cantfind_ext4; 3034 + } 3037 3035 3038 3036 /* Set defaults before we parse the mount options */ 3039 3037 def_mount_opts = le32_to_cpu(es->s_default_mount_opts);