bcachefs: bch2_ec_read_extent() now takes btree_trans
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 4 Nov 2023 04:25:52 +0000 (00:25 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Nov 2023 18:13:57 +0000 (13:13 -0500)
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 <kent.overstreet@linux.dev>
fs/bcachefs/ec.c
fs/bcachefs/ec.h
fs/bcachefs/io_read.c

index 62a3ccd71dc416d07ef5e25ba60ba5a2741948d3..ee6416b1c5765bb0321b94c2f14b31c352c76da3 100644 (file)
@@ -476,14 +476,10 @@ err:
        return ret;
 }
 
-static int get_stripe_key(struct bch_fs *c, u64 idx, struct ec_stripe_buf *stripe)
-{
-       return bch2_trans_run(c, get_stripe_key_trans(trans, idx, stripe));
-}
-
 /* recovery read path: */
-int bch2_ec_read_extent(struct bch_fs *c, struct bch_read_bio *rbio)
+int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
 {
+       struct bch_fs *c = trans->c;
        struct ec_stripe_buf *buf;
        struct closure cl;
        struct bch_stripe *v;
@@ -498,7 +494,7 @@ int bch2_ec_read_extent(struct bch_fs *c, struct bch_read_bio *rbio)
        if (!buf)
                return -BCH_ERR_ENOMEM_ec_read_extent;
 
-       ret = get_stripe_key(c, rbio->pick.ec.idx, buf);
+       ret = lockrestart_do(trans, get_stripe_key_trans(trans, rbio->pick.ec.idx, buf));
        if (ret) {
                bch_err_ratelimited(c,
                        "error doing reconstruct read: error %i looking up stripe", ret);
index 61c67aa0aa49a202a7e3d4ddee3531308b45a7e0..7d0237c9819f1a42561f5ec81512e1c4278d12fd 100644 (file)
@@ -199,7 +199,7 @@ struct ec_stripe_head {
        struct ec_stripe_new    *s;
 };
 
-int bch2_ec_read_extent(struct bch_fs *, struct bch_read_bio *);
+int bch2_ec_read_extent(struct btree_trans *, struct bch_read_bio *);
 
 void *bch2_writepoint_ec_buf(struct bch_fs *, struct write_point *);
 
index ae36fc485f5f1e018cddb728ed244d84a1459d05..a56ed553dc15e6c709c5fed992d0a5b097170703 100644 (file)
@@ -1025,7 +1025,7 @@ get_bio:
                trans->notrace_relock_fail = true;
        } else {
                /* Attempting reconstruct read: */
-               if (bch2_ec_read_extent(c, rbio)) {
+               if (bch2_ec_read_extent(trans, rbio)) {
                        bch2_rbio_error(rbio, READ_RETRY_AVOID, BLK_STS_IOERR);
                        goto out;
                }