aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/debug.c
diff options
context:
space:
mode:
authorChao Yu <yuchao0@huawei.com>2018-05-07 08:28:54 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2018-05-31 14:31:51 -0400
commit2ef79ecb5e906d87475d3e0c49b22425499a89f3 (patch)
tree266179c3b3bd4d98a621ce4652729bdb716e1d2f /fs/f2fs/debug.c
parent5b0e95398e2bcc18e871758221cc712be4a0a39a (diff)
f2fs: avoid stucking GC due to atomic write
f2fs doesn't allow abuse on atomic write class interface, so except limiting in-mem pages' total memory usage capacity, we need to limit atomic-write usage as well when filesystem is seriously fragmented, otherwise we may run into infinite loop during foreground GC because target blocks in victim segment are belong to atomic opened file for long time. Now, we will detect failure due to atomic write in foreground GC, if the count exceeds threshold, we will drop all atomic written data in cache, by this, I expect it can keep our system running safely to prevent Dos attack. In addition, his patch adds to show GC skip information in debugfs, now it just shows count of skipped caused by atomic write. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/debug.c')
-rw-r--r--fs/f2fs/debug.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index a66107b5cfff..2d65e77ae5cf 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -104,6 +104,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
104 si->avail_nids = NM_I(sbi)->available_nids; 104 si->avail_nids = NM_I(sbi)->available_nids;
105 si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; 105 si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID];
106 si->bg_gc = sbi->bg_gc; 106 si->bg_gc = sbi->bg_gc;
107 si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC];
108 si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC];
107 si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg) 109 si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg)
108 * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg) 110 * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg)
109 / 2; 111 / 2;
@@ -342,6 +344,10 @@ static int stat_show(struct seq_file *s, void *v)
342 si->bg_data_blks); 344 si->bg_data_blks);
343 seq_printf(s, " - node blocks : %d (%d)\n", si->node_blks, 345 seq_printf(s, " - node blocks : %d (%d)\n", si->node_blks,
344 si->bg_node_blks); 346 si->bg_node_blks);
347 seq_printf(s, "Skipped : atomic write %llu (%llu)\n",
348 si->skipped_atomic_files[BG_GC] +
349 si->skipped_atomic_files[FG_GC],
350 si->skipped_atomic_files[BG_GC]);
345 seq_puts(s, "\nExtent Cache:\n"); 351 seq_puts(s, "\nExtent Cache:\n");
346 seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n", 352 seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n",
347 si->hit_largest, si->hit_cached, 353 si->hit_largest, si->hit_cached,