]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bcachefs: Fix btree ID bitmasks
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 17 Jun 2024 13:28:01 +0000 (09:28 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 19 Jun 2024 22:27:23 +0000 (18:27 -0400)
these should be 64 bit bitmasks, not 32 bit.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs_format.h
fs/bcachefs/btree_types.h

index 90c12fe2a2cd3b030f0c6eb6aee1149262cc8dd1..5d3c5b5e34af80894d98565f0efde75a2e2e04f5 100644 (file)
@@ -1382,9 +1382,10 @@ enum btree_id {
 
 /*
  * Maximum number of btrees that we will _ever_ have under the current scheme,
- * where we refer to them with bitfields
+ * where we refer to them with 64 bit bitfields - and we also need a bit for
+ * the interior btree node type:
  */
-#define BTREE_ID_NR_MAX                64
+#define BTREE_ID_NR_MAX                63
 
 static inline bool btree_id_is_alloc(enum btree_id id)
 {
index d63db4fefe73433078634b75748f97083564985d..87f485e9c552d97dad450d1967bc4fe88f043406 100644 (file)
@@ -761,13 +761,13 @@ static inline bool btree_node_type_needs_gc(enum btree_node_type type)
 
 static inline bool btree_node_type_is_extents(enum btree_node_type type)
 {
-       const unsigned mask = 0
+       const u64 mask = 0
 #define x(name, nr, flags, ...)        |((!!((flags) & BTREE_ID_EXTENTS)) << (nr + 1))
        BCH_BTREE_IDS()
 #undef x
        ;
 
-       return (1U << type) & mask;
+       return BIT_ULL(type) & mask;
 }
 
 static inline bool btree_id_is_extents(enum btree_id btree)
@@ -777,35 +777,35 @@ static inline bool btree_id_is_extents(enum btree_id btree)
 
 static inline bool btree_type_has_snapshots(enum btree_id id)
 {
-       const unsigned mask = 0
+       const u64 mask = 0
 #define x(name, nr, flags, ...)        |((!!((flags) & BTREE_ID_SNAPSHOTS)) << nr)
        BCH_BTREE_IDS()
 #undef x
        ;
 
-       return (1U << id) & mask;
+       return BIT_ULL(id) & mask;
 }
 
 static inline bool btree_type_has_snapshot_field(enum btree_id id)
 {
-       const unsigned mask = 0
+       const u64 mask = 0
 #define x(name, nr, flags, ...)        |((!!((flags) & (BTREE_ID_SNAPSHOT_FIELD|BTREE_ID_SNAPSHOTS))) << nr)
        BCH_BTREE_IDS()
 #undef x
        ;
 
-       return (1U << id) & mask;
+       return BIT_ULL(id) & mask;
 }
 
 static inline bool btree_type_has_ptrs(enum btree_id id)
 {
-       const unsigned mask = 0
+       const u64 mask = 0
 #define x(name, nr, flags, ...)        |((!!((flags) & BTREE_ID_DATA)) << nr)
        BCH_BTREE_IDS()
 #undef x
        ;
 
-       return (1U << id) & mask;
+       return BIT_ULL(id) & mask;
 }
 
 struct btree_root {