]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: async objs now support bch_write_ops
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 17 May 2025 23:54:39 +0000 (19:54 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:15:05 +0000 (20:15 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/async_objs.c
fs/bcachefs/async_objs_types.h
fs/bcachefs/io_write.c
fs/bcachefs/io_write_types.h
fs/bcachefs/move.c

index 57e2fe4214616824f4a54586ebce34e621ac3434..a7cd1f0f09647aa43790628e80b3ebcba531376c 100644 (file)
@@ -9,6 +9,7 @@
 #include "btree_io.h"
 #include "debug.h"
 #include "io_read.h"
+#include "io_write.h"
 
 #include <linux/debugfs.h>
 
@@ -22,6 +23,11 @@ static void rbio_obj_to_text(struct printbuf *out, void *obj)
        bch2_read_bio_to_text(out, obj);
 }
 
+static void write_op_obj_to_text(struct printbuf *out, void *obj)
+{
+       bch2_write_op_to_text(out, obj);
+}
+
 static void btree_read_bio_obj_to_text(struct printbuf *out, void *obj)
 {
        struct btree_read_bio *rbio = obj;
index 310a4f90f49b2165b066ecdab681a6470c7027e1..8d713c0f5841d7ebfee20486ad47d75d3d57eb1f 100644 (file)
@@ -5,6 +5,7 @@
 #define BCH_ASYNC_OBJ_LISTS()                                          \
        x(promote)                                                      \
        x(rbio)                                                         \
+       x(write_op)                                                     \
        x(btree_read_bio)                                               \
        x(btree_write_bio)
 
index 399df8fede8bda43e29eab1617daa58f72470f0e..fd4b89d6a96afdd20fc17ebb774bbf385031b88e 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "bcachefs.h"
 #include "alloc_foreground.h"
+#include "async_objs.h"
 #include "bkey_buf.h"
 #include "bset.h"
 #include "btree_update.h"
@@ -547,6 +548,7 @@ static void bch2_write_done(struct closure *cl)
 
        EBUG_ON(cl->parent);
        closure_debug_destroy(cl);
+       async_object_list_del(c, write_op, op->list_idx);
        if (op->end_io)
                op->end_io(op);
 }
@@ -1673,6 +1675,8 @@ CLOSURE_CALLBACK(bch2_write)
        BUG_ON(!op->write_point.v);
        BUG_ON(bkey_eq(op->pos, POS_MAX));
 
+       async_object_list_add(c, write_op, op, &op->list_idx);
+
        if (op->flags & BCH_WRITE_only_specified_devs)
                op->flags |= BCH_WRITE_alloc_nowait;
 
@@ -1717,6 +1721,7 @@ err:
        bch2_disk_reservation_put(c, &op->res);
 
        closure_debug_destroy(&op->cl);
+       async_object_list_del(c, write_op, op->list_idx);
        if (op->end_io)
                op->end_io(op);
 }
@@ -1750,6 +1755,7 @@ void bch2_write_op_to_text(struct printbuf *out, struct bch_write_op *op)
        prt_printf(out, "nr_replicas_required:\t%u\n", op->nr_replicas_required);
 
        prt_printf(out, "ref:\t%u\n", closure_nr_remaining(&op->cl));
+       prt_printf(out, "ret\t%s\n", bch2_err_str(op->error));
 
        printbuf_indent_sub(out, 2);
 }
index b4a6a44a45d07c5bddbd3f1da44bec928c36417d..5da4eb8bb6f6d8cf2f5039679d7b232e9fa02fc3 100644 (file)
@@ -71,6 +71,10 @@ struct bch_write_op {
        void                    (*end_io)(struct bch_write_op *);
        u64                     start_time;
 
+#ifdef CONFIG_BCACHEFS_ASYNC_OBJECT_LISTS
+       unsigned                list_idx;
+#endif
+
        unsigned                written; /* sectors */
        u16                     flags;
        s16                     error; /* dio write path expects it to hold -ERESTARTSYS... */
index 0dd3bec3acff9f2acfcafe4fffd14acacf89723b..79f4722621d599388f1183f9fe1d98c12e57600a 100644 (file)
@@ -109,7 +109,6 @@ static void move_write_done(struct bch_write_op *op)
                        struct printbuf buf = PRINTBUF;
 
                        bch2_write_op_to_text(&buf, op);
-                       prt_printf(&buf, "ret\t%s\n", bch2_err_str(op->error));
                        trace_io_move_write_fail(c, buf.buf);
                        printbuf_exit(&buf);
                }