mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 11:50:43 +09:00
Revert "f2fs: remove batched discard in f2fs_trim_fs"
This reverts commit c4cc29d19e.
Conflicts:
fs/f2fs/f2fs.h
fs/f2fs/segment.c
fs/f2fs/super.c
This commit is contained in:
@@ -75,6 +75,12 @@ 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,7 +195,12 @@ enum {
|
||||
CP_DISCARD,
|
||||
};
|
||||
|
||||
#define MAX_DISCARD_BLOCKS(sbi) (1 << (sbi)->log_blocks_per_seg)
|
||||
#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 DISCARD_ISSUE_RATE 8
|
||||
#define DEF_CP_INTERVAL 60 /* 60 secs */
|
||||
#define DEF_IDLE_INTERVAL 5 /* 5 secs */
|
||||
@@ -718,6 +723,9 @@ struct f2fs_sm_info {
|
||||
/* a threshold to reclaim prefree segments */
|
||||
unsigned int rec_prefree_segments;
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -965,8 +965,7 @@ 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->len <= MAX_DISCARD_BLOCKS(sbi)) {
|
||||
last->blkaddr + last->len) {
|
||||
last->len += end - start;
|
||||
goto done;
|
||||
}
|
||||
@@ -1706,25 +1705,36 @@ 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));
|
||||
cpc.trim_start = start_segno;
|
||||
cpc.trim_end = end_segno;
|
||||
|
||||
mutex_lock(&sbi->gc_mutex);
|
||||
err = write_checkpoint(sbi, &cpc);
|
||||
mutex_unlock(&sbi->gc_mutex);
|
||||
/* 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;
|
||||
@@ -2885,6 +2895,8 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
|
||||
sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
|
||||
sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
|
||||
|
||||
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)) {
|
||||
|
||||
@@ -287,6 +287,7 @@ 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(DCC_INFO, discard_cmd_control, 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);
|
||||
@@ -311,6 +312,7 @@ 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),
|
||||
|
||||
Reference in New Issue
Block a user