summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_io.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-12-13 21:08:37 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:32 +0300
commitc297a763e2dcf34fe94f74c633957306d28fe138 (patch)
treeee87324ee2109252ce58a7a746f35a42461c78c6 /fs/bcachefs/btree_io.h
parentc9bebae65eade6529f9d3068a6da42fc56664bfe (diff)
downloadlinux-c297a763e2dcf34fe94f74c633957306d28fe138.tar.xz
bcachefs: Refactor whiteouts compaction
The whiteout compaction path - as opposed to just dropping whiteouts - is now only needed for extents, and soon will only be needed for extent btree nodes in the old format. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_io.h')
-rw-r--r--fs/bcachefs/btree_io.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/bcachefs/btree_io.h b/fs/bcachefs/btree_io.h
index 69516ec34b89..43fa8a6dbee5 100644
--- a/fs/bcachefs/btree_io.h
+++ b/fs/bcachefs/btree_io.h
@@ -54,16 +54,17 @@ static inline bool btree_node_may_write(struct btree *b)
enum compact_mode {
COMPACT_LAZY,
- COMPACT_WRITTEN,
- COMPACT_WRITTEN_NO_WRITE_LOCK,
+ COMPACT_ALL,
};
-bool __bch2_compact_whiteouts(struct bch_fs *, struct btree *, 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)
+static inline bool should_compact_bset_lazy(struct btree *b,
+ struct bset_tree *t)
{
unsigned total_u64s = bset_u64s(t);
- unsigned dead_u64s = total_u64s - b->nr.bset_u64s[t - b->set];
+ unsigned dead_u64s = bset_dead_u64s(b, t);
return dead_u64s > 64 && dead_u64s * 3 > total_u64s;
}
@@ -74,7 +75,7 @@ static inline bool bch2_maybe_compact_whiteouts(struct bch_fs *c, struct btree *
for_each_bset(b, t)
if (should_compact_bset_lazy(b, t))
- return __bch2_compact_whiteouts(c, b, COMPACT_LAZY);
+ return bch2_compact_whiteouts(c, b, COMPACT_LAZY);
return false;
}