Skip to content

Commit 4e0197f

Browse files
author
Jaegeuk Kim
committed
f2fs: kill heap-based allocation
No one uses this feature. Let's kill it. Reviewed-by: Daeho Jeong <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 3ae768a commit 4e0197f

File tree

5 files changed

+11
-71
lines changed

5 files changed

+11
-71
lines changed

Documentation/filesystems/f2fs.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ norecovery Disable the roll-forward recovery routine, mounted read-
126126
discard/nodiscard Enable/disable real-time discard in f2fs, if discard is
127127
enabled, f2fs will issue discard/TRIM commands when a
128128
segment is cleaned.
129-
no_heap Disable heap-style segment allocation which finds free
130-
segments for data from the beginning of main area, while
131-
for node from the end of main area.
129+
heap/no_heap Deprecated.
132130
nouser_xattr Disable Extended User Attributes. Note: xattr is enabled
133131
by default if CONFIG_F2FS_FS_XATTR is selected.
134132
noacl Disable POSIX Access Control List. Note: acl is enabled

fs/f2fs/gc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,11 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
280280
p->max_search > sbi->max_victim_search)
281281
p->max_search = sbi->max_victim_search;
282282

283-
/* let's select beginning hot/small space first in no_heap mode*/
283+
/* let's select beginning hot/small space first. */
284284
if (f2fs_need_rand_seg(sbi))
285285
p->offset = get_random_u32_below(MAIN_SECS(sbi) *
286286
SEGS_PER_SEC(sbi));
287-
else if (test_opt(sbi, NOHEAP) &&
288-
(type == CURSEG_HOT_DATA || IS_NODESEG(type)))
287+
else if (type == CURSEG_HOT_DATA || IS_NODESEG(type))
289288
p->offset = 0;
290289
else
291290
p->offset = SIT_I(sbi)->last_victim[p->gc_mode];

fs/f2fs/segment.c

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,16 +2640,14 @@ static int is_next_segment_free(struct f2fs_sb_info *sbi,
26402640
* This function should be returned with success, otherwise BUG
26412641
*/
26422642
static void get_new_segment(struct f2fs_sb_info *sbi,
2643-
unsigned int *newseg, bool new_sec, int dir)
2643+
unsigned int *newseg, bool new_sec)
26442644
{
26452645
struct free_segmap_info *free_i = FREE_I(sbi);
26462646
unsigned int segno, secno, zoneno;
26472647
unsigned int total_zones = MAIN_SECS(sbi) / sbi->secs_per_zone;
26482648
unsigned int hint = GET_SEC_FROM_SEG(sbi, *newseg);
26492649
unsigned int old_zoneno = GET_ZONE_FROM_SEG(sbi, *newseg);
2650-
unsigned int left_start = hint;
26512650
bool init = true;
2652-
int go_left = 0;
26532651
int i;
26542652

26552653
spin_lock(&free_i->segmap_lock);
@@ -2663,30 +2661,10 @@ static void get_new_segment(struct f2fs_sb_info *sbi,
26632661
find_other_zone:
26642662
secno = find_next_zero_bit(free_i->free_secmap, MAIN_SECS(sbi), hint);
26652663
if (secno >= MAIN_SECS(sbi)) {
2666-
if (dir == ALLOC_RIGHT) {
2667-
secno = find_first_zero_bit(free_i->free_secmap,
2664+
secno = find_first_zero_bit(free_i->free_secmap,
26682665
MAIN_SECS(sbi));
2669-
f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi));
2670-
} else {
2671-
go_left = 1;
2672-
left_start = hint - 1;
2673-
}
2674-
}
2675-
if (go_left == 0)
2676-
goto skip_left;
2677-
2678-
while (test_bit(left_start, free_i->free_secmap)) {
2679-
if (left_start > 0) {
2680-
left_start--;
2681-
continue;
2682-
}
2683-
left_start = find_first_zero_bit(free_i->free_secmap,
2684-
MAIN_SECS(sbi));
2685-
f2fs_bug_on(sbi, left_start >= MAIN_SECS(sbi));
2686-
break;
2666+
f2fs_bug_on(sbi, secno >= MAIN_SECS(sbi));
26872667
}
2688-
secno = left_start;
2689-
skip_left:
26902668
segno = GET_SEG_FROM_SEC(sbi, secno);
26912669
zoneno = GET_ZONE_FROM_SEC(sbi, secno);
26922670

@@ -2697,21 +2675,13 @@ static void get_new_segment(struct f2fs_sb_info *sbi,
26972675
goto got_it;
26982676
if (zoneno == old_zoneno)
26992677
goto got_it;
2700-
if (dir == ALLOC_LEFT) {
2701-
if (!go_left && zoneno + 1 >= total_zones)
2702-
goto got_it;
2703-
if (go_left && zoneno == 0)
2704-
goto got_it;
2705-
}
27062678
for (i = 0; i < NR_CURSEG_TYPE; i++)
27072679
if (CURSEG_I(sbi, i)->zone == zoneno)
27082680
break;
27092681

27102682
if (i < NR_CURSEG_TYPE) {
27112683
/* zone is in user, try another */
2712-
if (go_left)
2713-
hint = zoneno * sbi->secs_per_zone - 1;
2714-
else if (zoneno + 1 >= total_zones)
2684+
if (zoneno + 1 >= total_zones)
27152685
hint = 0;
27162686
else
27172687
hint = (zoneno + 1) * sbi->secs_per_zone;
@@ -2769,8 +2739,7 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
27692739
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
27702740
return 0;
27712741

2772-
if (test_opt(sbi, NOHEAP) &&
2773-
(seg_type == CURSEG_HOT_DATA || IS_NODESEG(seg_type)))
2742+
if (seg_type == CURSEG_HOT_DATA || IS_NODESEG(seg_type))
27742743
return 0;
27752744

27762745
if (SIT_I(sbi)->last_victim[ALLOC_NEXT])
@@ -2790,21 +2759,12 @@ static unsigned int __get_next_segno(struct f2fs_sb_info *sbi, int type)
27902759
static void new_curseg(struct f2fs_sb_info *sbi, int type, bool new_sec)
27912760
{
27922761
struct curseg_info *curseg = CURSEG_I(sbi, type);
2793-
unsigned short seg_type = curseg->seg_type;
27942762
unsigned int segno = curseg->segno;
2795-
int dir = ALLOC_LEFT;
27962763

27972764
if (curseg->inited)
2798-
write_sum_page(sbi, curseg->sum_blk,
2799-
GET_SUM_BLOCK(sbi, segno));
2800-
if (seg_type == CURSEG_WARM_DATA || seg_type == CURSEG_COLD_DATA)
2801-
dir = ALLOC_RIGHT;
2802-
2803-
if (test_opt(sbi, NOHEAP))
2804-
dir = ALLOC_RIGHT;
2805-
2765+
write_sum_page(sbi, curseg->sum_blk, GET_SUM_BLOCK(sbi, segno));
28062766
segno = __get_next_segno(sbi, type);
2807-
get_new_segment(sbi, &segno, new_sec, dir);
2767+
get_new_segment(sbi, &segno, new_sec);
28082768
curseg->next_segno = segno;
28092769
reset_curseg(sbi, type, 1);
28102770
curseg->alloc_type = LFS;

fs/f2fs/segment.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,6 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
136136
#define SECTOR_TO_BLOCK(sectors) \
137137
((sectors) >> F2FS_LOG_SECTORS_PER_BLOCK)
138138

139-
/*
140-
* indicate a block allocation direction: RIGHT and LEFT.
141-
* RIGHT means allocating new sections towards the end of volume.
142-
* LEFT means the opposite direction.
143-
*/
144-
enum {
145-
ALLOC_RIGHT = 0,
146-
ALLOC_LEFT
147-
};
148-
149139
/*
150140
* In the victim_sel_policy->alloc_mode, there are three block allocation modes.
151141
* LFS writes data sequentially with cleaning operations.

fs/f2fs/super.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
733733
clear_opt(sbi, DISCARD);
734734
break;
735735
case Opt_noheap:
736-
set_opt(sbi, NOHEAP);
737-
break;
738736
case Opt_heap:
739-
clear_opt(sbi, NOHEAP);
737+
f2fs_warn(sbi, "heap/no_heap options were deprecated");
740738
break;
741739
#ifdef CONFIG_F2FS_FS_XATTR
742740
case Opt_user_xattr:
@@ -1962,10 +1960,6 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
19621960
} else {
19631961
seq_puts(seq, ",nodiscard");
19641962
}
1965-
if (test_opt(sbi, NOHEAP))
1966-
seq_puts(seq, ",no_heap");
1967-
else
1968-
seq_puts(seq, ",heap");
19691963
#ifdef CONFIG_F2FS_FS_XATTR
19701964
if (test_opt(sbi, XATTR_USER))
19711965
seq_puts(seq, ",user_xattr");
@@ -2142,7 +2136,6 @@ static void default_options(struct f2fs_sb_info *sbi, bool remount)
21422136
set_opt(sbi, INLINE_XATTR);
21432137
set_opt(sbi, INLINE_DATA);
21442138
set_opt(sbi, INLINE_DENTRY);
2145-
set_opt(sbi, NOHEAP);
21462139
set_opt(sbi, MERGE_CHECKPOINT);
21472140
F2FS_OPTION(sbi).unusable_cap = 0;
21482141
sbi->sb->s_flags |= SB_LAZYTIME;

0 commit comments

Comments
 (0)