diff options
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 18 | ||||
-rw-r--r-- | fs/bcachefs/btree_update.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 11 |
3 files changed, 13 insertions, 18 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 3feaac33aaff..6110d4ce4e5f 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -706,7 +706,6 @@ static int bch2_check_discard_freespace_key(struct btree_trans *trans, struct bch_alloc_v4 a; u64 genbits; struct bpos pos; - struct bkey_i *update; enum bch_data_type state = iter->btree_id == BTREE_ID_need_discard ? BCH_DATA_need_discard : BCH_DATA_free; @@ -756,21 +755,8 @@ fsck_err: printbuf_exit(&buf); return ret; delete: - if (iter->btree_id == BTREE_ID_freespace) { - /* should probably add a helper for deleting extents */ - update = bch2_trans_kmalloc(trans, sizeof(*update)); - ret = PTR_ERR_OR_ZERO(update); - if (ret) - goto err; - - bkey_init(&update->k); - update->k.p = iter->pos; - bch2_key_resize(&update->k, 1); - - ret = bch2_trans_update(trans, iter, update, 0); - } else { - ret = bch2_btree_delete_at(trans, iter, 0); - } + ret = bch2_btree_delete_extent_at(trans, iter, + iter->btree_id == BTREE_ID_freespace ? 1 : 0, 0); goto out; } diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h index ad13b0739a68..a40f3460fd62 100644 --- a/fs/bcachefs/btree_update.h +++ b/fs/bcachefs/btree_update.h @@ -51,6 +51,8 @@ enum btree_insert_flags { #define BCH_HASH_SET_MUST_CREATE (1 << __BCH_HASH_SET_MUST_CREATE) #define BCH_HASH_SET_MUST_REPLACE (1 << __BCH_HASH_SET_MUST_REPLACE) +int bch2_btree_delete_extent_at(struct btree_trans *, struct btree_iter *, + unsigned, unsigned); int bch2_btree_delete_at(struct btree_trans *, struct btree_iter *, unsigned); int __bch2_btree_insert(struct btree_trans *, enum btree_id, struct bkey_i *); diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index c502e96748d8..449fbae585cb 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1697,8 +1697,8 @@ int bch2_btree_insert(struct bch_fs *c, enum btree_id id, __bch2_btree_insert(&trans, id, k)); } -int bch2_btree_delete_at(struct btree_trans *trans, - struct btree_iter *iter, unsigned update_flags) +int bch2_btree_delete_extent_at(struct btree_trans *trans, struct btree_iter *iter, + unsigned len, unsigned update_flags) { struct bkey_i *k; @@ -1708,9 +1708,16 @@ int bch2_btree_delete_at(struct btree_trans *trans, bkey_init(&k->k); k->k.p = iter->pos; + bch2_key_resize(&k->k, len); return bch2_trans_update(trans, iter, k, update_flags); } +int bch2_btree_delete_at(struct btree_trans *trans, + struct btree_iter *iter, unsigned update_flags) +{ + return bch2_btree_delete_extent_at(trans, iter, 0, update_flags); +} + int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, struct bpos start, struct bpos end, unsigned update_flags, |