diff options
Diffstat (limited to 'fs/bcachefs/data_update.c')
-rw-r--r-- | fs/bcachefs/data_update.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index e848e210a9bf..ccedc93fe0ef 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -115,7 +115,7 @@ static void trace_io_move_finish2(struct data_update *u, struct bkey_i *insert) { struct bch_fs *c = u->op.c; - struct printbuf buf = PRINTBUF; + CLASS(printbuf, buf)(); prt_newline(&buf); @@ -131,7 +131,6 @@ static void trace_io_move_finish2(struct data_update *u, prt_newline(&buf); trace_io_move_finish(c, buf.buf); - printbuf_exit(&buf); } noinline_for_stack @@ -143,7 +142,7 @@ static void trace_io_move_fail2(struct data_update *m, { struct bch_fs *c = m->op.c; struct bkey_s_c old = bkey_i_to_s_c(m->k.k); - struct printbuf buf = PRINTBUF; + CLASS(printbuf, buf)(); unsigned rewrites_found = 0; if (!trace_io_move_fail_enabled()) @@ -187,7 +186,6 @@ static void trace_io_move_fail2(struct data_update *m, } trace_io_move_fail(c, buf.buf); - printbuf_exit(&buf); } noinline_for_stack @@ -196,7 +194,7 @@ static void trace_data_update2(struct data_update *m, struct bkey_i *insert) { struct bch_fs *c = m->op.c; - struct printbuf buf = PRINTBUF; + CLASS(printbuf, buf)(); prt_str(&buf, "\nold: "); bch2_bkey_val_to_text(&buf, c, old); @@ -206,7 +204,6 @@ static void trace_data_update2(struct data_update *m, bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(insert)); trace_data_update(c, buf.buf); - printbuf_exit(&buf); } noinline_for_stack @@ -215,7 +212,7 @@ static void trace_io_move_created_rebalance2(struct data_update *m, struct bkey_i *insert) { struct bch_fs *c = m->op.c; - struct printbuf buf = PRINTBUF; + CLASS(printbuf, buf)(); bch2_data_update_opts_to_text(&buf, c, &m->op.opts, &m->data_opts); @@ -227,7 +224,6 @@ static void trace_io_move_created_rebalance2(struct data_update *m, bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(insert)); trace_io_move_created_rebalance(c, buf.buf); - printbuf_exit(&buf); this_cpu_inc(c->counters[BCH_COUNTER_io_move_created_rebalance]); } @@ -238,7 +234,7 @@ static int data_update_invalid_bkey(struct data_update *m, struct bkey_i *insert) { struct bch_fs *c = m->op.c; - struct printbuf buf = PRINTBUF; + CLASS(printbuf, buf)(); bch2_log_msg_start(c, &buf); prt_str(&buf, "about to insert invalid key in data update path"); @@ -254,7 +250,6 @@ static int data_update_invalid_bkey(struct data_update *m, bch2_fs_emergency_read_only2(c, &buf); bch2_print_str(c, KERN_ERR, buf.buf); - printbuf_exit(&buf); return bch_err_throw(c, invalid_bkey); } @@ -499,7 +494,8 @@ out: int bch2_data_update_index_update(struct bch_write_op *op) { - return bch2_trans_run(op->c, __bch2_data_update_index_update(trans, op)); + CLASS(btree_trans, trans)(op->c); + return __bch2_data_update_index_update(trans, op); } void bch2_data_update_read_done(struct data_update *m) @@ -675,7 +671,7 @@ void bch2_data_update_inflight_to_text(struct printbuf *out, struct data_update if (!m->read_done) { prt_printf(out, "read:\n"); printbuf_indent_add(out, 2); - bch2_read_bio_to_text(out, &m->rbio); + bch2_read_bio_to_text(out, m->op.c, &m->rbio); } else { prt_printf(out, "write:\n"); printbuf_indent_add(out, 2); @@ -783,6 +779,9 @@ static int can_write_extent(struct bch_fs *c, struct data_update *m) darray_for_each(m->op.devs_have, i) __clear_bit(*i, devs.d); + CLASS(printbuf, buf)(); + + guard(printbuf_atomic)(&buf); guard(rcu)(); unsigned nr_replicas = 0, i; @@ -794,7 +793,11 @@ static int can_write_extent(struct bch_fs *c, struct data_update *m) struct bch_dev_usage usage; bch2_dev_usage_read_fast(ca, &usage); - if (!dev_buckets_free(ca, usage, m->op.watermark)) + u64 nr_free = dev_buckets_free(ca, usage, m->op.watermark); + + prt_printf(&buf, "%s=%llu ", ca->name, nr_free); + + if (!nr_free) continue; nr_replicas += ca->mi.durability; @@ -802,8 +805,10 @@ static int can_write_extent(struct bch_fs *c, struct data_update *m) break; } - if (!nr_replicas) + if (!nr_replicas) { + trace_data_update_done_no_rw_devs(c, buf.buf); return bch_err_throw(c, data_update_done_no_rw_devs); + } if (nr_replicas < m->op.nr_replicas) return bch_err_throw(c, insufficient_devices); return 0; |