@@ -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;
@@ -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);
@@ -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');
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@gmail.com> --- 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(+)