diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/mballoc.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index cc1297e15f1b..851f49b2f9d2 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -4808,6 +4808,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) | |||
4808 | ext4_group_t group, ngroups = ext4_get_groups_count(sb); | 4808 | ext4_group_t group, ngroups = ext4_get_groups_count(sb); |
4809 | ext4_grpblk_t cnt = 0, first_block, last_block; | 4809 | ext4_grpblk_t cnt = 0, first_block, last_block; |
4810 | uint64_t start, len, minlen, trimmed; | 4810 | uint64_t start, len, minlen, trimmed; |
4811 | ext4_fsblk_t first_data_blk = | ||
4812 | le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); | ||
4811 | int ret = 0; | 4813 | int ret = 0; |
4812 | 4814 | ||
4813 | start = range->start >> sb->s_blocksize_bits; | 4815 | start = range->start >> sb->s_blocksize_bits; |
@@ -4817,6 +4819,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) | |||
4817 | 4819 | ||
4818 | if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb))) | 4820 | if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb))) |
4819 | return -EINVAL; | 4821 | return -EINVAL; |
4822 | if (start < first_data_blk) { | ||
4823 | len -= first_data_blk - start; | ||
4824 | start = first_data_blk; | ||
4825 | } | ||
4820 | 4826 | ||
4821 | /* Determine first and last group to examine based on start and len */ | 4827 | /* Determine first and last group to examine based on start and len */ |
4822 | ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start, | 4828 | ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start, |