Show optional collected per-mount io stats in /proc/<pid>/mountstats for filesystems that do not implement their own show_stats() method. Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx> --- See following snippet from mountstats example report: device overlay mounted on /mnt with fstype overlay times: 125 153 rchar: 12 wchar: 0 syscr: 2 syscw: 0 Thanks, Amir. fs/mount.h | 1 + fs/namespace.c | 2 ++ fs/proc_namespace.c | 13 +++++++++++++ 3 files changed, 16 insertions(+) diff --git a/fs/mount.h b/fs/mount.h index 81db83c36140..1f262892a6ed 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -91,6 +91,7 @@ struct mount { int mnt_id; /* mount identifier */ int mnt_group_id; /* peer group identifier */ int mnt_expiry_mark; /* true if marked for expiry */ + time64_t mnt_time; /* time of mount */ struct hlist_head mnt_pins; struct hlist_head mnt_stuck_children; } __randomize_layout; diff --git a/fs/namespace.c b/fs/namespace.c index 04b35dfcc71f..3a91234e5fd0 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -198,6 +198,8 @@ static struct mount *alloc_vfsmnt(const char *name) mnt->mnt_count = 1; mnt->mnt_writers = 0; #endif + /* For proc/<pid>/mountstats */ + mnt->mnt_time = ktime_get_seconds(); INIT_HLIST_NODE(&mnt->mnt_hash); INIT_LIST_HEAD(&mnt->mnt_child); diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index eafb75755fa3..34aea7f3f550 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -229,6 +229,19 @@ static int show_vfsstat(struct seq_file *m, struct vfsmount *mnt) if (sb->s_op->show_stats) { seq_putc(m, ' '); err = sb->s_op->show_stats(m, mnt_path.dentry); + } else if (mnt_has_stats(mnt)) { + /* Similar to /proc/<pid>/io */ + seq_printf(m, "\n" + "\ttimes: %lld %lld\n" + "\trchar: %lld\n" + "\twchar: %lld\n" + "\tsyscr: %lld\n" + "\tsyscw: %lld\n", + r->mnt_time, ktime_get_seconds(), + mnt_iostats_counter_read(r, MNTIOS_CHARS_RD), + mnt_iostats_counter_read(r, MNTIOS_CHARS_WR), + mnt_iostats_counter_read(r, MNTIOS_SYSCALLS_RD), + mnt_iostats_counter_read(r, MNTIOS_SYSCALLS_WR)); } seq_putc(m, '\n'); -- 2.25.1