summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_update_interior.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-12-30 22:37:25 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:36 +0300
commite3e464ac6d09269b19cea3dc32b626db44d0e6ba (patch)
tree7aafd377933161ed88573a5e3dab7ee3d8e0e06a /fs/bcachefs/btree_update_interior.h
parent57b0b3db475de6b724e4db3b827c00484cdde642 (diff)
downloadlinux-e3e464ac6d09269b19cea3dc32b626db44d0e6ba.tar.xz
bcachefs: Move extent overwrite handling out of core btree code
Ever since the btree code was first written, handling of overwriting existing extents - including partially overwriting and splittin existing extents - was handled as part of the core btree insert path. The modern transaction and iterator infrastructure didn't exist then, so that was the only way for it to be done. This patch moves that outside of the core btree code to a pass that runs at transaction commit time. This is a significant simplification to the btree code and overall reduction in code size, but more importantly it gets us much closer to the core btree code being completely independent of extents and is important prep work for snapshots. This introduces a new feature bit; the old and new extent update models are incompatible when the filesystem needs journal replay. 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.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h
index e3204f32cc68..f6aceed89427 100644
--- a/fs/bcachefs/btree_update_interior.h
+++ b/fs/bcachefs/btree_update_interior.h
@@ -303,18 +303,23 @@ static inline struct btree_node_entry *want_new_bset(struct bch_fs *c,
}
static inline void push_whiteout(struct bch_fs *c, struct btree *b,
- struct bkey_packed *k)
+ struct bpos pos)
{
- unsigned u64s = bkeyp_key_u64s(&b->format, k);
- struct bkey_packed *dst;
+ struct bkey_packed k;
- BUG_ON(u64s > bch_btree_keys_u64s_remaining(c, b));
+ BUG_ON(bch_btree_keys_u64s_remaining(c, b) < BKEY_U64s);
- 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;
+ if (!bkey_pack_pos(&k, pos, b)) {
+ struct bkey *u = (void *) &k;
+
+ bkey_init(u);
+ u->p = pos;
+ }
+
+ k.needs_whiteout = true;
+
+ b->whiteout_u64s += k.u64s;
+ bkey_copy(unwritten_whiteouts_start(c, b), &k);
}
/*