1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _BCACHEFS_BBPOS_H
3 #define _BCACHEFS_BBPOS_H
5 #include "bkey_methods.h"
6 #include "btree_cache.h"
13 static inline struct bbpos BBPOS(enum btree_id btree, struct bpos pos)
15 return (struct bbpos) { btree, pos };
18 #define BBPOS_MIN BBPOS(0, POS_MIN)
19 #define BBPOS_MAX BBPOS(BTREE_ID_NR - 1, POS_MAX)
21 static inline int bbpos_cmp(struct bbpos l, struct bbpos r)
23 return cmp_int(l.btree, r.btree) ?: bpos_cmp(l.pos, r.pos);
26 static inline struct bbpos bbpos_successor(struct bbpos pos)
28 if (bpos_cmp(pos.pos, SPOS_MAX)) {
29 pos.pos = bpos_successor(pos.pos);
33 if (pos.btree != BTREE_ID_NR) {
42 static inline void bch2_bbpos_to_text(struct printbuf *out, struct bbpos pos)
44 prt_str(out, bch2_btree_id_str(pos.btree));
46 bch2_bpos_to_text(out, pos.pos);
49 #endif /* _BCACHEFS_BBPOS_H */