f2fs: remove batched discard in f2fs_trim_fs
We don't need to do multiple checkpoints, since we don't actually wait for completion of discard commands during checkpoint. Instead, we still need to avoid very big discard commands, since that large discard can interfere block allocation. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
4844bb76e7
commit
c4cc29d19e
4 changed files with 14 additions and 41 deletions
|
@ -75,12 +75,6 @@ Contact: "Jaegeuk Kim" <jaegeuk.kim@samsung.com>
|
|||
Description:
|
||||
Controls the memory footprint used by f2fs.
|
||||
|
||||
What: /sys/fs/f2fs/<disk>/trim_sections
|
||||
Date: February 2015
|
||||
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
|
||||
Description:
|
||||
Controls the trimming rate in batch mode.
|
||||
|
||||
What: /sys/fs/f2fs/<disk>/cp_interval
|
||||
Date: October 2015
|
||||
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
|
||||
|
|
|
@ -195,11 +195,7 @@ enum {
|
|||
CP_DISCARD,
|
||||
};
|
||||
|
||||
#define DEF_BATCHED_TRIM_SECTIONS 2
|
||||
#define BATCHED_TRIM_SEGMENTS(sbi) \
|
||||
(SM_I(sbi)->trim_sections * (sbi)->segs_per_sec)
|
||||
#define BATCHED_TRIM_BLOCKS(sbi) \
|
||||
(BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg)
|
||||
#define MAX_DISCARD_BLOCKS(sbi) (1 << (sbi)->log_blocks_per_seg)
|
||||
#define DEF_CP_INTERVAL 60 /* 60 secs */
|
||||
#define DEF_IDLE_INTERVAL 5 /* 5 secs */
|
||||
|
||||
|
@ -705,9 +701,6 @@ struct f2fs_sm_info {
|
|||
int nr_discards; /* # of discards in the list */
|
||||
int max_discards; /* max. discards to be issued */
|
||||
|
||||
/* for batched trimming */
|
||||
unsigned int trim_sections; /* # of sections to trim */
|
||||
|
||||
struct list_head sit_entry_set; /* sit entry set list */
|
||||
|
||||
unsigned int ipu_policy; /* in-place-update policy */
|
||||
|
|
|
@ -903,7 +903,8 @@ static void __add_discard_entry(struct f2fs_sb_info *sbi,
|
|||
if (!list_empty(head)) {
|
||||
last = list_last_entry(head, struct discard_entry, list);
|
||||
if (START_BLOCK(sbi, cpc->trim_start) + start ==
|
||||
last->blkaddr + last->len) {
|
||||
last->blkaddr + last->len &&
|
||||
last->len <= MAX_DISCARD_BLOCKS(sbi)) {
|
||||
last->len += end - start;
|
||||
goto done;
|
||||
}
|
||||
|
@ -1593,36 +1594,25 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
|
|||
"Found FS corruption, run fsck to fix.");
|
||||
goto out;
|
||||
}
|
||||
if (sbi->discard_blks == 0)
|
||||
goto out;
|
||||
|
||||
/* start/end segment number in main_area */
|
||||
start_segno = (start <= MAIN_BLKADDR(sbi)) ? 0 : GET_SEGNO(sbi, start);
|
||||
end_segno = (end >= MAX_BLKADDR(sbi)) ? MAIN_SEGS(sbi) - 1 :
|
||||
GET_SEGNO(sbi, end);
|
||||
/*
|
||||
* do checkpoint to issue discard commands safely since we now can
|
||||
* use async discard.
|
||||
*/
|
||||
cpc.reason = CP_DISCARD;
|
||||
cpc.trim_minlen = max_t(__u64, 1, F2FS_BYTES_TO_BLK(range->minlen));
|
||||
|
||||
/* do checkpoint to issue discard commands safely */
|
||||
for (; start_segno <= end_segno; start_segno = cpc.trim_end + 1) {
|
||||
cpc.trim_start = start_segno;
|
||||
|
||||
if (sbi->discard_blks == 0)
|
||||
break;
|
||||
else if (sbi->discard_blks < BATCHED_TRIM_BLOCKS(sbi))
|
||||
cpc.trim_end = end_segno;
|
||||
else
|
||||
cpc.trim_end = min_t(unsigned int,
|
||||
rounddown(start_segno +
|
||||
BATCHED_TRIM_SEGMENTS(sbi),
|
||||
sbi->segs_per_sec) - 1, end_segno);
|
||||
|
||||
mutex_lock(&sbi->gc_mutex);
|
||||
err = write_checkpoint(sbi, &cpc);
|
||||
mutex_unlock(&sbi->gc_mutex);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
schedule();
|
||||
}
|
||||
out:
|
||||
range->len = F2FS_BLK_TO_BYTES(cpc.trimmed);
|
||||
return err;
|
||||
|
@ -2788,8 +2778,6 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
|
|||
sm_info->nr_discards = 0;
|
||||
sm_info->max_discards = 0;
|
||||
|
||||
sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;
|
||||
|
||||
INIT_LIST_HEAD(&sm_info->sit_entry_set);
|
||||
|
||||
if (test_opt(sbi, FLUSH_MERGE) && !f2fs_readonly(sbi->sb)) {
|
||||
|
|
|
@ -284,7 +284,6 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
|
|||
F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
|
||||
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);
|
||||
|
@ -309,7 +308,6 @@ static struct attribute *f2fs_attrs[] = {
|
|||
ATTR_LIST(gc_idle),
|
||||
ATTR_LIST(reclaim_segments),
|
||||
ATTR_LIST(max_small_discards),
|
||||
ATTR_LIST(batched_trim_sections),
|
||||
ATTR_LIST(ipu_policy),
|
||||
ATTR_LIST(min_ipu_util),
|
||||
ATTR_LIST(min_fsync_blocks),
|
||||
|
|
Loading…
Add table
Reference in a new issue