summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_update_interior.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-11-29 14:08:51 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:32 -0400
commitc9bebae65eade6529f9d3068a6da42fc56664bfe (patch)
treeebf834840eb1ad862f684aae12ed3cb15f5d9388 /fs/bcachefs/btree_update_interior.h
parent183797e31d43ce2fbfc596ff3f4d034f1ba144d0 (diff)
downloadlinux-stable-c9bebae65eade6529f9d3068a6da42fc56664bfe.tar.gz
linux-stable-c9bebae65eade6529f9d3068a6da42fc56664bfe.tar.bz2
linux-stable-c9bebae65eade6529f9d3068a6da42fc56664bfe.zip
bcachefs: Whiteout changes
More prep work for snapshots: extents will soon be using KEY_TYPE_deleted for whiteouts, with 0 size. But we wen't be able to keep these whiteouts with the rest of the extents in the btree node, due to sorting invariants breaking. We can deal with this by immediately moving the new whiteouts to the unwritten whiteouts area - this just means those whiteouts won't be sorted, so we need new code to sort them prior to merging them with the rest of the keys to be written. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_update_interior.h')
-rw-r--r--fs/bcachefs/btree_update_interior.h29
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h
index 85f1320fa7b1..8f9d4a0b68ea 100644
--- a/fs/bcachefs/btree_update_interior.h
+++ b/fs/bcachefs/btree_update_interior.h
@@ -251,8 +251,7 @@ static inline ssize_t __bch_btree_u64s_remaining(struct bch_fs *c,
void *end)
{
ssize_t used = bset_byte_offset(b, end) / sizeof(u64) +
- b->whiteout_u64s +
- b->uncompacted_whiteout_u64s;
+ b->whiteout_u64s;
ssize_t total = c->opts.btree_node_size << 6;
return total - used;
@@ -302,23 +301,19 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c,
return NULL;
}
-static inline void unreserve_whiteout(struct btree *b, struct bkey_packed *k)
+static inline void push_whiteout(struct bch_fs *c, struct btree *b,
+ struct bkey_packed *k)
{
- if (bkey_written(b, k)) {
- EBUG_ON(b->uncompacted_whiteout_u64s <
- bkeyp_key_u64s(&b->format, k));
- b->uncompacted_whiteout_u64s -=
- bkeyp_key_u64s(&b->format, k);
- }
-}
+ unsigned u64s = bkeyp_key_u64s(&b->format, k);
+ struct bkey_packed *dst;
-static inline void reserve_whiteout(struct btree *b, struct bkey_packed *k)
-{
- if (bkey_written(b, k)) {
- BUG_ON(!k->needs_whiteout);
- b->uncompacted_whiteout_u64s +=
- bkeyp_key_u64s(&b->format, k);
- }
+ BUG_ON(u64s > bch_btree_keys_u64s_remaining(c, b));
+
+ b->whiteout_u64s += bkeyp_key_u64s(&b->format, k);
+ dst = unwritten_whiteouts_start(c, b);
+ memcpy_u64s(dst, k, u64s);
+ dst->u64s = u64s;
+ dst->type = KEY_TYPE_deleted;
}
/*