In bcachefs, io_read and io_write counter record the amount
of data which has been read and written. They increase in
unit of sector, so to display correctly, they need to be
shifted to the left by the size of a sector.
Fixes: 1c6fdbd8f246 ("bcachefs: Initial commit")
Signed-off-by: Hongbo Li <[email protected]>
---
When I read one 15.7M file, the io_read sysfs interface shows:
- Before this patch
- original:
since mount: 0 B
since filesystem creation: 5.11 KiB
- after read:
since mount: 31.4 KiB
since filesystem creation: 36.5 KiB
- After this patch:
- original:
since mount: 0 B
since filesystem creation: 18.3 MiB
- after read:
since mount: 15.7 MiB
since filesystem creation: 34.0 MiB
---
fs/bcachefs/sysfs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/bcachefs/sysfs.c b/fs/bcachefs/sysfs.c
index 97733c766948..aa46b69da4d8 100644
--- a/fs/bcachefs/sysfs.c
+++ b/fs/bcachefs/sysfs.c
@@ -513,6 +513,11 @@ SHOW(bch2_fs_counters)
if (attr == &sysfs_##t) {
\
counter =
percpu_u64_get(&c->counters[BCH_COUNTER_##t]);\
counter_since_mount = counter -
c->counters_on_mount[BCH_COUNTER_##t];\
+ if (attr == &sysfs_io_read || attr == &sysfs_io_write)
{\
+ counter <<= 9;
\
+ counter_since_mount <<= 9;
\
+ }
\
+
\
prt_printf(out, "since mount:\t");
\
prt_human_readable_u64(out, counter_since_mount);
\
prt_newline(out);
\
--
2.34.1