]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext4: fix trimming of a single group
authorJan Kara <jack@suse.cz>
Mon, 10 Jan 2011 17:30:39 +0000 (12:30 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 17 Feb 2011 23:14:20 +0000 (15:14 -0800)
commit ca6e909f9bebe709bc65a3ee605ce32969db0452 upstream.

When ext4_trim_fs() is called to trim a part of a single group, the
logic will wrongly set last block of the interval to 'len' instead
of 'first_block + len'. Thus a shorter interval is possibly trimmed.
Fix it.

CC: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext4/mballoc.c

index 5b4d4e3a4d58e3506c15e891e7b8df394bc0838f..4c4766c0d52cd3987b0dec9a63c04facc216ab35 100644 (file)
@@ -4851,7 +4851,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
                if (len >= EXT4_BLOCKS_PER_GROUP(sb))
                        len -= (EXT4_BLOCKS_PER_GROUP(sb) - first_block);
                else
-                       last_block = len;
+                       last_block = first_block + len;
 
                if (e4b.bd_info->bb_free >= minlen) {
                        cnt = ext4_trim_all_free(sb, &e4b, first_block,