Commit ece254b2 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: don't lose errors from iterators that have been freed

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2a039f1e
...@@ -983,6 +983,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans, ...@@ -983,6 +983,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans,
} }
if (unlikely(ret == -EIO)) { if (unlikely(ret == -EIO)) {
trans->error = true;
iter->flags |= BTREE_ITER_ERROR; iter->flags |= BTREE_ITER_ERROR;
iter->l[iter->level].b = BTREE_ITER_NOT_END; iter->l[iter->level].b = BTREE_ITER_NOT_END;
goto out; goto out;
...@@ -1943,7 +1944,7 @@ void bch2_trans_init(struct btree_trans *trans, struct bch_fs *c) ...@@ -1943,7 +1944,7 @@ void bch2_trans_init(struct btree_trans *trans, struct bch_fs *c)
int bch2_trans_exit(struct btree_trans *trans) int bch2_trans_exit(struct btree_trans *trans)
{ {
int ret = bch2_trans_unlock(trans); bch2_trans_unlock(trans);
kfree(trans->mem); kfree(trans->mem);
if (trans->used_mempool) if (trans->used_mempool)
...@@ -1952,5 +1953,6 @@ int bch2_trans_exit(struct btree_trans *trans) ...@@ -1952,5 +1953,6 @@ int bch2_trans_exit(struct btree_trans *trans)
kfree(trans->iters); kfree(trans->iters);
trans->mem = (void *) 0x1; trans->mem = (void *) 0x1;
trans->iters = (void *) 0x1; trans->iters = (void *) 0x1;
return ret;
return trans->error ? -EIO : 0;
} }
...@@ -280,6 +280,7 @@ struct btree_trans { ...@@ -280,6 +280,7 @@ struct btree_trans {
u8 nr_updates; u8 nr_updates;
u8 size; u8 size;
unsigned used_mempool:1; unsigned used_mempool:1;
unsigned error:1;
unsigned mem_top; unsigned mem_top;
unsigned mem_bytes; unsigned mem_bytes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment