bcachefs: Fix BCH_SB_ERRS() so we can reorder

BCH_SB_ERRS() has a field for the actual enum val so that we can reorder
to reorganize, but the way BCH_SB_ERR_MAX was defined didn't allow for
this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2024-09-26 15:30:17 -04:00
parent 5612daafb7
commit 8d65b15f8d
5 changed files with 9 additions and 8 deletions

View file

@ -776,7 +776,7 @@ struct bch_fs {
unsigned nsec_per_time_unit; unsigned nsec_per_time_unit;
u64 features; u64 features;
u64 compat; u64 compat;
unsigned long errors_silent[BITS_TO_LONGS(BCH_SB_ERR_MAX)]; unsigned long errors_silent[BITS_TO_LONGS(BCH_FSCK_ERR_MAX)];
u64 btrees_lost_data; u64 btrees_lost_data;
} sb; } sb;

View file

@ -312,8 +312,7 @@ static void bch2_sb_downgrade_to_text(struct printbuf *out, struct bch_sb *sb,
if (!first) if (!first)
prt_char(out, ','); prt_char(out, ',');
first = false; first = false;
unsigned e = le16_to_cpu(i->errors[j]); bch2_sb_error_id_to_text(out, le16_to_cpu(i->errors[j]));
prt_str(out, e < BCH_SB_ERR_MAX ? bch2_sb_error_strs[e] : "(unknown)");
} }
prt_newline(out); prt_newline(out);
} }
@ -401,7 +400,7 @@ void bch2_sb_set_downgrade(struct bch_fs *c, unsigned new_minor, unsigned old_mi
for (unsigned j = 0; j < le16_to_cpu(i->nr_errors); j++) { for (unsigned j = 0; j < le16_to_cpu(i->nr_errors); j++) {
unsigned e = le16_to_cpu(i->errors[j]); unsigned e = le16_to_cpu(i->errors[j]);
if (e < BCH_SB_ERR_MAX) if (e < BCH_FSCK_ERR_MAX)
__set_bit(e, c->sb.errors_silent); __set_bit(e, c->sb.errors_silent);
if (e < sizeof(ext->errors_silent) * 8) if (e < sizeof(ext->errors_silent) * 8)
__set_bit_le64(e, ext->errors_silent); __set_bit_le64(e, ext->errors_silent);

View file

@ -7,12 +7,12 @@
const char * const bch2_sb_error_strs[] = { const char * const bch2_sb_error_strs[] = {
#define x(t, n, ...) [n] = #t, #define x(t, n, ...) [n] = #t,
BCH_SB_ERRS() BCH_SB_ERRS()
NULL #undef x
}; };
static void bch2_sb_error_id_to_text(struct printbuf *out, enum bch_sb_error_id id) void bch2_sb_error_id_to_text(struct printbuf *out, enum bch_sb_error_id id)
{ {
if (id < BCH_SB_ERR_MAX) if (id < BCH_FSCK_ERR_MAX)
prt_str(out, bch2_sb_error_strs[id]); prt_str(out, bch2_sb_error_strs[id]);
else else
prt_printf(out, "(unknown error %u)", id); prt_printf(out, "(unknown error %u)", id);

View file

@ -6,6 +6,8 @@
extern const char * const bch2_sb_error_strs[]; extern const char * const bch2_sb_error_strs[];
void bch2_sb_error_id_to_text(struct printbuf *, enum bch_sb_error_id);
extern const struct bch_sb_field_ops bch_sb_field_ops_errors; extern const struct bch_sb_field_ops bch_sb_field_ops_errors;
void bch2_sb_error_count(struct bch_fs *, enum bch_sb_error_id); void bch2_sb_error_count(struct bch_fs *, enum bch_sb_error_id);

View file

@ -292,12 +292,12 @@ enum bch_fsck_flags {
x(accounting_key_replicas_nr_devs_0, 278, FSCK_AUTOFIX) \ x(accounting_key_replicas_nr_devs_0, 278, FSCK_AUTOFIX) \
x(accounting_key_replicas_nr_required_bad, 279, FSCK_AUTOFIX) \ x(accounting_key_replicas_nr_required_bad, 279, FSCK_AUTOFIX) \
x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \ x(accounting_key_replicas_devs_unsorted, 280, FSCK_AUTOFIX) \
x(MAX, 281, 0)
enum bch_sb_error_id { enum bch_sb_error_id {
#define x(t, n, ...) BCH_FSCK_ERR_##t = n, #define x(t, n, ...) BCH_FSCK_ERR_##t = n,
BCH_SB_ERRS() BCH_SB_ERRS()
#undef x #undef x
BCH_SB_ERR_MAX
}; };
struct bch_sb_field_errors { struct bch_sb_field_errors {