diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-06-20 21:27:21 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-07-27 18:03:59 +0900 |
commit | 5a6154920faf9d3d5a39de1da49c66af9831d270 (patch) | |
tree | 7bb43d6d57d81accd2fc7592e45b08cb144e60fd | |
parent | e2374015f27fe5ee5d5c37966e2faf396cdaaa65 (diff) | |
download | linux-stable-5a6154920faf9d3d5a39de1da49c66af9831d270.tar.gz linux-stable-5a6154920faf9d3d5a39de1da49c66af9831d270.tar.bz2 linux-stable-5a6154920faf9d3d5a39de1da49c66af9831d270.zip |
f2fs: don't issue discard commands in online discard is on
Actually, we don't need to issue discard commands, if discard is on, as
mentioned in the comment.
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/segment.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 9efce174c51a..6dc8828b4d87 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2469,23 +2469,24 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) if (err) goto out; - start_block = START_BLOCK(sbi, start_segno); - end_block = START_BLOCK(sbi, end_segno + 1); - - __init_discard_policy(sbi, &dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen); - __issue_discard_cmd_range(sbi, &dpolicy, start_block, end_block); - /* * We filed discard candidates, but actually we don't need to wait for * all of them, since they'll be issued in idle time along with runtime * discard option. User configuration looks like using runtime discard * or periodic fstrim instead of it. */ - if (!test_opt(sbi, DISCARD)) { - trimmed = __wait_discard_cmd_range(sbi, &dpolicy, + if (test_opt(sbi, DISCARD)) + goto out; + + start_block = START_BLOCK(sbi, start_segno); + end_block = START_BLOCK(sbi, end_segno + 1); + + __init_discard_policy(sbi, &dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen); + __issue_discard_cmd_range(sbi, &dpolicy, start_block, end_block); + + trimmed = __wait_discard_cmd_range(sbi, &dpolicy, start_block, end_block); - range->len = F2FS_BLK_TO_BYTES(trimmed); - } + range->len = F2FS_BLK_TO_BYTES(trimmed); out: return err; } |