Skip to content

Commit

Permalink
f2fs: don't issue discard commands in online discard is on
Browse files Browse the repository at this point in the history
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>
Signed-off-by: khusika <khusikadhamar@gmail.com>
  • Loading branch information
Jaegeuk Kim authored and khusika committed Oct 13, 2018
1 parent 692fa51 commit 25a740e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -2550,23 +2550,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;
}
Expand Down

0 comments on commit 25a740e

Please sign in to comment.