diff mbox series

[v4,9/9] fs: enable per-sb io stats for all blockdev filesystems

Message ID 20220305160424.1040102-10-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show
Series Generic per-sb io stats | expand

Commit Message

Amir Goldstein March 5, 2022, 4:04 p.m. UTC
In addition to filesystems that opt-in with FS_SB_IOSTATS, auto-enable
per-sb I/O stats for all blockdev filesystems.

This can be used by tools like iotop to display the total I/O stats
via sb along side the submitted I/O stats to block device to get a
more complete view that also includes the cached I/O stats.

Link: https://lore.kernel.org/linux-fsdevel/20220302211226.GG3927073@dread.disaster.area/
Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 fs/super.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/super.c b/fs/super.c
index a18930693e54..e1bee46dfb5a 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -232,7 +232,12 @@  static struct super_block *alloc_super(struct file_system_type *type, int flags,
 	if (security_sb_alloc(s))
 		goto fail;
 
-	if (type->fs_flags & FS_SB_IOSTATS && sb_iostats_init(s))
+	/*
+	 * Account per-sb I/O stats for all blockdev filesystems and for
+	 * filesystems that opt-in with FS_SB_IOSTATS.
+	 */
+	if (type->fs_flags & (FS_SB_IOSTATS | FS_REQUIRES_DEV) &&
+	    sb_iostats_init(s))
 		goto fail;
 
 	for (i = 0; i < SB_FREEZE_LEVELS; i++) {