Skip to content

Commit c7e351b

Browse files
author
Kent Overstreet
committed
bcachefs: Add range being updated to btree_update_to_text()
We had a deadlock during recovery where interior btree updates became wedged and all open_buckets were consumed; start adding more introspection. Signed-off-by: Kent Overstreet <[email protected]>
1 parent b43f724 commit c7e351b

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

fs/bcachefs/btree_update_interior.c

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,15 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
12321232
list_add_tail(&as->list, &c->btree_interior_update_list);
12331233
mutex_unlock(&c->btree_interior_update_lock);
12341234

1235+
struct btree *b = btree_path_node(path, path->level);
1236+
as->node_start = b->data->min_key;
1237+
as->node_end = b->data->max_key;
1238+
as->node_needed_rewrite = btree_node_need_rewrite(b);
1239+
as->node_written = b->written;
1240+
as->node_sectors = btree_buf_bytes(b) >> 9;
1241+
as->node_remaining = __bch2_btree_u64s_remaining(b,
1242+
btree_bkey_last(b, bset_tree_last(b)));
1243+
12351244
/*
12361245
* We don't want to allocate if we're in an error state, that can cause
12371246
* deadlock on emergency shutdown due to open buckets getting stuck in
@@ -2108,6 +2117,9 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
21082117
if (ret)
21092118
goto err;
21102119

2120+
as->node_start = prev->data->min_key;
2121+
as->node_end = next->data->max_key;
2122+
21112123
trace_and_count(c, btree_node_merge, trans, b);
21122124

21132125
n = bch2_btree_node_alloc(as, trans, b->c.level);
@@ -2681,9 +2693,19 @@ static void bch2_btree_update_to_text(struct printbuf *out, struct btree_update
26812693

26822694
prt_str(out, " ");
26832695
bch2_btree_id_to_text(out, as->btree_id);
2684-
prt_printf(out, " l=%u-%u mode=%s nodes_written=%u cl.remaining=%u journal_seq=%llu\n",
2696+
prt_printf(out, " l=%u-%u ",
26852697
as->update_level_start,
2686-
as->update_level_end,
2698+
as->update_level_end);
2699+
bch2_bpos_to_text(out, as->node_start);
2700+
prt_char(out, ' ');
2701+
bch2_bpos_to_text(out, as->node_end);
2702+
prt_printf(out, "\nwritten %u/%u u64s_remaining %u need_rewrite %u",
2703+
as->node_written,
2704+
as->node_sectors,
2705+
as->node_remaining,
2706+
as->node_needed_rewrite);
2707+
2708+
prt_printf(out, "\nmode=%s nodes_written=%u cl.remaining=%u journal_seq=%llu\n",
26872709
bch2_btree_update_modes[as->mode],
26882710
as->nodes_written,
26892711
closure_nr_remaining(&as->cl),

fs/bcachefs/btree_update_interior.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ struct btree_update {
5757
unsigned took_gc_lock:1;
5858

5959
enum btree_id btree_id;
60+
struct bpos node_start;
61+
struct bpos node_end;
62+
bool node_needed_rewrite;
63+
u16 node_written;
64+
u16 node_sectors;
65+
u16 node_remaining;
66+
6067
unsigned update_level_start;
6168
unsigned update_level_end;
6269

0 commit comments

Comments
 (0)