]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ext3: Adjust trim start with first_data_block.
authorTao Ma <boyu.mt@taobao.com>
Fri, 21 Jan 2011 02:52:56 +0000 (10:52 +0800)
committerJan Kara <jack@suse.cz>
Thu, 24 Feb 2011 10:42:45 +0000 (11:42 +0100)
As we have make the consense in the e-mail[1], the trim start should
be added with first_data_block. So this patch fulfill it and remove
the check for start < first_data_block.

[1] http://www.spinics.net/lists/linux-ext4/msg22737.html

Cc: Jan Kara <jack@suse.cz>
Cc: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/ext3/balloc.c

index 045995c8ce5acd27c51fbebf50ceeaaaf3311b93..5b8344fab79d5f9ec4794faa95b24a9b76ac6639 100644 (file)
@@ -2090,7 +2090,8 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
        ext3_fsblk_t max_blks = le32_to_cpu(es->s_blocks_count);
        int ret = 0;
 
-       start = range->start >> sb->s_blocksize_bits;
+       start = (range->start >> sb->s_blocksize_bits) +
+               le32_to_cpu(es->s_first_data_block);
        len = range->len >> sb->s_blocksize_bits;
        minlen = range->minlen >> sb->s_blocksize_bits;
        trimmed = 0;
@@ -2099,10 +2100,6 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
                return -EINVAL;
        if (start >= max_blks)
                goto out;
-       if (start < le32_to_cpu(es->s_first_data_block)) {
-               len -= le32_to_cpu(es->s_first_data_block) - start;
-               start = le32_to_cpu(es->s_first_data_block);
-       }
        if (start + len > max_blks)
                len = max_blks - start;