]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: Log original key being moved in data updates
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 30 Mar 2025 20:57:21 +0000 (16:57 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 30 Mar 2025 22:25:12 +0000 (18:25 -0400)
There's something going on with the data move path; log the original key
being moved for debugging.

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

index 0ec273daccb7d8f6ba0214a3eeb2d02fb7ed0f6f..fe400dfc5d7630687c4705f059678d52c5101766 100644 (file)
 
 #include <linux/ioprio.h>
 
+static const char * const bch2_data_update_type_strs[] = {
+#define x(t, n, ...) [n] = #t,
+       BCH_DATA_UPDATE_TYPES()
+#undef x
+       NULL
+};
+
 static void bkey_put_dev_refs(struct bch_fs *c, struct bkey_s_c k)
 {
        struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
@@ -181,6 +188,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
                container_of(op, struct data_update, op);
        struct keylist *keys = &op->insert_keys;
        struct bkey_buf _new, _insert;
+       struct printbuf journal_msg = PRINTBUF;
        int ret = 0;
 
        bch2_bkey_buf_init(&_new);
@@ -372,7 +380,12 @@ restart_drop_extra_replicas:
                        printbuf_exit(&buf);
                }
 
-               ret =   bch2_insert_snapshot_whiteouts(trans, m->btree_id,
+               printbuf_reset(&journal_msg);
+               prt_str(&journal_msg, bch2_data_update_type_strs[m->type]);
+
+               ret =   bch2_trans_log_msg(trans, &journal_msg) ?:
+                       bch2_trans_log_bkey(trans, m->btree_id, 0, m->k.k) ?:
+                       bch2_insert_snapshot_whiteouts(trans, m->btree_id,
                                                k.k->p, bkey_start_pos(&insert->k)) ?:
                        bch2_insert_snapshot_whiteouts(trans, m->btree_id,
                                                k.k->p, insert->k.p) ?:
@@ -417,6 +430,7 @@ nowork:
                goto next;
        }
 out:
+       printbuf_exit(&journal_msg);
        bch2_trans_iter_exit(trans, &iter);
        bch2_bkey_buf_exit(&_insert, c);
        bch2_bkey_buf_exit(&_new, c);
@@ -577,6 +591,9 @@ void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c,
 
 void bch2_data_update_to_text(struct printbuf *out, struct data_update *m)
 {
+       prt_str(out, bch2_data_update_type_strs[m->type]);
+       prt_newline(out);
+
        bch2_data_update_opts_to_text(out, m->op.c, &m->op.opts, &m->data_opts);
        prt_newline(out);
 
@@ -738,6 +755,9 @@ int bch2_data_update_init(struct btree_trans *trans,
 
        bch2_bkey_buf_init(&m->k);
        bch2_bkey_buf_reassemble(&m->k, c, k);
+       m->type         = data_opts.btree_insert_flags & BCH_WATERMARK_copygc
+               ? BCH_DATA_UPDATE_copygc
+               : BCH_DATA_UPDATE_rebalance;
        m->btree_id     = btree_id;
        m->data_opts    = data_opts;
        m->ctxt         = ctxt;
index c194cbbf5b5101bff76c0ce08960a9b9694490e9..ed05125867da5216f519a3a120385cda7c6739c8 100644 (file)
@@ -24,7 +24,19 @@ struct data_update_opts {
 void bch2_data_update_opts_to_text(struct printbuf *, struct bch_fs *,
                                   struct bch_io_opts *, struct data_update_opts *);
 
+#define BCH_DATA_UPDATE_TYPES()                \
+       x(copygc,       0)              \
+       x(rebalance,    1)              \
+       x(promote,      2)
+
+enum bch_data_update_types {
+#define x(n, id)       BCH_DATA_UPDATE_##n = id,
+       BCH_DATA_UPDATE_TYPES()
+#undef x
+};
+
 struct data_update {
+       enum bch_data_update_types type;
        /* extent being updated: */
        bool                    read_done;
        enum btree_id           btree_id;
index fafd00a3d6c955b590878e1110d74651096f2cec..fd01e67b3e843ef697201832a5d148b20586c3d8 100644 (file)
@@ -259,6 +259,7 @@ static struct bch_read_bio *__promote_alloc(struct btree_trans *trans,
                        &orig->opts,
                        update_opts,
                        btree_id, k);
+       op->write.type = BCH_DATA_UPDATE_promote;
        /*
         * possible errors: -BCH_ERR_nocow_lock_blocked,
         * -BCH_ERR_ENOSPC_disk_reservation: