diff options
-rw-r--r-- | fs/bcachefs/bset.h | 11 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 66 | ||||
-rw-r--r-- | fs/bcachefs/btree_types.h | 73 | ||||
-rw-r--r-- | fs/bcachefs/move.h | 11 | ||||
-rw-r--r-- | fs/bcachefs/move_types.h | 14 |
5 files changed, 88 insertions, 87 deletions
diff --git a/fs/bcachefs/bset.h b/fs/bcachefs/bset.h index cc4ea5d87e4b..1b67825ccef7 100644 --- a/fs/bcachefs/bset.h +++ b/fs/bcachefs/bset.h @@ -157,9 +157,6 @@ static inline bool btree_keys_expensive_checks(const struct btree *b) #endif } -struct btree_node_iter; -struct btree_node_iter_set; - enum bset_aux_tree_type { BSET_NO_AUX_TREE, BSET_RO_AUX_TREE, @@ -420,14 +417,6 @@ static inline enum bch_extent_overlap bch2_extent_overlap(const struct bkey *k, /* Btree key iteration */ -struct btree_node_iter { - u8 is_extents; - - struct btree_node_iter_set { - u16 k, end; - } data[MAX_BSETS]; -}; - static inline void __bch2_btree_node_iter_init(struct btree_node_iter *iter, bool is_extents) { diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 95191ba2bc79..0097a2a20a18 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -4,72 +4,6 @@ #include <linux/dynamic_fault.h> #include "btree_types.h" -#include "bset.h" - -#define BTREE_ITER_SLOTS (1 << 0) -#define BTREE_ITER_INTENT (1 << 1) -#define BTREE_ITER_PREFETCH (1 << 2) -/* - * Used in bch2_btree_iter_traverse(), to indicate whether we're searching for - * @pos or the first key strictly greater than @pos - */ -#define BTREE_ITER_IS_EXTENTS (1 << 3) -/* - * indicates we need to call bch2_btree_iter_traverse() to revalidate iterator: - */ -#define BTREE_ITER_AT_END_OF_LEAF (1 << 4) -#define BTREE_ITER_ERROR (1 << 5) - -enum btree_iter_uptodate { - BTREE_ITER_UPTODATE = 0, - BTREE_ITER_NEED_PEEK = 1, - BTREE_ITER_NEED_RELOCK = 2, - BTREE_ITER_NEED_TRAVERSE = 3, - BTREE_ITER_END = 4, -}; - -/* - * @pos - iterator's current position - * @level - current btree depth - * @locks_want - btree level below which we start taking intent locks - * @nodes_locked - bitmask indicating which nodes in @nodes are locked - * @nodes_intent_locked - bitmask indicating which locks are intent locks - */ -struct btree_iter { - struct bch_fs *c; - struct bpos pos; - - u8 flags; - unsigned uptodate:4; - enum btree_id btree_id:4; - unsigned level:4, - locks_want:4, - nodes_locked:4, - nodes_intent_locked:4; - - struct btree_iter_level { - struct btree *b; - struct btree_node_iter iter; - } l[BTREE_MAX_DEPTH]; - - u32 lock_seq[BTREE_MAX_DEPTH]; - - /* - * Current unpacked key - so that bch2_btree_iter_next()/ - * bch2_btree_iter_next_slot() can correctly advance pos. - */ - struct bkey k; - - /* - * Circular linked list of linked iterators: linked iterators share - * locks (e.g. two linked iterators may have the same node intent - * locked, or read and write locked, at the same time), and insertions - * through one iterator won't invalidate the other linked iterators. - */ - - /* Must come last: */ - struct btree_iter *next; -}; static inline void btree_iter_set_dirty(struct btree_iter *iter, enum btree_iter_uptodate u) diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index 8854305d315e..f62c96d96226 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -176,6 +176,79 @@ struct btree_cache { struct closure_waitlist alloc_wait; }; +struct btree_node_iter { + u8 is_extents; + + struct btree_node_iter_set { + u16 k, end; + } data[MAX_BSETS]; +}; + +#define BTREE_ITER_SLOTS (1 << 0) +#define BTREE_ITER_INTENT (1 << 1) +#define BTREE_ITER_PREFETCH (1 << 2) +/* + * Used in bch2_btree_iter_traverse(), to indicate whether we're searching for + * @pos or the first key strictly greater than @pos + */ +#define BTREE_ITER_IS_EXTENTS (1 << 3) +/* + * indicates we need to call bch2_btree_iter_traverse() to revalidate iterator: + */ +#define BTREE_ITER_AT_END_OF_LEAF (1 << 4) +#define BTREE_ITER_ERROR (1 << 5) + +enum btree_iter_uptodate { + BTREE_ITER_UPTODATE = 0, + BTREE_ITER_NEED_PEEK = 1, + BTREE_ITER_NEED_RELOCK = 2, + BTREE_ITER_NEED_TRAVERSE = 3, + BTREE_ITER_END = 4, +}; + +/* + * @pos - iterator's current position + * @level - current btree depth + * @locks_want - btree level below which we start taking intent locks + * @nodes_locked - bitmask indicating which nodes in @nodes are locked + * @nodes_intent_locked - bitmask indicating which locks are intent locks + */ +struct btree_iter { + struct bch_fs *c; + struct bpos pos; + + u8 flags; + unsigned uptodate:4; + enum btree_id btree_id:4; + unsigned level:4, + locks_want:4, + nodes_locked:4, + nodes_intent_locked:4; + + struct btree_iter_level { + struct btree *b; + struct btree_node_iter iter; + } l[BTREE_MAX_DEPTH]; + + u32 lock_seq[BTREE_MAX_DEPTH]; + + /* + * Current unpacked key - so that bch2_btree_iter_next()/ + * bch2_btree_iter_next_slot() can correctly advance pos. + */ + struct bkey k; + + /* + * Circular linked list of linked iterators: linked iterators share + * locks (e.g. two linked iterators may have the same node intent + * locked, or read and write locked, at the same time), and insertions + * through one iterator won't invalidate the other linked iterators. + */ + + /* Must come last: */ + struct btree_iter *next; +}; + #define BTREE_FLAG(flag) \ static inline bool btree_node_ ## flag(struct btree *b) \ { return test_bit(BTREE_NODE_ ## flag, &b->flags); } \ diff --git a/fs/bcachefs/move.h b/fs/bcachefs/move.h index bc98f94bb23d..bc87e0670d92 100644 --- a/fs/bcachefs/move.h +++ b/fs/bcachefs/move.h @@ -4,6 +4,7 @@ #include "btree_iter.h" #include "buckets.h" #include "io_types.h" +#include "move_types.h" struct bch_read_bio; struct moving_context; @@ -48,16 +49,6 @@ typedef enum data_cmd (*move_pred_fn)(struct bch_fs *, void *, enum bkey_type, struct bkey_s_c_extent, struct bch_io_opts *, struct data_opts *); -struct bch_move_stats { - enum bch_data_type data_type; - struct btree_iter iter; - - atomic64_t keys_moved; - atomic64_t sectors_moved; - atomic64_t sectors_seen; - atomic64_t sectors_raced; -}; - int bch2_move_data(struct bch_fs *, struct bch_ratelimit *, struct write_point_specifier, struct bpos, struct bpos, diff --git a/fs/bcachefs/move_types.h b/fs/bcachefs/move_types.h new file mode 100644 index 000000000000..832542a879ab --- /dev/null +++ b/fs/bcachefs/move_types.h @@ -0,0 +1,14 @@ +#ifndef _BCACHEFS_MOVE_TYPES_H +#define _BCACHEFS_MOVE_TYPES_H + +struct bch_move_stats { + enum bch_data_type data_type; + struct btree_iter iter; + + atomic64_t keys_moved; + atomic64_t sectors_moved; + atomic64_t sectors_seen; + atomic64_t sectors_raced; +}; + +#endif /* _BCACHEFS_MOVE_TYPES_H */ |