diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2014-10-13 03:36:16 -0400 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2014-11-13 19:02:35 +0100 |
commit | c8137a7d271bc709697ecac2dfc88d6a226f2124 (patch) | |
tree | c0ed42775ef231b4a194f4166ca48e54ae010878 /fs/ext4/ext4.h | |
parent | cc35695f5987ae0f15439882dc66729deb82810d (diff) | |
download | lwn-c8137a7d271bc709697ecac2dfc88d6a226f2124.tar.gz lwn-c8137a7d271bc709697ecac2dfc88d6a226f2124.zip |
ext4: Replace open coded mdata csum feature to helper function
commit 9aa5d32ba269bec0e7eaba2697a986a7b0bc8528 upstream.
Besides the fact that this replacement improves code readability
it also protects from errors caused direct EXT4_S(sb)->s_es manipulation
which may result attempt to use uninitialized csum machinery.
#Testcase_BEGIN
IMG=/dev/ram0
MNT=/mnt
mkfs.ext4 $IMG
mount $IMG $MNT
#Enable feature directly on disk, on mounted fs
tune2fs -O metadata_csum $IMG
# Provoke metadata update, likey result in OOPS
touch $MNT/test
umount $MNT
#Testcase_END
# Replacement script
@@
expression E;
@@
- EXT4_HAS_RO_COMPAT_FEATURE(E, EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)
+ ext4_has_metadata_csum(E)
https://bugzilla.kernel.org/show_bug.cgi?id=82201
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 4eca63f8314a..bd5f351ef10b 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2328,6 +2328,14 @@ static inline int ext4_has_group_desc_csum(struct super_block *sb) EXT4_FEATURE_RO_COMPAT_METADATA_CSUM); } +static inline int ext4_has_metadata_csum(struct super_block *sb) +{ + WARN_ON_ONCE(EXT4_HAS_RO_COMPAT_FEATURE(sb, + EXT4_FEATURE_RO_COMPAT_METADATA_CSUM) && + !EXT4_SB(sb)->s_chksum_driver); + + return (EXT4_SB(sb)->s_chksum_driver != NULL); +} static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es) { return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) | |