Commit 81e8c3c5 authored by Petr Malat's avatar Petr Malat Committed by Theodore Ts'o

ext4: do not interpret high bytes if 64bit feature is disabled

Fields s_free_blocks_count_hi, s_r_blocks_count_hi and s_blocks_count_hi
are not valid if EXT4_FEATURE_INCOMPAT_64BIT is not enabled and should be
treated as zeroes.
Signed-off-by: default avatarPetr Malat <oss@malat.biz>
Link: https://lore.kernel.org/r/20200825150016.3363-1-oss@malat.bizSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent b483bb77
...@@ -3012,22 +3012,24 @@ static inline int ext4_has_group_desc_csum(struct super_block *sb) ...@@ -3012,22 +3012,24 @@ static inline int ext4_has_group_desc_csum(struct super_block *sb)
return ext4_has_feature_gdt_csum(sb) || ext4_has_metadata_csum(sb); return ext4_has_feature_gdt_csum(sb) || ext4_has_metadata_csum(sb);
} }
#define ext4_read_incompat_64bit_val(es, name) \
(((es)->s_feature_incompat & cpu_to_le32(EXT4_FEATURE_INCOMPAT_64BIT) \
? (ext4_fsblk_t)le32_to_cpu(es->name##_hi) << 32 : 0) | \
le32_to_cpu(es->name##_lo))
static inline ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es) 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) | return ext4_read_incompat_64bit_val(es, s_blocks_count);
le32_to_cpu(es->s_blocks_count_lo);
} }
static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es) static inline ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
{ {
return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) | return ext4_read_incompat_64bit_val(es, s_r_blocks_count);
le32_to_cpu(es->s_r_blocks_count_lo);
} }
static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es) static inline ext4_fsblk_t ext4_free_blocks_count(struct ext4_super_block *es)
{ {
return ((ext4_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) | return ext4_read_incompat_64bit_val(es, s_free_blocks_count);
le32_to_cpu(es->s_free_blocks_count_lo);
} }
static inline void ext4_blocks_count_set(struct ext4_super_block *es, static inline void ext4_blocks_count_set(struct ext4_super_block *es,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment