Skip to content

Commit 189c176

Browse files
author
Kent Overstreet
committed
bcachefs: Improve move_extent tracepoint
Also print out the data_opts, so that we can see what specifically is being done to an extent. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent ef740a1 commit 189c176

File tree

5 files changed

+48
-7
lines changed

5 files changed

+48
-7
lines changed

fs/bcachefs/bkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void bch2_bkey_packed_to_binary_text(struct printbuf *out,
3333
next_key_bits -= 64;
3434
}
3535

36-
bch2_prt_u64_binary(out, v, min(word_bits, nr_key_bits));
36+
bch2_prt_u64_base2_nbits(out, v, min(word_bits, nr_key_bits));
3737

3838
if (!next_key_bits)
3939
break;

fs/bcachefs/move.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "btree_update.h"
1010
#include "btree_update_interior.h"
1111
#include "btree_write_buffer.h"
12+
#include "compress.h"
1213
#include "disk_groups.h"
1314
#include "ec.h"
1415
#include "errcode.h"
@@ -34,12 +35,46 @@ const char * const bch2_data_ops_strs[] = {
3435
NULL
3536
};
3637

37-
static void trace_move_extent2(struct bch_fs *c, struct bkey_s_c k)
38+
static void bch2_data_update_opts_to_text(struct printbuf *out, struct bch_fs *c,
39+
struct bch_io_opts *io_opts,
40+
struct data_update_opts *data_opts)
41+
{
42+
printbuf_tabstop_push(out, 20);
43+
prt_str(out, "rewrite ptrs:");
44+
prt_tab(out);
45+
bch2_prt_u64_base2(out, data_opts->rewrite_ptrs);
46+
prt_newline(out);
47+
48+
prt_str(out, "kill ptrs: ");
49+
prt_tab(out);
50+
bch2_prt_u64_base2(out, data_opts->kill_ptrs);
51+
prt_newline(out);
52+
53+
prt_str(out, "target: ");
54+
prt_tab(out);
55+
bch2_target_to_text(out, c, data_opts->target);
56+
prt_newline(out);
57+
58+
prt_str(out, "compression: ");
59+
prt_tab(out);
60+
bch2_compression_opt_to_text(out, io_opts->background_compression ?: io_opts->compression);
61+
prt_newline(out);
62+
63+
prt_str(out, "extra replicas: ");
64+
prt_tab(out);
65+
prt_u64(out, data_opts->extra_replicas);
66+
}
67+
68+
static void trace_move_extent2(struct bch_fs *c, struct bkey_s_c k,
69+
struct bch_io_opts *io_opts,
70+
struct data_update_opts *data_opts)
3871
{
3972
if (trace_move_extent_enabled()) {
4073
struct printbuf buf = PRINTBUF;
4174

4275
bch2_bkey_val_to_text(&buf, c, k);
76+
prt_newline(&buf);
77+
bch2_data_update_opts_to_text(&buf, c, io_opts, data_opts);
4378
trace_move_extent(c, buf.buf);
4479
printbuf_exit(&buf);
4580
}
@@ -250,9 +285,10 @@ int bch2_move_extent(struct moving_context *ctxt,
250285
unsigned sectors = k.k->size, pages;
251286
int ret = -ENOMEM;
252287

288+
trace_move_extent2(c, k, &io_opts, &data_opts);
289+
253290
if (ctxt->stats)
254291
ctxt->stats->pos = BBPOS(iter->btree_id, iter->pos);
255-
trace_move_extent2(c, k);
256292

257293
bch2_data_update_opts_normalize(k, &data_opts);
258294

fs/bcachefs/rebalance.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ static struct bkey_s_c next_rebalance_extent(struct btree_trans *trans,
177177
prt_str(&buf, "target=");
178178
bch2_target_to_text(&buf, c, r->target);
179179
prt_str(&buf, " compression=");
180-
struct bch_compression_opt opt = __bch2_compression_decode(r->compression);
181-
prt_str(&buf, bch2_compression_opts[opt.type]);
180+
bch2_compression_opt_to_text(&buf, r->compression);
182181
prt_str(&buf, " ");
183182
bch2_bkey_val_to_text(&buf, c, k);
184183

fs/bcachefs/util.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,17 @@ bool bch2_is_zero(const void *_p, size_t n)
241241
return true;
242242
}
243243

244-
void bch2_prt_u64_binary(struct printbuf *out, u64 v, unsigned nr_bits)
244+
void bch2_prt_u64_base2_nbits(struct printbuf *out, u64 v, unsigned nr_bits)
245245
{
246246
while (nr_bits)
247247
prt_char(out, '0' + ((v >> --nr_bits) & 1));
248248
}
249249

250+
void bch2_prt_u64_base2(struct printbuf *out, u64 v)
251+
{
252+
bch2_prt_u64_base2_nbits(out, v, fls64(v) ?: 1);
253+
}
254+
250255
void bch2_print_string_as_lines(const char *prefix, const char *lines)
251256
{
252257
const char *p;

fs/bcachefs/util.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ bool bch2_is_zero(const void *, size_t);
342342

343343
u64 bch2_read_flag_list(char *, const char * const[]);
344344

345-
void bch2_prt_u64_binary(struct printbuf *, u64, unsigned);
345+
void bch2_prt_u64_base2_nbits(struct printbuf *, u64, unsigned);
346+
void bch2_prt_u64_base2(struct printbuf *, u64);
346347

347348
void bch2_print_string_as_lines(const char *prefix, const char *lines);
348349

0 commit comments

Comments
 (0)