mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-08 14:23:19 +00:00
bcachefs: Fix bch2_btree_node_insert_fits()
It should be checking for the recently added flag btree_node_needs_rewrite. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
d3a2b5d809
commit
f805824220
@ -311,7 +311,7 @@ static inline void push_whiteout(struct bch_fs *c, struct btree *b,
|
||||
static inline bool bch2_btree_node_insert_fits(struct bch_fs *c,
|
||||
struct btree *b, unsigned u64s)
|
||||
{
|
||||
if (unlikely(btree_node_fake(b)))
|
||||
if (unlikely(btree_node_need_rewrite(b)))
|
||||
return false;
|
||||
|
||||
return u64s <= bch_btree_keys_u64s_remaining(c, b);
|
||||
|
@ -264,14 +264,12 @@ static inline int bch2_trans_journal_res_get(struct btree_trans *trans,
|
||||
static enum btree_insert_ret
|
||||
btree_key_can_insert(struct btree_trans *trans,
|
||||
struct btree_iter *iter,
|
||||
struct bkey_i *insert,
|
||||
unsigned u64s)
|
||||
{
|
||||
struct bch_fs *c = trans->c;
|
||||
struct btree *b = iter_l(iter)->b;
|
||||
|
||||
if (unlikely(btree_node_need_rewrite(b)) ||
|
||||
unlikely(u64s > bch_btree_keys_u64s_remaining(c, b)))
|
||||
if (!bch2_btree_node_insert_fits(c, b, u64s))
|
||||
return BTREE_INSERT_BTREE_NODE_FULL;
|
||||
|
||||
return BTREE_INSERT_OK;
|
||||
@ -280,7 +278,6 @@ btree_key_can_insert(struct btree_trans *trans,
|
||||
static enum btree_insert_ret
|
||||
btree_key_can_insert_cached(struct btree_trans *trans,
|
||||
struct btree_iter *iter,
|
||||
struct bkey_i *insert,
|
||||
unsigned u64s)
|
||||
{
|
||||
struct bkey_cached *ck = (void *) iter->l[0].b;
|
||||
@ -398,8 +395,8 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
|
||||
|
||||
u64s += i->k->k.u64s;
|
||||
ret = btree_iter_type(i->iter) != BTREE_ITER_CACHED
|
||||
? btree_key_can_insert(trans, i->iter, i->k, u64s)
|
||||
: btree_key_can_insert_cached(trans, i->iter, i->k, u64s);
|
||||
? btree_key_can_insert(trans, i->iter, u64s)
|
||||
: btree_key_can_insert_cached(trans, i->iter, u64s);
|
||||
if (ret) {
|
||||
*stopped_at = i;
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user