1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_BBPOS_H
3 #define _BCACHEFS_BBPOS_H
5 #include "bkey_methods.h"
12 static inline struct bbpos BBPOS(enum btree_id btree, struct bpos pos)
14 return (struct bbpos) { btree, pos };
17 #define BBPOS_MIN BBPOS(0, POS_MIN)
18 #define BBPOS_MAX BBPOS(BTREE_ID_NR - 1, POS_MAX)
20 static inline int bbpos_cmp(struct bbpos l, struct bbpos r)
22 return cmp_int(l.btree, r.btree) ?: bpos_cmp(l.pos, r.pos);
25 static inline struct bbpos bbpos_successor(struct bbpos pos)
27 if (bpos_cmp(pos.pos, SPOS_MAX)) {
28 pos.pos = bpos_successor(pos.pos);
32 if (pos.btree != BTREE_ID_NR) {
41 static inline void bch2_bbpos_to_text(struct printbuf *out, struct bbpos pos)
43 prt_str(out, bch2_btree_ids[pos.btree]);
45 bch2_bpos_to_text(out, pos.pos);
48 #endif /* _BCACHEFS_BBPOS_H */