Skip to content

Commit e073e92

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: add a proc entry show inject stats
This patch adds a proc entry named inject_stats to show total injected count for each fault type. cat /proc/fs/f2fs/<dev>/inject_stats fault_type injected_count kmalloc 0 kvmalloc 0 page alloc 0 page get 0 alloc bio(obsolete) 0 alloc nid 0 orphan 0 no more block 0 too big dir depth 0 evict_inode fail 0 truncate fail 0 read IO error 0 checkpoint error 0 discard error 0 write IO error 0 slab alloc 0 dquot initialize 0 lock_op 0 invalid blkaddr 0 inconsistent blkaddr 0 no free segment 0 inconsistent footer 0 Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 539d334 commit e073e92

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

fs/f2fs/f2fs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ struct f2fs_fault_info {
7373
atomic_t inject_ops;
7474
int inject_rate;
7575
unsigned int inject_type;
76+
/* Used to account total count of injection for each type */
77+
unsigned int inject_count[FAULT_MAX];
7678
};
7779

7880
extern const char *f2fs_fault_name[FAULT_MAX];
@@ -1902,6 +1904,7 @@ static inline bool __time_to_inject(struct f2fs_sb_info *sbi, int type,
19021904
atomic_inc(&ffi->inject_ops);
19031905
if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
19041906
atomic_set(&ffi->inject_ops, 0);
1907+
ffi->inject_count[type]++;
19051908
f2fs_info_ratelimited(sbi, "inject %s in %s of %pS",
19061909
f2fs_fault_name[type], func, parent_func);
19071910
return true;

fs/f2fs/super.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const char *f2fs_fault_name[FAULT_MAX] = {
4747
[FAULT_KVMALLOC] = "kvmalloc",
4848
[FAULT_PAGE_ALLOC] = "page alloc",
4949
[FAULT_PAGE_GET] = "page get",
50+
[FAULT_ALLOC_BIO] = "alloc bio(obsolete)",
5051
[FAULT_ALLOC_NID] = "alloc nid",
5152
[FAULT_ORPHAN] = "orphan",
5253
[FAULT_BLOCK] = "no more block",

fs/f2fs/sysfs.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,24 @@ static int __maybe_unused disk_map_seq_show(struct seq_file *seq,
16791679
return 0;
16801680
}
16811681

1682+
#ifdef CONFIG_F2FS_FAULT_INJECTION
1683+
static int __maybe_unused inject_stats_seq_show(struct seq_file *seq,
1684+
void *offset)
1685+
{
1686+
struct super_block *sb = seq->private;
1687+
struct f2fs_sb_info *sbi = F2FS_SB(sb);
1688+
struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;
1689+
int i;
1690+
1691+
seq_puts(seq, "fault_type injected_count\n");
1692+
1693+
for (i = 0; i < FAULT_MAX; i++)
1694+
seq_printf(seq, "%-24s%-10u\n", f2fs_fault_name[i],
1695+
ffi->inject_count[i]);
1696+
return 0;
1697+
}
1698+
#endif
1699+
16821700
int __init f2fs_init_sysfs(void)
16831701
{
16841702
int ret;
@@ -1770,6 +1788,10 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
17701788
discard_plist_seq_show, sb);
17711789
proc_create_single_data("disk_map", 0444, sbi->s_proc,
17721790
disk_map_seq_show, sb);
1791+
#ifdef CONFIG_F2FS_FAULT_INJECTION
1792+
proc_create_single_data("inject_stats", 0444, sbi->s_proc,
1793+
inject_stats_seq_show, sb);
1794+
#endif
17731795
return 0;
17741796
put_feature_list_kobj:
17751797
kobject_put(&sbi->s_feature_list_kobj);

0 commit comments

Comments
 (0)