Re: [f2fs-dev] [PATCH v2] f2fs: kill heap-based allocation
On 2024/2/21 9:57, Jaegeuk Kim wrote: On 02/21, Chao Yu wrote: On 2024/2/21 4:51, Jaegeuk Kim wrote: No one uses this feature. Let's kill it. Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- Change log from v1: - keep mount options but give warnings instead Documentation/filesystems/f2fs.rst | 4 +-- fs/f2fs/gc.c | 5 ++- fs/f2fs/segment.c | 54 -- fs/f2fs/segment.h | 10 -- fs/f2fs/super.c| 9 + 5 files changed, 11 insertions(+), 71 deletions(-) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 9ac5083dae8e..c30a800604fd 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read- discard/nodiscard Enable/disable real-time discard in f2fs, if discard is enabled, f2fs will issue discard/TRIM commands when a segment is cleaned. -no_heap Disable heap-style segment allocation which finds free -segments for data from the beginning of main area, while -for node from the end of main area. +no_heap Deprecated. heap/no_heapDeprecated Otherwise, it looks good to me. Reviewed-by: Chao Yu BTW, do we need to kill heap-based allocation in mkfs.f2fs as well? I was about to work on it after kernel change tho. Can you write one? :) No problem. Thanks, Thanks, nouser_xattr Disable Extended User Attributes. Note: xattr is enabled by default if CONFIG_F2FS_FS_XATTR is selected. noacl Disable POSIX Access Control List. Note: acl is enabled diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 501b93b45b6c..a089a938355b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, p->max_search > sbi->max_victim_search) p->max_search = sbi->max_victim_search; - /* let's select beginning hot/small space first in no_heap mode*/ + /* let's select beginning hot/small space first. */ if (f2fs_need_rand_seg(sbi)) p->offset = get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); - else if (test_opt(sbi, NOHEAP) && - (type == CURSEG_HOT_DATA || IS_NODESEG(type))) + else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) p->offset = 0; else p->offset = SIT_I(sbi)->last_victim[p->gc_mode]; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 94c4f7b16c19..09af17af4e7a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2634,16 +2634,14 @@ static int is_next_segment_free(struct f2fs_sb_info *sbi, * This function should be returned with success, otherwise BUG */ static void get_new_segment(struct f2fs_sb_info *sbi, - unsigned int *newseg, bool new_sec, int dir) + unsigned int *newseg, bool new_sec) { struct free_segmap_info *free_i = FREE_I(sbi); unsigned int segno, secno, zoneno; unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone; unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); - unsigned int left_start = hint; bool init = true; - int go_left = 0; int i; spin_lock(_i->segmap_lock); @@ -2657,30 +2655,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, find_other_zone: secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { - if (dir == ALLOC_RIGHT) { - secno = find_first_zero_bit(free_i->free_secmap, + secno = find_first_zero_bit(free_i->free_secmap, MAIN_SECS(sbi)); - f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); - } else { - go_left = 1; - left_start = hint - 1; - } - } - if (go_left == 0) - goto skip_left; - - while (test_bit(left_start, free_i->free_secmap)) { - if (left_start > 0) { - left_start--; - continue; - } - left_start = find_first_zero_bit(free_i->free_secmap, - MAIN_SECS(sbi)); - f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi)); - break; + f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } - secno =
Re: [f2fs-dev] [PATCH v2] f2fs: kill heap-based allocation
On 02/21, Chao Yu wrote: > On 2024/2/21 4:51, Jaegeuk Kim wrote: > > No one uses this feature. Let's kill it. > > > > Reviewed-by: Daeho Jeong > > Signed-off-by: Jaegeuk Kim > > --- > > > > Change log from v1: > >- keep mount options but give warnings instead > > > > Documentation/filesystems/f2fs.rst | 4 +-- > > fs/f2fs/gc.c | 5 ++- > > fs/f2fs/segment.c | 54 -- > > fs/f2fs/segment.h | 10 -- > > fs/f2fs/super.c| 9 + > > 5 files changed, 11 insertions(+), 71 deletions(-) > > > > diff --git a/Documentation/filesystems/f2fs.rst > > b/Documentation/filesystems/f2fs.rst > > index 9ac5083dae8e..c30a800604fd 100644 > > --- a/Documentation/filesystems/f2fs.rst > > +++ b/Documentation/filesystems/f2fs.rst > > @@ -126,9 +126,7 @@ norecovery Disable the roll-forward > > recovery routine, mounted read- > > discard/nodiscard Enable/disable real-time discard in f2fs, if discard is > > enabled, f2fs will issue discard/TRIM commands when a > > segment is cleaned. > > -no_heap Disable heap-style segment allocation which > > finds free > > -segments for data from the beginning of main area, > > while > > -for node from the end of main area. > > +no_heap Deprecated. > > heap/no_heap Deprecated > > Otherwise, it looks good to me. > > Reviewed-by: Chao Yu > > BTW, do we need to kill heap-based allocation in mkfs.f2fs as well? I was about to work on it after kernel change tho. Can you write one? :) > > Thanks, > > > nouser_xattr Disable Extended User Attributes. Note: xattr > > is enabled > > by default if CONFIG_F2FS_FS_XATTR is selected. > > noacl Disable POSIX Access Control List. Note: acl > > is enabled > > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c > > index 501b93b45b6c..a089a938355b 100644 > > --- a/fs/f2fs/gc.c > > +++ b/fs/f2fs/gc.c > > @@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, > > int gc_type, > > p->max_search > sbi->max_victim_search) > > p->max_search = sbi->max_victim_search; > > - /* let's select beginning hot/small space first in no_heap mode*/ > > + /* let's select beginning hot/small space first. */ > > if (f2fs_need_rand_seg(sbi)) > > p->offset = get_random_u32_below(MAIN_SECS(sbi) * > > SEGS_PER_SEC(sbi)); > > - else if (test_opt(sbi, NOHEAP) && > > - (type == CURSEG_HOT_DATA || IS_NODESEG(type))) > > + else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) > > p->offset = 0; > > else > > p->offset = SIT_I(sbi)->last_victim[p->gc_mode]; > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > > index 94c4f7b16c19..09af17af4e7a 100644 > > --- a/fs/f2fs/segment.c > > +++ b/fs/f2fs/segment.c > > @@ -2634,16 +2634,14 @@ static int is_next_segment_free(struct f2fs_sb_info > > *sbi, > >* This function should be returned with success, otherwise BUG > >*/ > > static void get_new_segment(struct f2fs_sb_info *sbi, > > - unsigned int *newseg, bool new_sec, int dir) > > + unsigned int *newseg, bool new_sec) > > { > > struct free_segmap_info *free_i = FREE_I(sbi); > > unsigned int segno, secno, zoneno; > > unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone; > > unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); > > unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); > > - unsigned int left_start = hint; > > bool init = true; > > - int go_left = 0; > > int i; > > spin_lock(_i->segmap_lock); > > @@ -2657,30 +2655,10 @@ static void get_new_segment(struct f2fs_sb_info > > *sbi, > > find_other_zone: > > secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); > > if (secno >= MAIN_SECS(sbi)) { > > - if (dir == ALLOC_RIGHT) { > > - secno = find_first_zero_bit(free_i->free_secmap, > > + secno = find_first_zero_bit(free_i->free_secmap, > > MAIN_SECS(sbi)); > > - f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); > > - } else { > > - go_left = 1; > > - left_start = hint - 1; > > - } > > - } > > - if (go_left == 0) > > - goto skip_left; > > - > > - while (test_bit(left_start, free_i->free_secmap)) { > > - if (left_start > 0) { > > - left_start--; > > - continue; > > - } > > - left_start = find_first_zero_bit(free_i->free_secmap, > > - MAIN_SECS(sbi)); > > - f2fs_bug_on(sbi,
Re: [f2fs-dev] [PATCH v2] f2fs: kill heap-based allocation
On 2024/2/21 4:51, Jaegeuk Kim wrote: No one uses this feature. Let's kill it. Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- Change log from v1: - keep mount options but give warnings instead Documentation/filesystems/f2fs.rst | 4 +-- fs/f2fs/gc.c | 5 ++- fs/f2fs/segment.c | 54 -- fs/f2fs/segment.h | 10 -- fs/f2fs/super.c| 9 + 5 files changed, 11 insertions(+), 71 deletions(-) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 9ac5083dae8e..c30a800604fd 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read- discard/nodiscard Enable/disable real-time discard in f2fs, if discard is enabled, f2fs will issue discard/TRIM commands when a segment is cleaned. -no_heap Disable heap-style segment allocation which finds free -segments for data from the beginning of main area, while -for node from the end of main area. +no_heap Deprecated. heap/no_heapDeprecated Otherwise, it looks good to me. Reviewed-by: Chao Yu BTW, do we need to kill heap-based allocation in mkfs.f2fs as well? Thanks, nouser_xattr Disable Extended User Attributes. Note: xattr is enabled by default if CONFIG_F2FS_FS_XATTR is selected. noacl Disable POSIX Access Control List. Note: acl is enabled diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 501b93b45b6c..a089a938355b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, p->max_search > sbi->max_victim_search) p->max_search = sbi->max_victim_search; - /* let's select beginning hot/small space first in no_heap mode*/ + /* let's select beginning hot/small space first. */ if (f2fs_need_rand_seg(sbi)) p->offset = get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); - else if (test_opt(sbi, NOHEAP) && - (type == CURSEG_HOT_DATA || IS_NODESEG(type))) + else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) p->offset = 0; else p->offset = SIT_I(sbi)->last_victim[p->gc_mode]; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 94c4f7b16c19..09af17af4e7a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2634,16 +2634,14 @@ static int is_next_segment_free(struct f2fs_sb_info *sbi, * This function should be returned with success, otherwise BUG */ static void get_new_segment(struct f2fs_sb_info *sbi, - unsigned int *newseg, bool new_sec, int dir) + unsigned int *newseg, bool new_sec) { struct free_segmap_info *free_i = FREE_I(sbi); unsigned int segno, secno, zoneno; unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone; unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); - unsigned int left_start = hint; bool init = true; - int go_left = 0; int i; spin_lock(_i->segmap_lock); @@ -2657,30 +2655,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, find_other_zone: secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { - if (dir == ALLOC_RIGHT) { - secno = find_first_zero_bit(free_i->free_secmap, + secno = find_first_zero_bit(free_i->free_secmap, MAIN_SECS(sbi)); - f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); - } else { - go_left = 1; - left_start = hint - 1; - } - } - if (go_left == 0) - goto skip_left; - - while (test_bit(left_start, free_i->free_secmap)) { - if (left_start > 0) { - left_start--; - continue; - } - left_start = find_first_zero_bit(free_i->free_secmap, - MAIN_SECS(sbi)); - f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi)); - break; + f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } - secno = left_start; -skip_left: segno = GET_SEG_FROM_SEC(sbi, secno); zoneno = GET_ZONE_FROM_SEC(sbi, secno); @@ -2691,21 +2669,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi,
Re: [f2fs-dev] [PATCH v2] f2fs: kill heap-based allocation
No one uses this feature. Let's kill it. Reviewed-by: Daeho Jeong Signed-off-by: Jaegeuk Kim --- Change log from v1: - keep mount options but give warnings instead Documentation/filesystems/f2fs.rst | 4 +-- fs/f2fs/gc.c | 5 ++- fs/f2fs/segment.c | 54 -- fs/f2fs/segment.h | 10 -- fs/f2fs/super.c| 9 + 5 files changed, 11 insertions(+), 71 deletions(-) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 9ac5083dae8e..c30a800604fd 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read- discard/nodiscard Enable/disable real-time discard in f2fs, if discard is enabled, f2fs will issue discard/TRIM commands when a segment is cleaned. -no_heap Disable heap-style segment allocation which finds free -segments for data from the beginning of main area, while -for node from the end of main area. +no_heap Deprecated. nouser_xattrDisable Extended User Attributes. Note: xattr is enabled by default if CONFIG_F2FS_FS_XATTR is selected. noacl Disable POSIX Access Control List. Note: acl is enabled diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 501b93b45b6c..a089a938355b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type, p->max_search > sbi->max_victim_search) p->max_search = sbi->max_victim_search; - /* let's select beginning hot/small space first in no_heap mode*/ + /* let's select beginning hot/small space first. */ if (f2fs_need_rand_seg(sbi)) p->offset = get_random_u32_below(MAIN_SECS(sbi) * SEGS_PER_SEC(sbi)); - else if (test_opt(sbi, NOHEAP) && - (type == CURSEG_HOT_DATA || IS_NODESEG(type))) + else if (type == CURSEG_HOT_DATA || IS_NODESEG(type)) p->offset = 0; else p->offset = SIT_I(sbi)->last_victim[p->gc_mode]; diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 94c4f7b16c19..09af17af4e7a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2634,16 +2634,14 @@ static int is_next_segment_free(struct f2fs_sb_info *sbi, * This function should be returned with success, otherwise BUG */ static void get_new_segment(struct f2fs_sb_info *sbi, - unsigned int *newseg, bool new_sec, int dir) + unsigned int *newseg, bool new_sec) { struct free_segmap_info *free_i = FREE_I(sbi); unsigned int segno, secno, zoneno; unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone; unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg); unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg); - unsigned int left_start = hint; bool init = true; - int go_left = 0; int i; spin_lock(_i->segmap_lock); @@ -2657,30 +2655,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi, find_other_zone: secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint); if (secno >= MAIN_SECS(sbi)) { - if (dir == ALLOC_RIGHT) { - secno = find_first_zero_bit(free_i->free_secmap, + secno = find_first_zero_bit(free_i->free_secmap, MAIN_SECS(sbi)); - f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); - } else { - go_left = 1; - left_start = hint - 1; - } - } - if (go_left == 0) - goto skip_left; - - while (test_bit(left_start, free_i->free_secmap)) { - if (left_start > 0) { - left_start--; - continue; - } - left_start = find_first_zero_bit(free_i->free_secmap, - MAIN_SECS(sbi)); - f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi)); - break; + f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi)); } - secno = left_start; -skip_left: segno = GET_SEG_FROM_SEC(sbi, secno); zoneno = GET_ZONE_FROM_SEC(sbi, secno); @@ -2691,21 +2669,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi, goto got_it; if (zoneno == old_zoneno) goto got_it; - if (dir == ALLOC_LEFT) { - if (!go_left && zoneno + 1 >= total_zones) - goto got_it; -