diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-02-05 00:26:03 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-02-05 00:31:32 -0500 |
commit | 99adc23cf6260a8e5b237f498119ee163d8f71f6 (patch) | |
tree | 1b1488e62f2b94c0a1a1f8e2c1a5dceba0037612 /libbcachefs/btree_io.h | |
parent | 27c0b6fbc5ffe0979436a6436187d1bf952e9a24 (diff) |
Update bcachefs sources to 0e765bc37c bcachefs: foreground merging of interior btree nodes
Diffstat (limited to 'libbcachefs/btree_io.h')
-rw-r--r-- | libbcachefs/btree_io.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libbcachefs/btree_io.h b/libbcachefs/btree_io.h index 66053d53..f2790716 100644 --- a/libbcachefs/btree_io.h +++ b/libbcachefs/btree_io.h @@ -57,21 +57,23 @@ enum compact_mode { bool __bch2_compact_whiteouts(struct bch_fs *, struct btree *, enum compact_mode); +static inline unsigned should_compact_bset_lazy(struct btree *b, struct bset_tree *t) +{ + unsigned bset_u64s = le16_to_cpu(bset(b, t)->u64s); + unsigned dead_u64s = bset_u64s - b->nr.bset_u64s[t - b->set]; + + return dead_u64s > 128 && dead_u64s * 3 > bset_u64s; +} + static inline bool bch2_maybe_compact_whiteouts(struct bch_fs *c, struct btree *b) { struct bset_tree *t; - for_each_bset(b, t) { - unsigned live_u64s = b->nr.bset_u64s[t - b->set]; - unsigned bset_u64s = le16_to_cpu(bset(b, t)->u64s); - - if (live_u64s * 4 < bset_u64s * 3) - goto compact; - } + for_each_bset(b, t) + if (should_compact_bset_lazy(b, t)) + return __bch2_compact_whiteouts(c, b, COMPACT_LAZY); return false; -compact: - return __bch2_compact_whiteouts(c, b, COMPACT_LAZY); } void bch2_btree_sort_into(struct bch_fs *, struct btree *, struct btree *); @@ -134,6 +136,9 @@ do { \ } \ } while (0) +void bch2_btree_flush_all_reads(struct bch_fs *); +void bch2_btree_flush_all_writes(struct bch_fs *); void bch2_btree_verify_flushed(struct bch_fs *); +ssize_t bch2_dirty_btree_nodes_print(struct bch_fs *, char *); #endif /* _BCACHEFS_BTREE_IO_H */ |