bcachefs: Add iops fields to bch_member
authorHunter Shaffer <huntershaffer182456@gmail.com>
Mon, 25 Sep 2023 04:46:28 +0000 (00:46 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:15 +0000 (17:10 -0400)
Signed-off-by: Hunter Shaffer <huntershaffer182456@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs_format.h
fs/bcachefs/opts.c
fs/bcachefs/opts.h
fs/bcachefs/sb-members.c

index 45701b1230b79af059e1518d0ee7f47c4c1eef4b..99749f3315fec5fafb0b6d051ca01f0b7384834a 100644 (file)
@@ -1269,6 +1269,19 @@ struct bch_sb_field_journal_v2 {
 
 #define BCH_MIN_NR_NBUCKETS    (1 << 6)
 
+#define BCH_IOPS_MEASUREMENTS()                        \
+       x(seqread,      0)                      \
+       x(seqwrite,     1)                      \
+       x(randread,     2)                      \
+       x(randwrite,    3)
+
+enum bch_iops_measurement {
+#define x(t, n) BCH_IOPS_##t = n,
+       BCH_IOPS_MEASUREMENTS()
+#undef x
+       BCH_IOPS_NR
+};
+
 struct bch_member {
        __uuid_t                uuid;
        __le64                  nbuckets;       /* device size */
@@ -1277,19 +1290,20 @@ struct bch_member {
        __le32                  pad;
        __le64                  last_mount;     /* time_t */
 
-       __le64                  flags[2];
+       __le64                  flags;
+       __le32                  iops[4];
 };
 
 #define BCH_MEMBER_V1_BYTES    56
 
-LE64_BITMASK(BCH_MEMBER_STATE,         struct bch_member, flags[0],  0,  4)
+LE64_BITMASK(BCH_MEMBER_STATE,         struct bch_member, flags,  0,  4)
 /* 4-14 unused, was TIER, HAS_(META)DATA, REPLACEMENT */
-LE64_BITMASK(BCH_MEMBER_DISCARD,       struct bch_member, flags[0], 14, 15)
-LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED,  struct bch_member, flags[0], 15, 20)
-LE64_BITMASK(BCH_MEMBER_GROUP,         struct bch_member, flags[0], 20, 28)
-LE64_BITMASK(BCH_MEMBER_DURABILITY,    struct bch_member, flags[0], 28, 30)
+LE64_BITMASK(BCH_MEMBER_DISCARD,       struct bch_member, flags, 14, 15)
+LE64_BITMASK(BCH_MEMBER_DATA_ALLOWED,  struct bch_member, flags, 15, 20)
+LE64_BITMASK(BCH_MEMBER_GROUP,         struct bch_member, flags, 20, 28)
+LE64_BITMASK(BCH_MEMBER_DURABILITY,    struct bch_member, flags, 28, 30)
 LE64_BITMASK(BCH_MEMBER_FREESPACE_INITIALIZED,
-                                       struct bch_member, flags[0], 30, 31)
+                                       struct bch_member, flags, 30, 31)
 
 #if 0
 LE64_BITMASK(BCH_MEMBER_NR_READ_ERRORS,        struct bch_member, flags[1], 0,  20);
index 739a2ef80945b095a19aae195084888db817cd46..232f50c73a9452efa01cfa97436588bb42b1fc87 100644 (file)
 
 #define x(t, n, ...) [n] = #t,
 
+const char * const bch2_iops_measurements[] = {
+       BCH_IOPS_MEASUREMENTS()
+       NULL
+};
+
 const char * const bch2_error_actions[] = {
        BCH_ERROR_ACTIONS()
        NULL
index c21c258e40184b63e6fcee7ec708c6c2509e532e..55014336c5f7534d3deadf16fc77671108d25d7b 100644 (file)
@@ -10,6 +10,7 @@
 
 struct bch_fs;
 
+extern const char * const bch2_iops_measurements[];
 extern const char * const bch2_error_actions[];
 extern const char * const bch2_fsck_fix_opts[];
 extern const char * const bch2_version_upgrade_opts[];
index b9a75eb5a8ebf597913425703bd222ae227941bd..04bde1aaff9f45de7fc5b3cd37af448bca0076d2 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "bcachefs.h"
 #include "disk_groups.h"
+#include "opts.h"
 #include "replicas.h"
 #include "sb-members.h"
 #include "super-io.h"
@@ -172,6 +173,13 @@ static void member_to_text(struct printbuf *out,
        prt_units_u64(out, device_size << 9);
        prt_newline(out);
 
+       for (unsigned i = 0; i < BCH_IOPS_NR; i++) {
+               prt_printf(out, "%s iops:", bch2_iops_measurements[i]);
+               prt_tab(out);
+               prt_printf(out, "%u", le32_to_cpu(m.iops[i]));
+               prt_newline(out);
+       }
+
        prt_printf(out, "Bucket size:");
        prt_tab(out);
        prt_units_u64(out, bucket_size << 9);