linux: add patch for failed fstrim command

Signed-off-by: Stephan Raue <stephan@openelec.tv>
This commit is contained in:
Stephan Raue 2011-01-11 16:46:22 +01:00
parent e4e018c8cf
commit b98bf57ee4

View File

@ -0,0 +1,23 @@
diff -Naur linux-2.6.37/fs/ext4/mballoc.c linux-2.6.37.patch/fs/ext4/mballoc.c
--- linux-2.6.37/fs/ext4/mballoc.c 2011-01-05 01:50:19.000000000 +0100
+++ linux-2.6.37.patch/fs/ext4/mballoc.c 2011-01-11 16:40:40.592434028 +0100
@@ -4819,6 +4819,8 @@
ext4_group_t group, ngroups = ext4_get_groups_count(sb);
ext4_grpblk_t cnt = 0, first_block, last_block;
uint64_t start, len, minlen, trimmed;
+ ext4_fsblk_t first_data_blk =
+ le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
int ret = 0;
start = range->start >> sb->s_blocksize_bits;
@@ -4828,6 +4830,10 @@
if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb)))
return -EINVAL;
+ if (start < first_data_blk) {
+ len -= first_data_blk - start;
+ start = first_data_blk;
+ }
/* Determine first and last group to examine based on start and len */
ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start,