Commit 7423330e authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: prt_printf() now respects \r\n\t

parent 2dcb605e
Loading
Loading
Loading
Loading
+11 −21
Original line number Diff line number Diff line
@@ -330,27 +330,17 @@ void bch2_alloc_to_text(struct printbuf *out, struct bch_fs *c, struct bkey_s_c
	prt_printf(out, "gen %u oldest_gen %u data_type ", a->gen, a->oldest_gen);
	bch2_prt_data_type(out, a->data_type);
	prt_newline(out);
	prt_printf(out, "journal_seq       %llu",	a->journal_seq);
	prt_newline(out);
	prt_printf(out, "need_discard      %llu",	BCH_ALLOC_V4_NEED_DISCARD(a));
	prt_newline(out);
	prt_printf(out, "need_inc_gen      %llu",	BCH_ALLOC_V4_NEED_INC_GEN(a));
	prt_newline(out);
	prt_printf(out, "dirty_sectors     %u",	a->dirty_sectors);
	prt_newline(out);
	prt_printf(out, "cached_sectors    %u",	a->cached_sectors);
	prt_newline(out);
	prt_printf(out, "stripe            %u",	a->stripe);
	prt_newline(out);
	prt_printf(out, "stripe_redundancy %u",	a->stripe_redundancy);
	prt_newline(out);
	prt_printf(out, "io_time[READ]     %llu",	a->io_time[READ]);
	prt_newline(out);
	prt_printf(out, "io_time[WRITE]    %llu",	a->io_time[WRITE]);
	prt_newline(out);
	prt_printf(out, "fragmentation     %llu",	a->fragmentation_lru);
	prt_newline(out);
	prt_printf(out, "bp_start          %llu", BCH_ALLOC_V4_BACKPOINTERS_START(a));
	prt_printf(out, "journal_seq       %llu\n",	a->journal_seq);
	prt_printf(out, "need_discard      %llu\n",	BCH_ALLOC_V4_NEED_DISCARD(a));
	prt_printf(out, "need_inc_gen      %llu\n",	BCH_ALLOC_V4_NEED_INC_GEN(a));
	prt_printf(out, "dirty_sectors     %u\n",	a->dirty_sectors);
	prt_printf(out, "cached_sectors    %u\n",	a->cached_sectors);
	prt_printf(out, "stripe            %u\n",	a->stripe);
	prt_printf(out, "stripe_redundancy %u\n",	a->stripe_redundancy);
	prt_printf(out, "io_time[READ]     %llu\n",	a->io_time[READ]);
	prt_printf(out, "io_time[WRITE]    %llu\n",	a->io_time[WRITE]);
	prt_printf(out, "fragmentation     %llu\n",	a->fragmentation_lru);
	prt_printf(out, "bp_start          %llu\n", BCH_ALLOC_V4_BACKPOINTERS_START(a));
	printbuf_indent_sub(out, 2);
}

+1 −2
Original line number Diff line number Diff line
@@ -117,8 +117,7 @@ static noinline int backpointer_mod_err(struct btree_trans *trans,

		bch_err(c, "%s", buf.buf);
	} else if (c->curr_recovery_pass > BCH_RECOVERY_PASS_check_extents_to_backpointers) {
		prt_printf(&buf, "backpointer not found when deleting");
		prt_newline(&buf);
		prt_printf(&buf, "backpointer not found when deleting\n");
		printbuf_indent_add(&buf, 2);

		prt_printf(&buf, "searching for ");
+5 −10
Original line number Diff line number Diff line
@@ -522,6 +522,8 @@ static void btree_err_msg(struct printbuf *out, struct bch_fs *c,
	prt_printf(out, "at btree ");
	bch2_btree_pos_to_text(out, c, b);

	printbuf_indent_add(out, 2);

	prt_printf(out, "\nnode offset %u/%u",
		   b->written, btree_ptr_sectors_written(&b->key));
	if (i)
@@ -2344,20 +2346,13 @@ void bch2_btree_write_stats_to_text(struct printbuf *out, struct bch_fs *c)
	printbuf_tabstop_push(out, 20);
	printbuf_tabstop_push(out, 10);

	prt_tab(out);
	prt_str(out, "nr");
	prt_tab(out);
	prt_str(out, "size");
	prt_newline(out);
	prt_printf(out, "\tnr\tsize\n");

	for (unsigned i = 0; i < BTREE_WRITE_TYPE_NR; i++) {
		u64 nr		= atomic64_read(&c->btree_write_stats[i].nr);
		u64 bytes	= atomic64_read(&c->btree_write_stats[i].bytes);

		prt_printf(out, "%s:", bch2_btree_write_types[i]);
		prt_tab(out);
		prt_u64(out, nr);
		prt_tab(out);
		prt_printf(out, "%s:\t%llu\t", bch2_btree_write_types[i], nr);
		prt_human_readable_u64(out, nr ? div64_u64(bytes, nr) : 0);
		prt_newline(out);
	}
+6 −12
Original line number Diff line number Diff line
@@ -1387,19 +1387,17 @@ void __noreturn bch2_trans_in_restart_error(struct btree_trans *trans)
noinline __cold
void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
{
	prt_printf(buf, "transaction updates for %s journal seq %llu",
	prt_printf(buf, "transaction updates for %s journal seq %llu\n",
	       trans->fn, trans->journal_res.seq);
	prt_newline(buf);
	printbuf_indent_add(buf, 2);

	trans_for_each_update(trans, i) {
		struct bkey_s_c old = { &i->old_k, i->old_v };

		prt_printf(buf, "update: btree=%s cached=%u %pS",
		prt_printf(buf, "update: btree=%s cached=%u %pS\n",
		       bch2_btree_id_str(i->btree_id),
		       i->cached,
		       (void *) i->ip_allocated);
		prt_newline(buf);

		prt_printf(buf, "  old ");
		bch2_bkey_val_to_text(buf, trans->c, old);
@@ -3166,13 +3164,11 @@ bch2_btree_bkey_cached_common_to_text(struct printbuf *out,
	pid = owner ? owner->pid : 0;
	rcu_read_unlock();

	prt_tab(out);
	prt_printf(out, "%px %c l=%u %s:", b, b->cached ? 'c' : 'b',
	prt_printf(out, "\t%px %c l=%u %s:", b, b->cached ? 'c' : 'b',
		   b->level, bch2_btree_id_str(b->btree_id));
	bch2_bpos_to_text(out, btree_node_pos(b));

	prt_tab(out);
	prt_printf(out, " locks %u:%u:%u held by pid %u",
	prt_printf(out, "\t locks %u:%u:%u held by pid %u",
		   c.n[0], c.n[1], c.n[2], pid);
}

@@ -3229,10 +3225,8 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct btree_trans *trans)

	b = READ_ONCE(trans->locking);
	if (b) {
		prt_printf(out, "  blocked for %lluus on",
			   div_u64(local_clock() - trans->locking_wait.start_time,
				   1000));
		prt_newline(out);
		prt_printf(out, "  blocked for %lluus on\n",
			   div_u64(local_clock() - trans->locking_wait.start_time, 1000));
		prt_printf(out, "    %c", lock_types[trans->locking_wait.lock_want]);
		bch2_btree_bkey_cached_common_to_text(out, b);
		prt_newline(out);
+3 −6
Original line number Diff line number Diff line
@@ -1039,12 +1039,9 @@ int bch2_fs_btree_key_cache_init(struct btree_key_cache *bc)

void bch2_btree_key_cache_to_text(struct printbuf *out, struct btree_key_cache *c)
{
	prt_printf(out, "nr_freed:\t%lu",	atomic_long_read(&c->nr_freed));
	prt_newline(out);
	prt_printf(out, "nr_keys:\t%lu",	atomic_long_read(&c->nr_keys));
	prt_newline(out);
	prt_printf(out, "nr_dirty:\t%lu",	atomic_long_read(&c->nr_dirty));
	prt_newline(out);
	prt_printf(out, "nr_freed:\t%lu\n",	atomic_long_read(&c->nr_freed));
	prt_printf(out, "nr_keys:\t%lu\n",	atomic_long_read(&c->nr_keys));
	prt_printf(out, "nr_dirty:\t%lu\n",	atomic_long_read(&c->nr_dirty));
}

void bch2_btree_key_cache_exit(void)
Loading