Commit 084d42bb authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 9ca4853b
......@@ -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);
......
......@@ -531,10 +531,9 @@ int bch2_readdir(struct bch_fs *c, subvol_inum inum, struct dir_context *ctx)
* 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:
......
......@@ -881,6 +881,10 @@ static void bchfs_read(struct btree_trans *trans,
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);
......
......@@ -2395,6 +2395,10 @@ void __bch2_read(struct bch_fs *c, struct bch_read_bio *rbio,
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);
......
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