diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-06-12 22:45:56 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:06 +0300 |
commit | a49e9a0589d1828af787bacf0a1e18eca7facb88 (patch) | |
tree | 03b7f574add84daaf5fb042a39e0547afb52fd1f /fs/bcachefs/extent_update.c | |
parent | 90d22a660a4ed5e1500602f15edcb91ab38a1e7c (diff) | |
download | linux-a49e9a0589d1828af787bacf0a1e18eca7facb88.tar.xz |
bcachefs: Fix null ptr deref when splitting compressed extents
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/extent_update.c')
-rw-r--r-- | fs/bcachefs/extent_update.c | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/fs/bcachefs/extent_update.c b/fs/bcachefs/extent_update.c index bb4b2b4352e0..ef4aaf1c30ed 100644 --- a/fs/bcachefs/extent_update.c +++ b/fs/bcachefs/extent_update.c @@ -173,38 +173,3 @@ int bch2_extent_is_atomic(struct bkey_i *k, struct btree_iter *iter) return !bkey_cmp(end, k->k.p); } - -enum btree_insert_ret -bch2_extent_can_insert(struct btree_trans *trans, - struct btree_iter *iter, - struct bkey_i *insert) -{ - struct bkey_s_c k; - int ret, sectors; - - k = bch2_btree_iter_peek_slot(iter); - ret = bkey_err(k); - if (ret) - return ret; - - /* Check if we're splitting a compressed extent: */ - - if (bkey_cmp(bkey_start_pos(&insert->k), bkey_start_pos(k.k)) > 0 && - bkey_cmp(insert->k.p, k.k->p) < 0 && - (sectors = bch2_bkey_sectors_compressed(k))) { - int flags = trans->flags & BTREE_INSERT_NOFAIL - ? BCH_DISK_RESERVATION_NOFAIL : 0; - - switch (bch2_disk_reservation_add(trans->c, trans->disk_res, - sectors, flags)) { - case 0: - break; - case -ENOSPC: - return BTREE_INSERT_ENOSPC; - default: - BUG(); - } - } - - return BTREE_INSERT_OK; -} |