Skip to content

Commit e3fd3fa

Browse files
author
Kent Overstreet
committed
bcachefs: Fix btree ID bitmasks
these should be 64 bit bitmasks, not 32 bit. Signed-off-by: Kent Overstreet <[email protected]>
1 parent d406545 commit e3fd3fa

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

fs/bcachefs/bcachefs_format.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,9 +1382,10 @@ enum btree_id {
13821382

13831383
/*
13841384
* Maximum number of btrees that we will _ever_ have under the current scheme,
1385-
* where we refer to them with bitfields
1385+
* where we refer to them with 64 bit bitfields - and we also need a bit for
1386+
* the interior btree node type:
13861387
*/
1387-
#define BTREE_ID_NR_MAX 64
1388+
#define BTREE_ID_NR_MAX 63
13881389

13891390
static inline bool btree_id_is_alloc(enum btree_id id)
13901391
{

fs/bcachefs/btree_types.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,13 @@ static inline bool btree_node_type_needs_gc(enum btree_node_type type)
761761

762762
static inline bool btree_node_type_is_extents(enum btree_node_type type)
763763
{
764-
const unsigned mask = 0
764+
const u64 mask = 0
765765
#define x(name, nr, flags, ...) |((!!((flags) & BTREE_ID_EXTENTS)) << (nr + 1))
766766
BCH_BTREE_IDS()
767767
#undef x
768768
;
769769

770-
return (1U << type) & mask;
770+
return BIT_ULL(type) & mask;
771771
}
772772

773773
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)
777777

778778
static inline bool btree_type_has_snapshots(enum btree_id id)
779779
{
780-
const unsigned mask = 0
780+
const u64 mask = 0
781781
#define x(name, nr, flags, ...) |((!!((flags) & BTREE_ID_SNAPSHOTS)) << nr)
782782
BCH_BTREE_IDS()
783783
#undef x
784784
;
785785

786-
return (1U << id) & mask;
786+
return BIT_ULL(id) & mask;
787787
}
788788

789789
static inline bool btree_type_has_snapshot_field(enum btree_id id)
790790
{
791-
const unsigned mask = 0
791+
const u64 mask = 0
792792
#define x(name, nr, flags, ...) |((!!((flags) & (BTREE_ID_SNAPSHOT_FIELD|BTREE_ID_SNAPSHOTS))) << nr)
793793
BCH_BTREE_IDS()
794794
#undef x
795795
;
796796

797-
return (1U << id) & mask;
797+
return BIT_ULL(id) & mask;
798798
}
799799

800800
static inline bool btree_type_has_ptrs(enum btree_id id)
801801
{
802-
const unsigned mask = 0
802+
const u64 mask = 0
803803
#define x(name, nr, flags, ...) |((!!((flags) & BTREE_ID_DATA)) << nr)
804804
BCH_BTREE_IDS()
805805
#undef x
806806
;
807807

808-
return (1U << id) & mask;
808+
return BIT_ULL(id) & mask;
809809
}
810810

811811
struct btree_root {

0 commit comments

Comments
 (0)