Skip to contentSkip to conversation

bcachefs: recovery_passes_types.h -> recovery_passes_format.h

PATCH New Kent Overstreet 1 participant 2 messages May 10, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 bcachefs: recovery_passes_types.h -> recovery_passes_format.h

---
 fs/bcachefs/bcachefs.h                                      | 1 -
 fs/bcachefs/bcachefs_format.h                               | 1 +
 .../{recovery_passes_types.h => recovery_passes_format.h}   | 6 +++---
 3 files changed, 4 insertions(+), 4 deletions(-)
 rename fs/bcachefs/{recovery_passes_types.h => recovery_passes_format.h} (95%)
fs/bcachefs/bcachefs.h +0 -1
index fe9710522419..84cd38a89159 100644
@@ -213,7 +213,6 @@
 #include "fifo.h"
 #include "nocow_locking_types.h"
 #include "opts.h"
-#include "recovery_passes_types.h"
 #include "sb-errors_types.h"
 #include "seqmutex.h"
 #include "snapshot_types.h"
fs/bcachefs/bcachefs_format.h +1 -0
index a483d440fa39..df5a4d4df640 100644
@@ -510,6 +510,7 @@ struct bch_sb_field {
 #include "logged_ops_format.h"
 #include "lru_format.h"
 #include "quota_format.h"
+#include "recovery_passes_format.h"
 #include "reflink_format.h"
 #include "replicas_format.h"
 #include "snapshot_format.h"
fs/bcachefs/recovery_passes_format.h renamed from fs/bcachefs/recovery_passes_types.h +3 -3
similarity index 95%
rename from fs/bcachefs/recovery_passes_types.h
rename to fs/bcachefs/recovery_passes_format.h
index be3185fc6ef4..291f58dfbd24 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _BCACHEFS_RECOVERY_PASSES_TYPES_H
-#define _BCACHEFS_RECOVERY_PASSES_TYPES_H
+#ifndef _BCACHEFS_RECOVERY_PASSES_FORMAT_H
+#define _BCACHEFS_RECOVERY_PASSES_FORMAT_H
 
 #define PASS_SILENT		BIT(0)
 #define PASS_FSCK		BIT(1)
@@ -81,4 +81,4 @@ enum bch_recovery_pass_stable {
 #undef x
 };
 
-#endif /* _BCACHEFS_RECOVERY_PASSES_TYPES_H */
+#endif /* _BCACHEFS_RECOVERY_PASSES_FORMAT_H */
Signature · 1 line
2.49.0
#1 lore raw

PATCH 2/2 bcachefs: bch_sb_field_recovery_passes

New superblock section for statistics on recovery passes - last time ran (successfully), last runtime.

This will be used by self healing code to determine when to kick off potentially expensive recovery passes.

---
 fs/bcachefs/backpointers.c           |   7 ++
 fs/bcachefs/bcachefs_format.h        |   3 +-
 fs/bcachefs/recovery_passes.c        | 181 +++++++++++++++++++--------
 fs/bcachefs/recovery_passes.h        |   2 +
 fs/bcachefs/recovery_passes_format.h |  20 +++
 fs/bcachefs/sb-members.c             |  14 +--
 6 files changed, 161 insertions(+), 66 deletions(-)
fs/bcachefs/backpointers.c +7 -0
index 321c7b53d970..597ea0a65c6e 100644
@@ -1228,6 +1228,13 @@ int bch2_check_bucket_backpointer_mismatch(struct btree_trans *trans,
 	if (nr > allowed)
 		bch2_check_extents_to_backpointers_async(trans->c);
 
+	/*
+	 * Track duration of last check_extents_to_backpointers (all recovery
+	 * passes?)
+	 *
+	 * Track when we last ran check_extents_to_backpointers
+	 */
+
 	return ret;
 }
 
fs/bcachefs/bcachefs_format.h +2 -1
index df5a4d4df640..5900ff3715c6 100644
@@ -497,7 +497,8 @@ struct bch_sb_field {
 	x(members_v2,			11)	\
 	x(errors,			12)	\
 	x(ext,				13)	\
-	x(downgrade,			14)
+	x(downgrade,			14)	\
+	x(recovery_passes,		15)
 
 #include "alloc_background_format.h"
 #include "dirent_format.h"
fs/bcachefs/recovery_passes.c +126 -55

217 lines not on this page · raw message

fs/bcachefs/recovery_passes.h +2 -0
index f33dd005beb4..d39856f908da 100644
@@ -3,6 +3,8 @@
 
 extern const char * const bch2_recovery_passes[];
 
+extern const struct bch_sb_field_ops bch_sb_field_ops_recovery_passes;
+
 u64 bch2_recovery_passes_to_stable(u64 v);
 u64 bch2_recovery_passes_from_stable(u64 v);
 
fs/bcachefs/recovery_passes_format.h +20 -0
index 291f58dfbd24..c434eafbca19 100644
@@ -81,4 +81,24 @@ enum bch_recovery_pass_stable {
 #undef x
 };
 
+struct recovery_pass_entry {
+	__le64			last_run;
+	__le32			last_runtime;
+	__le32			flags;
+};
+
+struct bch_sb_field_recovery_passes {
+	struct bch_sb_field	field;
+	struct recovery_pass_entry start[];
+};
+
+static inline unsigned
+recovery_passes_nr_entries(struct bch_sb_field_recovery_passes *r)
+{
+	return r
+		? ((vstruct_end(&r->field) - (void *) &r->start[0]) /
+		   sizeof(struct recovery_pass_entry))
+		: 0;
+}
+
 #endif /* _BCACHEFS_RECOVERY_PASSES_FORMAT_H */
fs/bcachefs/sb-members.c +4 -10
index 563263d65cf0..0cc26ebceb30 100644
@@ -222,17 +222,11 @@ static void member_to_text(struct printbuf *out,
 	printbuf_indent_add(out, 2);
 
 	prt_printf(out, "Label:\t");
-	if (BCH_MEMBER_GROUP(&m)) {
-		unsigned idx = BCH_MEMBER_GROUP(&m) - 1;
-
-		if (idx < disk_groups_nr(gi))
-			prt_printf(out, "%s (%u)",
-				   gi->entries[idx].label, idx);
-		else
-			prt_printf(out, "(bad disk labels section)");
-	} else {
+	if (BCH_MEMBER_GROUP(&m))
+		bch2_disk_path_to_text_sb(out, sb,
+				BCH_MEMBER_GROUP(&m) - 1);
+	else
 		prt_printf(out, "(none)");
-	}
 	prt_newline(out);
 
 	prt_printf(out, "UUID:\t");
Signature · 1 line
2.49.0