Skip to content

Commit 274bd9b

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: add to account skip count of background GC
This patch adds to account skip count of background GC, and show stat info via 'status' debugfs entry. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent b63e7be commit 274bd9b

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

fs/f2fs/debug.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
101101
si->avail_nids = NM_I(sbi)->available_nids;
102102
si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID];
103103
si->bg_gc = sbi->bg_gc;
104+
si->io_skip_bggc = sbi->io_skip_bggc;
105+
si->other_skip_bggc = sbi->other_skip_bggc;
104106
si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC];
105107
si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC];
106108
si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg)
@@ -355,6 +357,8 @@ static int stat_show(struct seq_file *s, void *v)
355357
si->skipped_atomic_files[BG_GC] +
356358
si->skipped_atomic_files[FG_GC],
357359
si->skipped_atomic_files[BG_GC]);
360+
seq_printf(s, "BG skip : IO: %u, Other: %u\n",
361+
si->io_skip_bggc, si->other_skip_bggc);
358362
seq_puts(s, "\nExtent Cache:\n");
359363
seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n",
360364
si->hit_largest, si->hit_cached,

fs/f2fs/f2fs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,8 @@ struct f2fs_sb_info {
12771277
atomic_t max_aw_cnt; /* max # of atomic writes */
12781278
atomic_t max_vw_cnt; /* max # of volatile writes */
12791279
int bg_gc; /* background gc calls */
1280+
unsigned int io_skip_bggc; /* skip background gc for in-flight IO */
1281+
unsigned int other_skip_bggc; /* skip background gc for other reasons */
12801282
unsigned int ndirty_inode[NR_INODE_TYPE]; /* # of dirty inodes */
12811283
#endif
12821284
spinlock_t stat_lock; /* lock for stat operations */
@@ -3104,6 +3106,7 @@ struct f2fs_stat_info {
31043106
int free_nids, avail_nids, alloc_nids;
31053107
int total_count, utilization;
31063108
int bg_gc, nr_wb_cp_data, nr_wb_data;
3109+
unsigned int io_skip_bggc, other_skip_bggc;
31073110
int nr_flushing, nr_flushed, flush_list_empty;
31083111
int nr_discarding, nr_discarded;
31093112
int nr_discard_cmd;
@@ -3141,6 +3144,8 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
31413144
#define stat_inc_bg_cp_count(si) ((si)->bg_cp_count++)
31423145
#define stat_inc_call_count(si) ((si)->call_count++)
31433146
#define stat_inc_bggc_count(sbi) ((sbi)->bg_gc++)
3147+
#define stat_io_skip_bggc_count(sbi) ((sbi)->io_skip_bggc++)
3148+
#define stat_other_skip_bggc_count(sbi) ((sbi)->other_skip_bggc++)
31443149
#define stat_inc_dirty_inode(sbi, type) ((sbi)->ndirty_inode[type]++)
31453150
#define stat_dec_dirty_inode(sbi, type) ((sbi)->ndirty_inode[type]--)
31463151
#define stat_inc_total_hit(sbi) (atomic64_inc(&(sbi)->total_hit_ext))
@@ -3257,6 +3262,8 @@ void f2fs_destroy_root_stats(void);
32573262
#define stat_inc_bg_cp_count(si) do { } while (0)
32583263
#define stat_inc_call_count(si) do { } while (0)
32593264
#define stat_inc_bggc_count(si) do { } while (0)
3265+
#define stat_io_skip_bggc_count(sbi) do { } while (0)
3266+
#define stat_other_skip_bggc_count(sbi) do { } while (0)
32603267
#define stat_inc_dirty_inode(sbi, type) do { } while (0)
32613268
#define stat_dec_dirty_inode(sbi, type) do { } while (0)
32623269
#define stat_inc_total_hit(sb) do { } while (0)

fs/f2fs/gc.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ static int gc_thread_func(void *data)
4040
if (gc_th->gc_wake)
4141
gc_th->gc_wake = 0;
4242

43-
if (try_to_freeze())
43+
if (try_to_freeze()) {
44+
stat_other_skip_bggc_count(sbi);
4445
continue;
46+
}
4547
if (kthread_should_stop())
4648
break;
4749

4850
if (sbi->sb->s_writers.frozen >= SB_FREEZE_WRITE) {
4951
increase_sleep_time(gc_th, &wait_ms);
52+
stat_other_skip_bggc_count(sbi);
5053
continue;
5154
}
5255

@@ -55,8 +58,10 @@ static int gc_thread_func(void *data)
5558
f2fs_stop_checkpoint(sbi, false);
5659
}
5760

58-
if (!sb_start_write_trylock(sbi->sb))
61+
if (!sb_start_write_trylock(sbi->sb)) {
62+
stat_other_skip_bggc_count(sbi);
5963
continue;
64+
}
6065

6166
/*
6267
* [GC triggering condition]
@@ -77,12 +82,15 @@ static int gc_thread_func(void *data)
7782
goto do_gc;
7883
}
7984

80-
if (!mutex_trylock(&sbi->gc_mutex))
85+
if (!mutex_trylock(&sbi->gc_mutex)) {
86+
stat_other_skip_bggc_count(sbi);
8187
goto next;
88+
}
8289

8390
if (!is_idle(sbi, GC_TIME)) {
8491
increase_sleep_time(gc_th, &wait_ms);
8592
mutex_unlock(&sbi->gc_mutex);
93+
stat_io_skip_bggc_count(sbi);
8694
goto next;
8795
}
8896

0 commit comments

Comments
 (0)