summaryrefslogtreecommitdiff
path: root/fs/bcachefs/extents.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/extents.c')
-rw-r--r--fs/bcachefs/extents.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c
index b2f50e162784..59d2eaea9edf 100644
--- a/fs/bcachefs/extents.c
+++ b/fs/bcachefs/extents.c
@@ -1298,6 +1298,17 @@ extent_insert_advance_pos(struct extent_insert_state *s, struct bkey_s_c k)
return __extent_insert_advance_pos(s, next_pos, k);
}
+void bch2_extent_trim_atomic(struct bkey_i *k, struct btree_iter *iter)
+{
+ struct btree *b = iter->l[0].b;
+
+ BUG_ON(iter->uptodate > BTREE_ITER_NEED_PEEK);
+
+ bch2_cut_back(b->key.k.p, &k->k);
+
+ BUG_ON(bkey_cmp(bkey_start_pos(&k->k), b->data->min_key) < 0);
+}
+
enum btree_insert_ret
bch2_extent_can_insert(struct btree_insert *trans,
struct btree_insert_entry *insert,
@@ -1311,6 +1322,9 @@ bch2_extent_can_insert(struct btree_insert *trans,
struct bkey_s_c k;
int sectors;
+ BUG_ON(trans->flags & BTREE_INSERT_ATOMIC &&
+ !bch2_extent_is_atomic(&insert->k->k, insert->iter));
+
/*
* We avoid creating whiteouts whenever possible when deleting, but
* those optimizations mean we may potentially insert two whiteouts