f2fs: fix to account gc stats correctly
authorChao Yu <chao@kernel.org>
Tue, 8 Aug 2023 00:59:48 +0000 (08:59 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 14 Aug 2023 20:41:57 +0000 (13:41 -0700)
commit9bf1dcbdfdc8892d9cfeaeab02519c0ecf17fe51
treec29635a9b46ba5683a6dee04b96d7118463a970c
parentbc3994ffa4cf23f55171943c713366132c3ff45d
f2fs: fix to account gc stats correctly

As reported, status debugfs entry shows inconsistent GC stats as below:

GC calls: 6008 (BG: 6161)
  - data segments : 3053 (BG: 3053)
  - node segments : 2955 (BG: 2955)

Total GC calls is larger than BGGC calls, the reason is:
- f2fs_stat_info.call_count accounts total migrated section count
by f2fs_gc()
- f2fs_stat_info.bg_gc accounts total call times of f2fs_gc() from
background gc_thread

Another issue is gc_foreground_calls sysfs entry shows total GC call
count rather than FGGC call count.

This patch changes as below for fix:
- account GC calls and migrated segment count separately
- support to account migrated section count if it enables large section
mode
- fix to show correct value in gc_foreground_calls sysfs entry

Fixes: fc7100ea2a52 ("f2fs: Add f2fs stats to sysfs")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/debug.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/segment.c
fs/f2fs/super.c
fs/f2fs/sysfs.c