summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/buckets.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-06 20:57:43 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-21 06:01:45 -0500
commite58f963cecbdb08f28334122afba93a7840beabc (patch)
tree0a5e9dd89fceeb1fbd8550958dfe44d1d7981cad /fs/bcachefs/buckets.h
parent38c23fb809f60bda1adfc431b18200b8f68c2025 (diff)
downloadlinux-e58f963cecbdb08f28334122afba93a7840beabc.tar.gz
linux-e58f963cecbdb08f28334122afba93a7840beabc.tar.bz2
linux-e58f963cecbdb08f28334122afba93a7840beabc.zip
bcachefs: helpers for printing data types
We need bounds checking since new versions may introduce new data types. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/buckets.h')
-rw-r--r--fs/bcachefs/buckets.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/bcachefs/buckets.h b/fs/bcachefs/buckets.h
index 2c95cc5d86be..2b1e907f2aca 100644
--- a/fs/bcachefs/buckets.h
+++ b/fs/bcachefs/buckets.h
@@ -385,6 +385,21 @@ static inline bool is_superblock_bucket(struct bch_dev *ca, u64 b)
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: */
static inline void bch2_disk_reservation_put(struct bch_fs *c,