Commit e58f963c authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: helpers for printing data types

We need bounds checking since new versions may introduce new data types.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 38c23fb8
...@@ -273,7 +273,7 @@ int bch2_alloc_v4_invalid(struct bch_fs *c, struct bkey_s_c k, ...@@ -273,7 +273,7 @@ int bch2_alloc_v4_invalid(struct bch_fs *c, struct bkey_s_c k,
bkey_fsck_err_on(!bch2_bucket_sectors_dirty(*a.v), bkey_fsck_err_on(!bch2_bucket_sectors_dirty(*a.v),
c, err, alloc_key_dirty_sectors_0, c, err, alloc_key_dirty_sectors_0,
"data_type %s but dirty_sectors==0", "data_type %s but dirty_sectors==0",
bch2_data_types[a.v->data_type]); bch2_data_type_str(a.v->data_type));
break; break;
case BCH_DATA_cached: case BCH_DATA_cached:
bkey_fsck_err_on(!a.v->cached_sectors || bkey_fsck_err_on(!a.v->cached_sectors ||
...@@ -325,11 +325,8 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c ...@@ -325,11 +325,8 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c
prt_newline(out); prt_newline(out);
printbuf_indent_add(out, 2); printbuf_indent_add(out, 2);
prt_printf(out, "gen %u oldest_gen %u data_type %s", prt_printf(out, "gen %u oldest_gen %u data_type ", a->gen, a->oldest_gen);
a->gen, a->oldest_gen, bch2_prt_data_type(out, a->data_type);
a->data_type < BCH_DATA_NR
? bch2_data_types[a->data_type]
: "(invalid data type)");
prt_newline(out); prt_newline(out);
prt_printf(out, "journal_seq %llu", a->journal_seq); prt_printf(out, "journal_seq %llu", a->journal_seq);
prt_newline(out); prt_newline(out);
......
...@@ -1525,10 +1525,11 @@ static void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, str ...@@ -1525,10 +1525,11 @@ static void bch2_open_bucket_to_text(struct printbuf *out, struct bch_fs *c, str
unsigned data_type = ob->data_type; unsigned data_type = ob->data_type;
barrier(); /* READ_ONCE() doesn't work on bitfields */ barrier(); /* READ_ONCE() doesn't work on bitfields */
prt_printf(out, "%zu ref %u %s %u:%llu gen %u allocated %u/%u", prt_printf(out, "%zu ref %u ",
ob - c->open_buckets, ob - c->open_buckets,
atomic_read(&ob->pin), atomic_read(&ob->pin));
data_type < BCH_DATA_NR ? bch2_data_types[data_type] : "invalid data type", bch2_prt_data_type(out, data_type);
prt_printf(out, " %u:%llu gen %u allocated %u/%u",
ob->dev, ob->bucket, ob->gen, ob->dev, ob->bucket, ob->gen,
ca->mi.bucket_size - ob->sectors_free, ca->mi.bucket_size); ca->mi.bucket_size - ob->sectors_free, ca->mi.bucket_size);
if (ob->ec) if (ob->ec)
......
...@@ -597,7 +597,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -597,7 +597,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
"bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n" "bucket %u:%zu data type %s ptr gen %u missing in alloc btree\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_type_str(ptr_data_type(k->k, &p.ptr)),
p.ptr.gen, p.ptr.gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) { bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) {
...@@ -615,7 +615,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -615,7 +615,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
"bucket %u:%zu data type %s ptr gen in the future: %u > %u\n" "bucket %u:%zu data type %s ptr gen in the future: %u > %u\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_type_str(ptr_data_type(k->k, &p.ptr)),
p.ptr.gen, g->gen, p.ptr.gen, g->gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) { bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) {
...@@ -637,7 +637,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -637,7 +637,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
"bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n" "bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen, p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), g->gen,
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_type_str(ptr_data_type(k->k, &p.ptr)),
p.ptr.gen, p.ptr.gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) bch2_bkey_val_to_text(&buf, c, *k), buf.buf))))
...@@ -649,7 +649,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -649,7 +649,7 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
"bucket %u:%zu data type %s stale dirty ptr: %u < %u\n" "bucket %u:%zu data type %s stale dirty ptr: %u < %u\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[ptr_data_type(k->k, &p.ptr)], bch2_data_type_str(ptr_data_type(k->k, &p.ptr)),
p.ptr.gen, g->gen, p.ptr.gen, g->gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf)))) bch2_bkey_val_to_text(&buf, c, *k), buf.buf))))
...@@ -664,8 +664,8 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id ...@@ -664,8 +664,8 @@ static int bch2_check_fix_ptrs(struct btree_trans *trans, enum btree_id btree_id
"bucket %u:%zu different types of data in same bucket: %s, %s\n" "bucket %u:%zu different types of data in same bucket: %s, %s\n"
"while marking %s", "while marking %s",
p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr), p.ptr.dev, PTR_BUCKET_NR(ca, &p.ptr),
bch2_data_types[g->data_type], bch2_data_type_str(g->data_type),
bch2_data_types[data_type], bch2_data_type_str(data_type),
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) { bch2_bkey_val_to_text(&buf, c, *k), buf.buf))) {
if (data_type == BCH_DATA_btree) { if (data_type == BCH_DATA_btree) {
...@@ -1238,11 +1238,11 @@ static int bch2_gc_done(struct bch_fs *c, ...@@ -1238,11 +1238,11 @@ static int bch2_gc_done(struct bch_fs *c,
for (i = 0; i < BCH_DATA_NR; i++) { for (i = 0; i < BCH_DATA_NR; i++) {
copy_dev_field(dev_usage_buckets_wrong, copy_dev_field(dev_usage_buckets_wrong,
d[i].buckets, "%s buckets", bch2_data_types[i]); d[i].buckets, "%s buckets", bch2_data_type_str(i));
copy_dev_field(dev_usage_sectors_wrong, copy_dev_field(dev_usage_sectors_wrong,
d[i].sectors, "%s sectors", bch2_data_types[i]); d[i].sectors, "%s sectors", bch2_data_type_str(i));
copy_dev_field(dev_usage_fragmented_wrong, copy_dev_field(dev_usage_fragmented_wrong,
d[i].fragmented, "%s fragmented", bch2_data_types[i]); d[i].fragmented, "%s fragmented", bch2_data_type_str(i));
} }
} }
...@@ -1417,8 +1417,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -1417,8 +1417,8 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
": got %s, should be %s", ": got %s, should be %s",
iter->pos.inode, iter->pos.offset, iter->pos.inode, iter->pos.offset,
gc.gen, gc.gen,
bch2_data_types[new.data_type], bch2_data_type_str(new.data_type),
bch2_data_types[gc.data_type])) bch2_data_type_str(gc.data_type)))
new.data_type = gc.data_type; new.data_type = gc.data_type;
#define copy_bucket_field(_errtype, _f) \ #define copy_bucket_field(_errtype, _f) \
...@@ -1428,7 +1428,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans, ...@@ -1428,7 +1428,7 @@ static int bch2_alloc_write_key(struct btree_trans *trans,
": got %u, should be %u", \ ": got %u, should be %u", \
iter->pos.inode, iter->pos.offset, \ iter->pos.inode, iter->pos.offset, \
gc.gen, \ gc.gen, \
bch2_data_types[gc.data_type], \ bch2_data_type_str(gc.data_type), \
new._f, gc._f)) \ new._f, gc._f)) \
new._f = gc._f; \ new._f = gc._f; \
......
...@@ -284,7 +284,7 @@ void bch2_dev_usage_to_text(struct printbuf *out, struct bch_dev_usage *usage) ...@@ -284,7 +284,7 @@ void bch2_dev_usage_to_text(struct printbuf *out, struct bch_dev_usage *usage)
prt_newline(out); prt_newline(out);
for (unsigned i = 0; i < BCH_DATA_NR; i++) { for (unsigned i = 0; i < BCH_DATA_NR; i++) {
prt_str(out, bch2_data_types[i]); bch2_prt_data_type(out, i);
prt_tab(out); prt_tab(out);
prt_u64(out, usage->d[i].buckets); prt_u64(out, usage->d[i].buckets);
prt_tab_rjust(out); prt_tab_rjust(out);
...@@ -523,8 +523,8 @@ int bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca, ...@@ -523,8 +523,8 @@ int bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca,
if (bch2_fs_inconsistent_on(g->data_type && if (bch2_fs_inconsistent_on(g->data_type &&
g->data_type != data_type, c, g->data_type != data_type, c,
"different types of data in same bucket: %s, %s", "different types of data in same bucket: %s, %s",
bch2_data_types[g->data_type], bch2_data_type_str(g->data_type),
bch2_data_types[data_type])) { bch2_data_type_str(data_type))) {
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
...@@ -532,7 +532,7 @@ int bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca, ...@@ -532,7 +532,7 @@ int bch2_mark_metadata_bucket(struct bch_fs *c, struct bch_dev *ca,
if (bch2_fs_inconsistent_on((u64) g->dirty_sectors + sectors > ca->mi.bucket_size, c, if (bch2_fs_inconsistent_on((u64) g->dirty_sectors + sectors > ca->mi.bucket_size, c,
"bucket %u:%zu gen %u data type %s sector count overflow: %u + %u > bucket size", "bucket %u:%zu gen %u data type %s sector count overflow: %u + %u > bucket size",
ca->dev_idx, b, g->gen, ca->dev_idx, b, g->gen,
bch2_data_types[g->data_type ?: data_type], bch2_data_type_str(g->data_type ?: data_type),
g->dirty_sectors, sectors)) { g->dirty_sectors, sectors)) {
ret = -EIO; ret = -EIO;
goto err; goto err;
...@@ -575,7 +575,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans, ...@@ -575,7 +575,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans,
"bucket %u:%zu gen %u data type %s: ptr gen %u newer than bucket gen\n" "bucket %u:%zu gen %u data type %s: ptr gen %u newer than bucket gen\n"
"while marking %s", "while marking %s",
ptr->dev, bucket_nr, b_gen, ptr->dev, bucket_nr, b_gen,
bch2_data_types[bucket_data_type ?: ptr_data_type], bch2_data_type_str(bucket_data_type ?: ptr_data_type),
ptr->gen, ptr->gen,
(bch2_bkey_val_to_text(&buf, c, k), buf.buf)); (bch2_bkey_val_to_text(&buf, c, k), buf.buf));
ret = -EIO; ret = -EIO;
...@@ -588,7 +588,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans, ...@@ -588,7 +588,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans,
"bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n" "bucket %u:%zu gen %u data type %s: ptr gen %u too stale\n"
"while marking %s", "while marking %s",
ptr->dev, bucket_nr, b_gen, ptr->dev, bucket_nr, b_gen,
bch2_data_types[bucket_data_type ?: ptr_data_type], bch2_data_type_str(bucket_data_type ?: ptr_data_type),
ptr->gen, ptr->gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, k), buf.buf)); bch2_bkey_val_to_text(&buf, c, k), buf.buf));
...@@ -603,7 +603,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans, ...@@ -603,7 +603,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans,
"while marking %s", "while marking %s",
ptr->dev, bucket_nr, b_gen, ptr->dev, bucket_nr, b_gen,
*bucket_gen(ca, bucket_nr), *bucket_gen(ca, bucket_nr),
bch2_data_types[bucket_data_type ?: ptr_data_type], bch2_data_type_str(bucket_data_type ?: ptr_data_type),
ptr->gen, ptr->gen,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, k), buf.buf)); bch2_bkey_val_to_text(&buf, c, k), buf.buf));
...@@ -624,8 +624,8 @@ int bch2_check_bucket_ref(struct btree_trans *trans, ...@@ -624,8 +624,8 @@ int bch2_check_bucket_ref(struct btree_trans *trans,
"bucket %u:%zu gen %u different types of data in same bucket: %s, %s\n" "bucket %u:%zu gen %u different types of data in same bucket: %s, %s\n"
"while marking %s", "while marking %s",
ptr->dev, bucket_nr, b_gen, ptr->dev, bucket_nr, b_gen,
bch2_data_types[bucket_data_type], bch2_data_type_str(bucket_data_type),
bch2_data_types[ptr_data_type], bch2_data_type_str(ptr_data_type),
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, k), buf.buf)); bch2_bkey_val_to_text(&buf, c, k), buf.buf));
ret = -EIO; ret = -EIO;
...@@ -638,7 +638,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans, ...@@ -638,7 +638,7 @@ int bch2_check_bucket_ref(struct btree_trans *trans,
"bucket %u:%zu gen %u data type %s sector count overflow: %u + %lli > U32_MAX\n" "bucket %u:%zu gen %u data type %s sector count overflow: %u + %lli > U32_MAX\n"
"while marking %s", "while marking %s",
ptr->dev, bucket_nr, b_gen, ptr->dev, bucket_nr, b_gen,
bch2_data_types[bucket_data_type ?: ptr_data_type], bch2_data_type_str(bucket_data_type ?: ptr_data_type),
bucket_sectors, sectors, bucket_sectors, sectors,
(printbuf_reset(&buf), (printbuf_reset(&buf),
bch2_bkey_val_to_text(&buf, c, k), buf.buf)); bch2_bkey_val_to_text(&buf, c, k), buf.buf));
...@@ -1130,9 +1130,9 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans, ...@@ -1130,9 +1130,9 @@ static int __bch2_trans_mark_metadata_bucket(struct btree_trans *trans,
"bucket %llu:%llu gen %u different types of data in same bucket: %s, %s\n" "bucket %llu:%llu gen %u different types of data in same bucket: %s, %s\n"
"while marking %s", "while marking %s",
iter.pos.inode, iter.pos.offset, a->v.gen, iter.pos.inode, iter.pos.offset, a->v.gen,
bch2_data_types[a->v.data_type], bch2_data_type_str(a->v.data_type),
bch2_data_types[type], bch2_data_type_str(type),
bch2_data_types[type]); bch2_data_type_str(type));
ret = -EIO; ret = -EIO;
goto err; goto err;
} }
......
...@@ -385,6 +385,21 @@ static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b) ...@@ -385,6 +385,21 @@ static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b)
return false; return false;
} }
static inline const char *bch2_data_type_str(enum bch_data_type type)
{
return type < BCH_DATA_NR
? __bch2_data_types[type]
: "(invalid data type)";
}
static inline void bch2_prt_data_type(struct printbuf *out, enum bch_data_type type)
{
if (type < BCH_DATA_NR)
prt_str(out, __bch2_data_types[type]);
else
prt_printf(out, "(invalid data type %u)", type);
}
/* disk reservations: */ /* disk reservations: */
static inline void bch2_disk_reservation_put(struct bch_fs *c, static inline void bch2_disk_reservation_put(struct bch_fs *c,
......
...@@ -190,7 +190,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans, ...@@ -190,7 +190,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
a->v.stripe_redundancy, trans, a->v.stripe_redundancy, trans,
"bucket %llu:%llu gen %u data type %s dirty_sectors %u: multiple stripes using same bucket (%u, %llu)", "bucket %llu:%llu gen %u data type %s dirty_sectors %u: multiple stripes using same bucket (%u, %llu)",
iter.pos.inode, iter.pos.offset, a->v.gen, iter.pos.inode, iter.pos.offset, a->v.gen,
bch2_data_types[a->v.data_type], bch2_data_type_str(a->v.data_type),
a->v.dirty_sectors, a->v.dirty_sectors,
a->v.stripe, s.k->p.offset)) { a->v.stripe, s.k->p.offset)) {
ret = -EIO; ret = -EIO;
...@@ -200,7 +200,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans, ...@@ -200,7 +200,7 @@ static int bch2_trans_mark_stripe_bucket(struct btree_trans *trans,
if (bch2_trans_inconsistent_on(data_type && a->v.dirty_sectors, trans, if (bch2_trans_inconsistent_on(data_type && a->v.dirty_sectors, trans,
"bucket %llu:%llu gen %u data type %s dirty_sectors %u: data already in stripe bucket %llu", "bucket %llu:%llu gen %u data type %s dirty_sectors %u: data already in stripe bucket %llu",
iter.pos.inode, iter.pos.offset, a->v.gen, iter.pos.inode, iter.pos.offset, a->v.gen,
bch2_data_types[a->v.data_type], bch2_data_type_str(a->v.data_type),
a->v.dirty_sectors, a->v.dirty_sectors,
s.k->p.offset)) { s.k->p.offset)) {
ret = -EIO; ret = -EIO;
......
...@@ -683,10 +683,7 @@ static void journal_entry_dev_usage_to_text(struct printbuf *out, struct bch_fs ...@@ -683,10 +683,7 @@ static void journal_entry_dev_usage_to_text(struct printbuf *out, struct bch_fs
prt_printf(out, "dev=%u", le32_to_cpu(u->dev)); prt_printf(out, "dev=%u", le32_to_cpu(u->dev));
for (i = 0; i < nr_types; i++) { for (i = 0; i < nr_types; i++) {
if (i < BCH_DATA_NR) bch2_prt_data_type(out, i);
prt_printf(out, " %s", bch2_data_types[i]);
else
prt_printf(out, " (unknown data type %u)", i);
prt_printf(out, ": buckets=%llu sectors=%llu fragmented=%llu", prt_printf(out, ": buckets=%llu sectors=%llu fragmented=%llu",
le64_to_cpu(u->d[i].buckets), le64_to_cpu(u->d[i].buckets),
le64_to_cpu(u->d[i].sectors), le64_to_cpu(u->d[i].sectors),
......
...@@ -1083,9 +1083,9 @@ int bch2_data_job(struct bch_fs *c, ...@@ -1083,9 +1083,9 @@ int bch2_data_job(struct bch_fs *c,
void bch2_move_stats_to_text(struct printbuf *out, struct bch_move_stats *stats) void bch2_move_stats_to_text(struct printbuf *out, struct bch_move_stats *stats)
{ {
prt_printf(out, "%s: data type=%s pos=", prt_printf(out, "%s: data type==", stats->name);
stats->name, bch2_prt_data_type(out, stats->data_type);
bch2_data_types[stats->data_type]); prt_str(out, " pos=");
bch2_bbpos_to_text(out, stats->pos); bch2_bbpos_to_text(out, stats->pos);
prt_newline(out); prt_newline(out);
printbuf_indent_add(out, 2); printbuf_indent_add(out, 2);
......
...@@ -72,7 +72,7 @@ const char * const bch2_str_hash_opts[] = { ...@@ -72,7 +72,7 @@ const char * const bch2_str_hash_opts[] = {
NULL NULL
}; };
const char * const bch2_data_types[] = { const char * const __bch2_data_types[] = {
BCH_DATA_TYPES() BCH_DATA_TYPES()
NULL NULL
}; };
......
...@@ -22,7 +22,7 @@ extern const char * const bch2_compression_types[]; ...@@ -22,7 +22,7 @@ extern const char * const bch2_compression_types[];
extern const char * const bch2_compression_opts[]; extern const char * const bch2_compression_opts[];
extern const char * const bch2_str_hash_types[]; extern const char * const bch2_str_hash_types[];
extern const char * const bch2_str_hash_opts[]; extern const char * const bch2_str_hash_opts[];
extern const char * const bch2_data_types[]; extern const char * const __bch2_data_types[];
extern const char * const bch2_member_states[]; extern const char * const bch2_member_states[];
extern const char * const bch2_jset_entry_types[]; extern const char * const bch2_jset_entry_types[];
extern const char * const bch2_fs_usage_types[]; extern const char * const bch2_fs_usage_types[];
......
...@@ -39,15 +39,10 @@ static void bch2_cpu_replicas_sort(struct bch_replicas_cpu *r) ...@@ -39,15 +39,10 @@ static void bch2_cpu_replicas_sort(struct bch_replicas_cpu *r)
static void bch2_replicas_entry_v0_to_text(struct printbuf *out, static void bch2_replicas_entry_v0_to_text(struct printbuf *out,
struct bch_replicas_entry_v0 *e) struct bch_replicas_entry_v0 *e)
{ {
unsigned i; bch2_prt_data_type(out, e->data_type);
if (e->data_type < BCH_DATA_NR)
prt_printf(out, "%s", bch2_data_types[e->data_type]);
else
prt_printf(out, "(invalid data type %u)", e->data_type);
prt_printf(out, ": %u [", e->nr_devs); prt_printf(out, ": %u [", e->nr_devs);
for (i = 0; i < e->nr_devs; i++) for (unsigned i = 0; i < e->nr_devs; i++)
prt_printf(out, i ? " %u" : "%u", e->devs[i]); prt_printf(out, i ? " %u" : "%u", e->devs[i]);
prt_printf(out, "]"); prt_printf(out, "]");
} }
...@@ -55,15 +50,10 @@ static void bch2_replicas_entry_v0_to_text(struct printbuf *out, ...@@ -55,15 +50,10 @@ static void bch2_replicas_entry_v0_to_text(struct printbuf *out,
void bch2_replicas_entry_to_text(struct printbuf *out, void bch2_replicas_entry_to_text(struct printbuf *out,
struct bch_replicas_entry_v1 *e) struct bch_replicas_entry_v1 *e)
{ {
unsigned i; bch2_prt_data_type(out, e->data_type);
if (e->data_type < BCH_DATA_NR)
prt_printf(out, "%s", bch2_data_types[e->data_type]);
else
prt_printf(out, "(invalid data type %u)", e->data_type);
prt_printf(out, ": %u/%u [", e->nr_required, e->nr_devs); prt_printf(out, ": %u/%u [", e->nr_required, e->nr_devs);
for (i = 0; i < e->nr_devs; i++) for (unsigned i = 0; i < e->nr_devs; i++)
prt_printf(out, i ? " %u" : "%u", e->devs[i]); prt_printf(out, i ? " %u" : "%u", e->devs[i]);
prt_printf(out, "]"); prt_printf(out, "]");
} }
......
...@@ -251,7 +251,7 @@ static void member_to_text(struct printbuf *out, ...@@ -251,7 +251,7 @@ static void member_to_text(struct printbuf *out,
prt_printf(out, "Data allowed:"); prt_printf(out, "Data allowed:");
prt_tab(out); prt_tab(out);
if (BCH_MEMBER_DATA_ALLOWED(&m)) if (BCH_MEMBER_DATA_ALLOWED(&m))
prt_bitflags(out, bch2_data_types, BCH_MEMBER_DATA_ALLOWED(&m)); prt_bitflags(out, __bch2_data_types, BCH_MEMBER_DATA_ALLOWED(&m));
else else
prt_printf(out, "(none)"); prt_printf(out, "(none)");
prt_newline(out); prt_newline(out);
...@@ -259,7 +259,7 @@ static void member_to_text(struct printbuf *out, ...@@ -259,7 +259,7 @@ static void member_to_text(struct printbuf *out,
prt_printf(out, "Has data:"); prt_printf(out, "Has data:");
prt_tab(out); prt_tab(out);
if (data_have) if (data_have)
prt_bitflags(out, bch2_data_types, data_have); prt_bitflags(out, __bch2_data_types, data_have);
else else
prt_printf(out, "(none)"); prt_printf(out, "(none)");
prt_newline(out); prt_newline(out);
......
...@@ -1625,7 +1625,7 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) ...@@ -1625,7 +1625,7 @@ int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
if (data) { if (data) {
struct printbuf data_has = PRINTBUF; struct printbuf data_has = PRINTBUF;
prt_bitflags(&data_has, bch2_data_types, data); prt_bitflags(&data_has, __bch2_data_types, data);
bch_err(ca, "Remove failed, still has data (%s)", data_has.buf); bch_err(ca, "Remove failed, still has data (%s)", data_has.buf);
printbuf_exit(&data_has); printbuf_exit(&data_has);
ret = -EBUSY; ret = -EBUSY;
......
...@@ -883,7 +883,7 @@ static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca) ...@@ -883,7 +883,7 @@ static void dev_io_done_to_text(struct printbuf *out, struct bch_dev *ca)
for (i = 1; i < BCH_DATA_NR; i++) for (i = 1; i < BCH_DATA_NR; i++)
prt_printf(out, "%-12s:%12llu\n", prt_printf(out, "%-12s:%12llu\n",
bch2_data_types[i], bch2_data_type_str(i),
percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9); percpu_u64_get(&ca->io_done->sectors[rw][i]) << 9);
} }
} }
...@@ -908,7 +908,7 @@ SHOW(bch2_dev) ...@@ -908,7 +908,7 @@ SHOW(bch2_dev)
} }
if (attr == &sysfs_has_data) { if (attr == &sysfs_has_data) {
prt_bitflags(out, bch2_data_types, bch2_dev_has_data(c, ca)); prt_bitflags(out, __bch2_data_types, bch2_dev_has_data(c, ca));
prt_char(out, '\n'); prt_char(out, '\n');
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment