f2fs: avoid mismatching block range for discard
authorYunlei He <heyunlei@huawei.com>
Thu, 7 Jul 2016 04:13:33 +0000 (12:13 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Fri, 8 Jul 2016 17:33:33 +0000 (10:33 -0700)
This patch skip discard block range smaller than trim_minlen,
and can not be merged by neighbour

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index 6d16ecf..9e13db0 100644 (file)
@@ -672,6 +672,10 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                        break;
 
                end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1);
+               if (force && start && end != max_blocks
+                                       && (end - start) < cpc->trim_minlen)
+                       continue;
+
                __add_discard_entry(sbi, cpc, se, start, end);
        }
 }