]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: bch2_recovery_pass_status_to_text()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 10 May 2025 22:23:41 +0000 (18:23 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:15:03 +0000 (20:15 -0400)
Show recovery pass status in sysfs - important now that we're running
them automatically in the background.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/recovery_passes.c
fs/bcachefs/recovery_passes.h
fs/bcachefs/sysfs.c

index e0e261aa752e156a80c2858f7032f4478732861d..02639b3d86b0f064a3f9e331bfd127b7116a3d5d 100644 (file)
@@ -444,6 +444,30 @@ int bch2_run_recovery_passes(struct bch_fs *c, enum bch_recovery_pass from)
        return ret;
 }
 
+static void prt_passes(struct printbuf *out, const char *msg, u64 passes)
+{
+       prt_printf(out, "%s:\t", msg);
+       prt_bitflags(out, bch2_recovery_passes, passes);
+       prt_newline(out);
+}
+
+void bch2_recovery_pass_status_to_text(struct printbuf *out, struct bch_fs *c)
+{
+       struct bch_fs_recovery *r = &c->recovery;
+
+       printbuf_tabstop_push(out, 32);
+       prt_passes(out, "Scheduled passes", c->sb.recovery_passes_required);
+       prt_passes(out, "Scheduled online passes", c->sb.recovery_passes_required &
+                  bch2_recovery_passes_match(PASS_ONLINE));
+       prt_passes(out, "Complete passes", r->passes_complete);
+       prt_passes(out, "Failing passes", r->passes_failing);
+
+       if (r->curr_pass) {
+               prt_printf(out, "Current pass:\t%s\n", bch2_recovery_passes[r->curr_pass]);
+               prt_passes(out, "Current passes", r->passes_to_run);
+       }
+}
+
 void bch2_fs_recovery_passes_init(struct bch_fs *c)
 {
        spin_lock_init(&c->recovery.lock);
index 0e79cc33fd8f138459a85df556f033fd2a34373b..8c90e29cd6cb840871c4b50e32c1c4a79f18f8b6 100644 (file)
@@ -20,6 +20,8 @@ int bch2_run_explicit_recovery_pass_persistent(struct bch_fs *, struct printbuf
 int bch2_run_online_recovery_passes(struct bch_fs *, u64);
 int bch2_run_recovery_passes(struct bch_fs *, enum bch_recovery_pass);
 
+void bch2_recovery_pass_status_to_text(struct printbuf *, struct bch_fs *);
+
 void bch2_fs_recovery_passes_init(struct bch_fs *);
 
 #endif /* _BCACHEFS_RECOVERY_PASSES_H */
index de7cda282a8c7d73fa9406f36dc4a540ae329fc6..1a55196d69f11b4d32e9fc369d4b1af30e298504 100644 (file)
@@ -35,6 +35,7 @@
 #include "nocow_locking.h"
 #include "opts.h"
 #include "rebalance.h"
+#include "recovery_passes.h"
 #include "replicas.h"
 #include "super-io.h"
 #include "tests.h"
@@ -200,6 +201,7 @@ read_attribute(copy_gc_wait);
 sysfs_pd_controller_attribute(rebalance);
 read_attribute(rebalance_status);
 read_attribute(snapshot_delete_status);
+read_attribute(recovery_status);
 
 read_attribute(new_stripes);
 
@@ -325,6 +327,9 @@ SHOW(bch2_fs)
        if (attr == &sysfs_snapshot_delete_status)
                bch2_snapshot_delete_status_to_text(out, c);
 
+       if (attr == &sysfs_recovery_status)
+               bch2_recovery_pass_status_to_text(out, c);
+
        /* Debugging: */
 
        if (attr == &sysfs_journal_debug)
@@ -475,6 +480,7 @@ struct attribute *bch2_fs_files[] = {
 
        &sysfs_rebalance_status,
        &sysfs_snapshot_delete_status,
+       &sysfs_recovery_status,
 
        &sysfs_compression_stats,