Skip to content

Commit ce8c59d

Browse files
harshadjstytso
authored andcommitted
ext4: add fast commit stats in procfs
This commit adds a file in procfs that tracks fast commit related statistics. root@kvm-xfstests:/mnt# cat /proc/fs/ext4/vdc/fc_info fc stats: 7772 commits 15 ineligible 4083 numblks 2242us avg_commit_time Ineligible reasons: "Extended attributes changed": 0 "Cross rename": 0 "Journal flag changed": 0 "Insufficient memory": 0 "Swap boot": 0 "Resize": 0 "Dir renamed": 0 "Falloc range op": 0 "FC Commit Failed": 15 Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Link: https://lore.kernel.org/r/20201015203802.3597742-10-harshadshirwadkar@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 0f0672f commit ce8c59d

3 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎fs/ext4/ext4.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2740,7 +2740,7 @@ extern int ext4_init_inode_table(struct super_block *sb,
27402740
extern void ext4_end_bitmap_read(struct buffer_head *bh, int uptodate);
27412741

27422742
/* fast_commit.c */
2743-
2743+
int ext4_fc_info_show(struct seq_file *seq, void *v);
27442744
void ext4_fc_init(struct super_block *sb, journal_t *journal);
27452745
void ext4_fc_init_inode(struct inode *inode);
27462746
void ext4_fc_track_range(struct inode *inode, ext4_lblk_t start,

‎fs/ext4/fast_commit.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,6 +2093,40 @@ void ext4_fc_init(struct super_block *sb, journal_t *journal)
20932093
}
20942094
}
20952095

2096+
const char *fc_ineligible_reasons[] = {
2097+
"Extended attributes changed",
2098+
"Cross rename",
2099+
"Journal flag changed",
2100+
"Insufficient memory",
2101+
"Swap boot",
2102+
"Resize",
2103+
"Dir renamed",
2104+
"Falloc range op",
2105+
"FC Commit Failed"
2106+
};
2107+
2108+
int ext4_fc_info_show(struct seq_file *seq, void *v)
2109+
{
2110+
struct ext4_sb_info *sbi = EXT4_SB((struct super_block *)seq->private);
2111+
struct ext4_fc_stats *stats = &sbi->s_fc_stats;
2112+
int i;
2113+
2114+
if (v != SEQ_START_TOKEN)
2115+
return 0;
2116+
2117+
seq_printf(seq,
2118+
"fc stats:\n%ld commits\n%ld ineligible\n%ld numblks\n%lluus avg_commit_time\n",
2119+
stats->fc_num_commits, stats->fc_ineligible_commits,
2120+
stats->fc_numblks,
2121+
div_u64(sbi->s_fc_avg_commit_time, 1000));
2122+
seq_puts(seq, "Ineligible reasons:\n");
2123+
for (i = 0; i < EXT4_FC_REASON_MAX; i++)
2124+
seq_printf(seq, "\"%s\":\t%d\n", fc_ineligible_reasons[i],
2125+
stats->fc_ineligible_reason_count[i]);
2126+
2127+
return 0;
2128+
}
2129+
20962130
int __init ext4_fc_init_dentry_cache(void)
20972131
{
20982132
ext4_fc_dentry_cachep = KMEM_CACHE(ext4_fc_dentry_update,

‎fs/ext4/sysfs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ int ext4_register_sysfs(struct super_block *sb)
521521
proc_create_single_data("es_shrinker_info", S_IRUGO,
522522
sbi->s_proc, ext4_seq_es_shrinker_info_show,
523523
sb);
524+
proc_create_single_data("fc_info", 0444, sbi->s_proc,
525+
ext4_fc_info_show, sb);
524526
proc_create_seq_data("mb_groups", S_IRUGO, sbi->s_proc,
525527
&ext4_mb_seq_groups_ops, sb);
526528
}

0 commit comments

Comments
 (0)