1

bcachefs: Apply workaround for too many btree iters to read path

Reading from cached data, which calls bch2_bucket_io_time_reset(), is
leading to transaction iterator overflows - this standardizes the
workaround.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2021-11-23 19:00:23 -05:00 committed by Kent Overstreet
parent 9ca4853b98
commit 084d42bbd6
4 changed files with 17 additions and 4 deletions

View File

@ -328,13 +328,19 @@ static inline struct bkey_s_c __bch2_btree_iter_peek(struct btree_iter *iter,
: bch2_btree_iter_peek(iter);
}
static inline int btree_trans_too_many_iters(struct btree_trans *trans)
{
return hweight64(trans->paths_allocated) > BTREE_ITER_MAX / 2
? -EINTR : 0;
}
static inline struct bkey_s_c
__bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
struct btree_iter *iter, unsigned flags)
{
struct bkey_s_c k;
while ((hweight64(trans->paths_allocated) > BTREE_ITER_MAX / 2) ||
while (btree_trans_too_many_iters(trans) ||
(k = __bch2_btree_iter_peek(iter, flags),
bkey_err(k) == -EINTR))
bch2_trans_begin(trans);

View File

@ -531,10 +531,9 @@ retry:
* read_target looks up subvolumes, we can overflow paths if the
* directory has many subvolumes in it
*/
if (hweight64(trans.paths_allocated) > BTREE_ITER_MAX / 2) {
ret = -EINTR;
ret = btree_trans_too_many_iters(&trans);
if (ret)
break;
}
}
bch2_trans_iter_exit(&trans, &iter);
err:

View File

@ -881,6 +881,10 @@ retry:
swap(rbio->bio.bi_iter.bi_size, bytes);
bio_advance(&rbio->bio, bytes);
ret = btree_trans_too_many_iters(trans);
if (ret)
break;
}
err:
bch2_trans_iter_exit(trans, &iter);

View File

@ -2395,6 +2395,10 @@ retry:
swap(bvec_iter.bi_size, bytes);
bio_advance_iter(&rbio->bio, &bvec_iter, bytes);
ret = btree_trans_too_many_iters(&trans);
if (ret)
break;
}
err:
bch2_trans_iter_exit(&trans, &iter);