From: Amir Goldstein <amir73il@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Dave Chinner <david@fromorbit.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 4/6] fs: report per-sb io stats
Date: Tue, 1 Mar 2022 20:42:19 +0200 [thread overview]
Message-ID: <20220301184221.371853-5-amir73il@gmail.com> (raw)
In-Reply-To: <20220301184221.371853-1-amir73il@gmail.com>
Show optional collected per-sb io stats in /proc/<pid>/mountstats
for filesystems that do not implement their own show_stats() method
and opted-in to generic per-sb stats with sb_iostats_init().
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
fs/proc_namespace.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 49650e54d2f8..9054a909e031 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -11,6 +11,7 @@
#include <linux/nsproxy.h>
#include <linux/security.h>
#include <linux/fs_struct.h>
+#include <linux/fs_iostats.h>
#include <linux/sched/task.h>
#include "proc/internal.h" /* only for get_proc_task() in ->open() */
@@ -232,6 +233,21 @@ 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 (sb_has_iostats(sb)) {
+ struct sb_iostats *iostats = sb_iostats(sb);
+
+ /* 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",
+ iostats->start_time, ktime_get_seconds(),
+ sb_iostats_counter_read(sb, SB_IOSTATS_CHARS_RD),
+ sb_iostats_counter_read(sb, SB_IOSTATS_CHARS_WR),
+ sb_iostats_counter_read(sb, SB_IOSTATS_SYSCALLS_RD),
+ sb_iostats_counter_read(sb, SB_IOSTATS_SYSCALLS_WR));
}
seq_putc(m, '\n');
--
2.25.1
next prev parent reply other threads:[~2022-03-01 18:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-01 18:42 [PATCH v3 0/6] Generic per-sb io stats Amir Goldstein
2022-03-01 18:42 ` [PATCH v3 1/6] lib/percpu_counter: add helpers for arrays of counters Amir Goldstein
2022-03-01 18:42 ` [PATCH v3 2/6] fs: add optional iostats counters to struct super_block Amir Goldstein
2022-03-01 18:42 ` [PATCH v3 3/6] fs: collect per-sb io stats Amir Goldstein
2022-03-01 18:42 ` Amir Goldstein [this message]
2022-03-01 18:42 ` [PATCH v3 5/6] ovl: opt-in for " Amir Goldstein
2022-03-01 18:42 ` [PATCH v3 6/6] fuse: " Amir Goldstein
2022-03-02 6:59 ` [PATCH v3 0/6] Generic " Dave Chinner
2022-03-02 7:43 ` Amir Goldstein
2022-03-02 8:26 ` Dave Chinner
2022-03-02 8:34 ` Amir Goldstein
2022-03-02 16:59 ` Amir Goldstein
2022-03-02 21:12 ` Dave Chinner
2022-03-03 6:50 ` Amir Goldstein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220301184221.371853-5-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).