bcachefs: bch2_copygc_wait_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 2 Mar 2023 04:10:39 +0000 (23:10 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:55 +0000 (17:09 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/movinggc.c
fs/bcachefs/movinggc.h
fs/bcachefs/sysfs.c

index 74e57f6ea148a6e32ff822bf858dee11765c3a56..63b358c95282e220ddb580e80c64fe16a896d844 100644 (file)
@@ -172,6 +172,18 @@ unsigned long bch2_copygc_wait_amount(struct bch_fs *c)
        return wait;
 }
 
+void bch2_copygc_wait_to_text(struct printbuf *out, struct bch_fs *c)
+{
+       prt_printf(out, "Currently waiting for:     ");
+       prt_human_readable_u64(out, max(0LL, c->copygc_wait -
+                                       atomic64_read(&c->io_clock[WRITE].now)) << 9);
+       prt_newline(out);
+
+       prt_printf(out, "Currently calculated wait: ");
+       prt_human_readable_u64(out, bch2_copygc_wait_amount(c));
+       prt_newline(out);
+}
+
 static int bch2_copygc_thread(void *arg)
 {
        struct bch_fs *c = arg;
index e85c8136a46e9b7ad52e987c9d299c4d4c9cc581..ea181fef5bc93232f42ac18e1033fcca3b7eda71 100644 (file)
@@ -3,6 +3,8 @@
 #define _BCACHEFS_MOVINGGC_H
 
 unsigned long bch2_copygc_wait_amount(struct bch_fs *);
+void bch2_copygc_wait_to_text(struct printbuf *, struct bch_fs *);
+
 void bch2_copygc_stop(struct bch_fs *);
 int bch2_copygc_start(struct bch_fs *);
 void bch2_fs_copygc_init(struct bch_fs *);
index 8108e1d81345115fe47ca25986f4e4d1dcf5f1b2..4abba2c9ccfa49b8dc32fd3a11eec5d5fe202ec1 100644 (file)
@@ -27,6 +27,7 @@
 #include "journal.h"
 #include "keylist.h"
 #include "move.h"
+#include "movinggc.h"
 #include "nocow_locking.h"
 #include "opts.h"
 #include "rebalance.h"
@@ -427,9 +428,9 @@ SHOW(bch2_fs)
 
        sysfs_printf(rebalance_enabled,         "%i", c->rebalance.enabled);
        sysfs_pd_controller_show(rebalance,     &c->rebalance.pd); /* XXX */
-       sysfs_hprint(copy_gc_wait,
-                    max(0LL, c->copygc_wait -
-                        atomic64_read(&c->io_clock[WRITE].now)) << 9);
+
+       if (attr == &sysfs_copy_gc_wait)
+               bch2_copygc_wait_to_text(out, c);
 
        if (attr == &sysfs_rebalance_work)
                bch2_rebalance_work_to_text(out, c);