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

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2019-04-04 21:28:16 -04:00 committed by Kent Overstreet
parent 2a039f1ee4
commit ece254b258
2 changed files with 5 additions and 2 deletions

View File

@ -983,6 +983,7 @@ static int __btree_iter_traverse_all(struct btree_trans *trans,
}
if (unlikely(ret == -EIO)) {
trans->error = true;
iter->flags |= BTREE_ITER_ERROR;
iter->l[iter->level].b = BTREE_ITER_NOT_END;
goto out;
@ -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 ret = bch2_trans_unlock(trans);
bch2_trans_unlock(trans);
kfree(trans->mem);
if (trans->used_mempool)
@ -1952,5 +1953,6 @@ int bch2_trans_exit(struct btree_trans *trans)
kfree(trans->iters);
trans->mem = (void *) 0x1;
trans->iters = (void *) 0x1;
return ret;
return trans->error ? -EIO : 0;
}

View File

@ -280,6 +280,7 @@ struct btree_trans {
u8 nr_updates;
u8 size;
unsigned used_mempool:1;
unsigned error:1;
unsigned mem_top;
unsigned mem_bytes;