Skip to content

Commit aa98266

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_ec_read_extent() now takes btree_trans
We're not supposed to have more than one btree_trans at a time in a given thread - that causes recursive locking deadlocks. Signed-off-by: Kent Overstreet <[email protected]>
1 parent da4aa3b commit aa98266

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

fs/bcachefs/ec.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -476,14 +476,10 @@ static int get_stripe_key_trans(struct btree_trans *trans, u64 idx,
476476
return ret;
477477
}
478478

479-
static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *stripe)
480-
{
481-
return bch2_trans_run(c, get_stripe_key_trans(trans, idx, stripe));
482-
}
483-
484479
/* recovery read path: */
485-
int bch2_ec_read_extent(struct bch_fs *c, struct bch_read_bio *rbio)
480+
int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
486481
{
482+
struct bch_fs *c = trans->c;
487483
struct ec_stripe_buf *buf;
488484
struct closure cl;
489485
struct bch_stripe *v;
@@ -498,7 +494,7 @@ int bch2_ec_read_extent(struct bch_fs *c, struct bch_read_bio *rbio)
498494
if (!buf)
499495
return -BCH_ERR_ENOMEM_ec_read_extent;
500496

501-
ret = get_stripe_key(c, rbio->pick.ec.idx, buf);
497+
ret = lockrestart_do(trans, get_stripe_key_trans(trans, rbio->pick.ec.idx, buf));
502498
if (ret) {
503499
bch_err_ratelimited(c,
504500
"error doing reconstruct read: error %i looking up stripe", ret);

fs/bcachefs/ec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ struct ec_stripe_head {
199199
struct ec_stripe_new *s;
200200
};
201201

202-
int bch2_ec_read_extent(struct bch_fs *, struct bch_read_bio *);
202+
int bch2_ec_read_extent(struct btree_trans *, struct bch_read_bio *);
203203

204204
void *bch2_writepoint_ec_buf(struct bch_fs *, struct write_point *);
205205

fs/bcachefs/io_read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ int __bch2_read_extent(struct btree_trans *trans, struct bch_read_bio *orig,
10251025
trans->notrace_relock_fail = true;
10261026
} else {
10271027
/* Attempting reconstruct read: */
1028-
if (bch2_ec_read_extent(c, rbio)) {
1028+
if (bch2_ec_read_extent(trans, rbio)) {
10291029
bch2_rbio_error(rbio, READ_RETRY_AVOID, BLK_STS_IOERR);
10301030
goto out;
10311031
}

0 commit comments

Comments
 (0)