Skip to content

Commit 7fdc3fa

Browse files
author
Kent Overstreet
committed
bcachefs: Log original key being moved in data updates
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>
1 parent edaed8e commit 7fdc3fa

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

fs/bcachefs/data_update.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
#include <linux/ioprio.h>
2424

25+
static const char * const bch2_data_update_type_strs[] = {
26+
#define x(t, n, ...) [n] = #t,
27+
BCH_DATA_UPDATE_TYPES()
28+
#undef x
29+
NULL
30+
};
31+
2532
static void bkey_put_dev_refs(struct bch_fs *c, struct bkey_s_c k)
2633
{
2734
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,
181188
container_of(op, struct data_update, op);
182189
struct keylist *keys = &op->insert_keys;
183190
struct bkey_buf _new, _insert;
191+
struct printbuf journal_msg = PRINTBUF;
184192
int ret = 0;
185193

186194
bch2_bkey_buf_init(&_new);
@@ -372,7 +380,12 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
372380
printbuf_exit(&buf);
373381
}
374382

375-
ret = bch2_insert_snapshot_whiteouts(trans, m->btree_id,
383+
printbuf_reset(&journal_msg);
384+
prt_str(&journal_msg, bch2_data_update_type_strs[m->type]);
385+
386+
ret = bch2_trans_log_msg(trans, &journal_msg) ?:
387+
bch2_trans_log_bkey(trans, m->btree_id, 0, m->k.k) ?:
388+
bch2_insert_snapshot_whiteouts(trans, m->btree_id,
376389
k.k->p, bkey_start_pos(&insert->k)) ?:
377390
bch2_insert_snapshot_whiteouts(trans, m->btree_id,
378391
k.k->p, insert->k.p) ?:
@@ -417,6 +430,7 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
417430
goto next;
418431
}
419432
out:
433+
printbuf_exit(&journal_msg);
420434
bch2_trans_iter_exit(trans, &iter);
421435
bch2_bkey_buf_exit(&_insert, c);
422436
bch2_bkey_buf_exit(&_new, c);
@@ -577,6 +591,9 @@ void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c,
577591

578592
void bch2_data_update_to_text(struct printbuf *out, struct data_update *m)
579593
{
594+
prt_str(out, bch2_data_update_type_strs[m->type]);
595+
prt_newline(out);
596+
580597
bch2_data_update_opts_to_text(out, m->op.c, &m->op.opts, &m->data_opts);
581598
prt_newline(out);
582599

@@ -738,6 +755,9 @@ int bch2_data_update_init(struct btree_trans *trans,
738755

739756
bch2_bkey_buf_init(&m->k);
740757
bch2_bkey_buf_reassemble(&m->k, c, k);
758+
m->type = data_opts.btree_insert_flags & BCH_WATERMARK_copygc
759+
? BCH_DATA_UPDATE_copygc
760+
: BCH_DATA_UPDATE_rebalance;
741761
m->btree_id = btree_id;
742762
m->data_opts = data_opts;
743763
m->ctxt = ctxt;

fs/bcachefs/data_update.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,19 @@ struct data_update_opts {
2424
void bch2_data_update_opts_to_text(struct printbuf *, struct bch_fs *,
2525
struct bch_io_opts *, struct data_update_opts *);
2626

27+
#define BCH_DATA_UPDATE_TYPES() \
28+
x(copygc, 0) \
29+
x(rebalance, 1) \
30+
x(promote, 2)
31+
32+
enum bch_data_update_types {
33+
#define x(n, id) BCH_DATA_UPDATE_##n = id,
34+
BCH_DATA_UPDATE_TYPES()
35+
#undef x
36+
};
37+
2738
struct data_update {
39+
enum bch_data_update_types type;
2840
/* extent being updated: */
2941
bool read_done;
3042
enum btree_id btree_id;

fs/bcachefs/io_read.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static struct bch_read_bio *__promote_alloc(struct btree_trans *trans,
259259
&orig->opts,
260260
update_opts,
261261
btree_id, k);
262+
op->write.type = BCH_DATA_UPDATE_promote;
262263
/*
263264
* possible errors: -BCH_ERR_nocow_lock_blocked,
264265
* -BCH_ERR_ENOSPC_disk_reservation:

0 commit comments

Comments
 (0)