]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: bch2_inum_offset_err_msg_trans() no longer handles transaction restarts
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 7 Feb 2025 18:37:30 +0000 (13:37 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 15 Mar 2025 01:02:12 +0000 (21:02 -0400)
we're starting to use error messages with paths in fsck_errors(), where
we do not want nested transaction restart handling, so let's prepare for
that.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/error.c
fs/bcachefs/error.h
fs/bcachefs/fs-io-buffered.c
fs/bcachefs/io_misc.c
fs/bcachefs/io_read.c

index 14cfcfa39590581bbb14fd8ac5096343c3942db1..c8fc58fab958cd680e5a779adbdd418a49595faf 100644 (file)
@@ -530,42 +530,33 @@ void bch2_flush_fsck_errs(struct bch_fs *c)
        mutex_unlock(&c->fsck_error_msgs_lock);
 }
 
-int bch2_inum_err_msg_trans(struct btree_trans *trans, struct printbuf *out, subvol_inum inum)
+int bch2_inum_offset_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
+                                   subvol_inum inum, u64 offset)
 {
        u32 restart_count = trans->restart_count;
        int ret = 0;
 
-       if (inum.subvol)
-               ret = lockrestart_do(trans, bch2_inum_to_path(trans, inum, out));
+       if (inum.subvol) {
+               ret = bch2_inum_to_path(trans, inum, out);
+               if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
+                       return ret;
+       }
        if (!inum.subvol || ret)
                prt_printf(out, "inum %llu:%llu", inum.subvol, inum.inum);
-
-       return trans_was_restarted(trans, restart_count);
-}
-
-int bch2_inum_offset_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
-                                   subvol_inum inum, u64 offset)
-{
-       int ret = bch2_inum_err_msg_trans(trans, out, inum);
        prt_printf(out, " offset %llu: ", offset);
-       return ret;
-}
 
-void bch2_inum_err_msg(struct bch_fs *c, struct printbuf *out, subvol_inum inum)
-{
-       bch2_trans_run(c, bch2_inum_err_msg_trans(trans, out, inum));
+       return trans_was_restarted(trans, restart_count);
 }
 
 void bch2_inum_offset_err_msg(struct bch_fs *c, struct printbuf *out,
                              subvol_inum inum, u64 offset)
 {
-       bch2_trans_run(c, bch2_inum_offset_err_msg_trans(trans, out, inum, offset));
+       bch2_trans_do(c, bch2_inum_offset_err_msg_trans(trans, out, inum, offset));
 }
 
-int bch2_inum_snap_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
-                                struct bpos pos)
+int bch2_inum_snap_offset_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
+                                       struct bpos pos)
 {
-       u32 restart_count = trans->restart_count;
        struct bch_fs *c = trans->c;
        int ret = 0;
 
@@ -577,18 +568,15 @@ int bch2_inum_snap_err_msg_trans(struct btree_trans *trans, struct printbuf *out
                .inum   = pos.inode,
        };
 
-       if (inum.subvol)
-               ret = lockrestart_do(trans, bch2_inum_to_path(trans, inum, out));
+       if (inum.subvol) {
+               ret = bch2_inum_to_path(trans, inum, out);
+               if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
+                       return ret;
+       }
+
        if (!inum.subvol || ret)
                prt_printf(out, "inum %llu:%u", pos.inode, pos.snapshot);
 
-       return trans_was_restarted(trans, restart_count);
-}
-
-int bch2_inum_snap_offset_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
-                                       struct bpos pos)
-{
-       int ret = bch2_inum_snap_err_msg_trans(trans, out, pos);
        prt_printf(out, " offset %llu: ", pos.offset << 8);
-       return ret;
+       return 0;
 }
index 95cf48a31dbf27c00368b2f24a61192e305c0b4e..76da0e88cee8b6b9e126d25ac63e43d311b09682 100644 (file)
@@ -238,13 +238,10 @@ void bch2_io_error(struct bch_dev *, enum bch_member_error_type);
        _ret;                                                           \
 })
 
-int bch2_inum_err_msg_trans(struct btree_trans *, struct printbuf *, subvol_inum);
 int bch2_inum_offset_err_msg_trans(struct btree_trans *, struct printbuf *, subvol_inum, u64);
 
-void bch2_inum_err_msg(struct bch_fs *, struct printbuf *, subvol_inum);
 void bch2_inum_offset_err_msg(struct bch_fs *, struct printbuf *, subvol_inum, u64);
 
-int bch2_inum_snap_err_msg_trans(struct btree_trans *, struct printbuf *, struct bpos);
 int bch2_inum_snap_offset_err_msg_trans(struct btree_trans *, struct printbuf *, struct bpos);
 
 #endif /* _BCACHEFS_ERROR_H */
index 0ec2eebdeffa54284b70eb2290f376990bff3413..5ab1c73c8d4c9986fa3556a9362296e6b6df1b06 100644 (file)
@@ -240,7 +240,8 @@ err:
 
        if (ret) {
                struct printbuf buf = PRINTBUF;
-               bch2_inum_offset_err_msg_trans(trans, &buf, inum, iter.pos.offset << 9);
+               lockrestart_do(trans,
+                       bch2_inum_offset_err_msg_trans(trans, &buf, inum, iter.pos.offset << 9));
                prt_printf(&buf, "read error %i from btree lookup", ret);
                bch_err_ratelimited(c, "%s", buf.buf);
                printbuf_exit(&buf);
index 5353979117b0a44c8b4c54bed82846631c944558..6b842c8d21bed0573bb572ab3b4cdac29b9f1f5b 100644 (file)
@@ -115,7 +115,8 @@ err:
                bch2_increment_clock(c, sectors_allocated, WRITE);
        if (should_print_err(ret)) {
                struct printbuf buf = PRINTBUF;
-               bch2_inum_offset_err_msg_trans(trans, &buf, inum, iter->pos.offset << 9);
+               lockrestart_do(trans,
+                       bch2_inum_offset_err_msg_trans(trans, &buf, inum, iter->pos.offset << 9));
                prt_printf(&buf, "fallocate error: %s", bch2_err_str(ret));
                bch_err_ratelimited(c, "%s", buf.buf);
                printbuf_exit(&buf);
index 33642c5bb9c704ba5a77285e2dbb5814c887ec29..dcd5a2aee0f12f496e1d688bfdb4b71d3d905567 100644 (file)
@@ -329,9 +329,10 @@ nopromote:
 static int bch2_read_err_msg_trans(struct btree_trans *trans, struct printbuf *out,
                                   struct bch_read_bio *rbio, struct bpos read_pos)
 {
-       return bch2_inum_offset_err_msg_trans(trans, out,
-               (subvol_inum) { rbio->subvol, read_pos.inode },
-               read_pos.offset << 9);
+       return lockrestart_do(trans,
+               bch2_inum_offset_err_msg_trans(trans, out,
+                               (subvol_inum) { rbio->subvol, read_pos.inode },
+                               read_pos.offset << 9));
 }
 
 static void bch2_read_err_msg(struct bch_fs *c, struct printbuf *out,
@@ -1281,7 +1282,9 @@ err:
 
        if (ret) {
                struct printbuf buf = PRINTBUF;
-               bch2_inum_offset_err_msg_trans(trans, &buf, inum, bvec_iter.bi_sector << 9);
+               lockrestart_do(trans,
+                       bch2_inum_offset_err_msg_trans(trans, &buf, inum,
+                                                      bvec_iter.bi_sector << 9));
                prt_printf(&buf, "read error %i from btree lookup", ret);
                bch_err_ratelimited(c, "%s", buf.buf);
                printbuf_exit(&buf);