Skip to content

Commit 19e0e21

Browse files
bbkzzJaegeuk Kim
authored andcommitted
f2fs: remove struct victim_selection default_v_ops
There is only single instance of these ops, and Jaegeuk point out that: Originally this was intended to give a chance to provide other allocation option. Anyway, it seems quit hard to do it anymore. So remove the indirection and call f2fs_get_victim() directly. Signed-off-by: Yangtao Li <frank.li@vivo.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent da6ea0b commit 19e0e21

4 files changed

Lines changed: 10 additions & 21 deletions

File tree

fs/f2fs/f2fs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,10 @@ void f2fs_build_gc_manager(struct f2fs_sb_info *sbi);
38153815
int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count);
38163816
int __init f2fs_create_garbage_collection_cache(void);
38173817
void f2fs_destroy_garbage_collection_cache(void);
3818+
/* victim selection function for cleaning and SSR */
3819+
int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
3820+
int gc_type, int type, char alloc_mode,
3821+
unsigned long long age);
38183822

38193823
/*
38203824
* recovery.c

fs/f2fs/gc.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,9 @@ static int f2fs_gc_pinned_control(struct inode *inode, int gc_type,
741741
* When it is called from SSR segment selection, it finds a segment
742742
* which has minimum valid blocks and removes it from dirty seglist.
743743
*/
744-
static int get_victim_by_default(struct f2fs_sb_info *sbi,
745-
unsigned int *result, int gc_type, int type,
746-
char alloc_mode, unsigned long long age)
744+
int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result,
745+
int gc_type, int type, char alloc_mode,
746+
unsigned long long age)
747747
{
748748
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
749749
struct sit_info *sm = SIT_I(sbi);
@@ -937,10 +937,6 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
937937
return ret;
938938
}
939939

940-
static const struct victim_selection default_v_ops = {
941-
.get_victim = get_victim_by_default,
942-
};
943-
944940
static struct inode *find_gc_inode(struct gc_inode_list *gc_list, nid_t ino)
945941
{
946942
struct inode_entry *ie;
@@ -1671,8 +1667,7 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim,
16711667
int ret;
16721668

16731669
down_write(&sit_i->sentry_lock);
1674-
ret = DIRTY_I(sbi)->v_ops->get_victim(sbi, victim, gc_type,
1675-
NO_CHECK_TYPE, LFS, 0);
1670+
ret = f2fs_get_victim(sbi, victim, gc_type, NO_CHECK_TYPE, LFS, 0);
16761671
up_write(&sit_i->sentry_lock);
16771672
return ret;
16781673
}
@@ -1963,8 +1958,6 @@ static void init_atgc_management(struct f2fs_sb_info *sbi)
19631958

19641959
void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)
19651960
{
1966-
DIRTY_I(sbi)->v_ops = &default_v_ops;
1967-
19681961
sbi->gc_pin_file_threshold = DEF_GC_FAILED_PINNED_FILES;
19691962

19701963
/* give warm/cold data area from slower device */

fs/f2fs/segment.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,7 +2875,6 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type,
28752875
int alloc_mode, unsigned long long age)
28762876
{
28772877
struct curseg_info *curseg = CURSEG_I(sbi, type);
2878-
const struct victim_selection *v_ops = DIRTY_I(sbi)->v_ops;
28792878
unsigned segno = NULL_SEGNO;
28802879
unsigned short seg_type = curseg->seg_type;
28812880
int i, cnt;
@@ -2884,7 +2883,7 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type,
28842883
sanity_check_seg_type(sbi, seg_type);
28852884

28862885
/* f2fs_need_SSR() already forces to do this */
2887-
if (!v_ops->get_victim(sbi, &segno, BG_GC, seg_type, alloc_mode, age)) {
2886+
if (!f2fs_get_victim(sbi, &segno, BG_GC, seg_type, alloc_mode, age)) {
28882887
curseg->next_segno = segno;
28892888
return 1;
28902889
}
@@ -2911,7 +2910,7 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type,
29112910
for (; cnt-- > 0; reversed ? i-- : i++) {
29122911
if (i == seg_type)
29132912
continue;
2914-
if (!v_ops->get_victim(sbi, &segno, BG_GC, i, alloc_mode, age)) {
2913+
if (!f2fs_get_victim(sbi, &segno, BG_GC, i, alloc_mode, age)) {
29152914
curseg->next_segno = segno;
29162915
return 1;
29172916
}

fs/f2fs/segment.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ enum dirty_type {
289289
};
290290

291291
struct dirty_seglist_info {
292-
const struct victim_selection *v_ops; /* victim selction operation */
293292
unsigned long *dirty_segmap[NR_DIRTY_TYPE];
294293
unsigned long *dirty_secmap;
295294
struct mutex seglist_lock; /* lock for segment bitmaps */
@@ -300,12 +299,6 @@ struct dirty_seglist_info {
300299
bool enable_pin_section; /* enable pinning section */
301300
};
302301

303-
/* victim selection function for cleaning and SSR */
304-
struct victim_selection {
305-
int (*get_victim)(struct f2fs_sb_info *, unsigned int *,
306-
int, int, char, unsigned long long);
307-
};
308-
309302
/* for active log information */
310303
struct curseg_info {
311304
struct mutex curseg_mutex; /* lock for consistency */

0 commit comments

Comments
 (0)