Commit 67997234 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: kill btree_trans->wb_updates



the btree write buffer path now creates a journal entry directly

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 002c76dc
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -638,7 +638,6 @@ struct btree_transaction_stats {
	struct bch2_time_stats	lock_hold_times;
	struct mutex		lock;
	unsigned		nr_max_paths;
	unsigned		wb_updates_size;
	unsigned		journal_entries_size;
	unsigned		max_mem;
	char			*max_paths_text;
+5 −12
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include "error.h"
#include "extents.h"
#include "journal.h"
#include "journal_io.h"
#include "replicas.h"
#include "snapshot.h"
#include "trace.h"
@@ -1369,7 +1370,6 @@ noinline __cold
void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
{
	struct btree_insert_entry *i;
	struct btree_write_buffered_key *wb;

	prt_printf(buf, "transaction updates for %s journal seq %llu",
	       trans->fn, trans->journal_res.seq);
@@ -1394,16 +1394,10 @@ void bch2_trans_updates_to_text(struct printbuf *buf, struct btree_trans *trans)
		prt_newline(buf);
	}

	trans_for_each_wb_update(trans, wb) {
		prt_printf(buf, "update: btree=%s wb=1 %pS",
		       bch2_btree_id_str(wb->btree),
		       (void *) i->ip_allocated);
		prt_newline(buf);

		prt_printf(buf, "  new ");
		bch2_bkey_val_to_text(buf, trans->c, bkey_i_to_s_c(&wb->k));
		prt_newline(buf);
	}
	for (struct jset_entry *e = trans->journal_entries;
	     e != btree_trans_journal_entries_top(trans);
	     e = vstruct_next(e))
		bch2_journal_entry_to_text(buf, trans->c, e);

	printbuf_indent_sub(buf, 2);
}
@@ -2922,7 +2916,6 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)

	if (s) {
		trans->nr_max_paths = s->nr_max_paths;
		trans->wb_updates_size = s->wb_updates_size;
		trans->journal_entries_size = s->journal_entries_size;
	}

+1 −1
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ static inline void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)

static inline void *bch2_trans_kmalloc_nomemzero(struct btree_trans *trans, size_t size)
{
	size = roundup(size, 8);
	size = round_up(size, 8);

	if (likely(trans->mem_top + size <= trans->mem_bytes)) {
		void *p = trans->mem + trans->mem_top;
+0 −18
Original line number Diff line number Diff line
@@ -624,7 +624,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
{
	struct bch_fs *c = trans->c;
	struct btree_insert_entry *i;
	struct btree_write_buffered_key *wb;
	struct btree_trans_commit_hook *h;
	unsigned u64s = 0;
	int ret;
@@ -743,14 +742,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
			bkey_copy((struct bkey_i *) entry->start, i->k);
		}

		trans_for_each_wb_update(trans, wb) {
			entry = bch2_journal_add_entry(j, &trans->journal_res,
					       BCH_JSET_ENTRY_write_buffer_keys,
					       wb->btree, 0,
					       wb->k.k.u64s);
			bkey_copy((struct bkey_i *) entry->start, &wb->k);
		}

		memcpy_u64s_small(journal_res_entry(&c->journal, &trans->journal_res),
				  trans->journal_entries,
				  trans->journal_entries_u64s);
@@ -785,13 +776,9 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
static noinline void bch2_drop_overwrites_from_journal(struct btree_trans *trans)
{
	struct btree_insert_entry *i;
	struct btree_write_buffered_key *wb;

	trans_for_each_update(trans, i)
		bch2_journal_key_overwritten(trans->c, i->btree_id, i->level, i->k->k.p);

	trans_for_each_wb_update(trans, wb)
		bch2_journal_key_overwritten(trans->c, wb->btree, 0, wb->k.k.p);
}

static noinline int bch2_trans_commit_bkey_invalid(struct btree_trans *trans,
@@ -993,11 +980,9 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
{
	struct bch_fs *c = trans->c;
	struct btree_insert_entry *i = NULL;
	struct btree_write_buffered_key *wb;
	int ret = 0;

	if (!trans->nr_updates &&
	    !trans->nr_wb_updates &&
	    !trans->journal_entries_u64s)
		goto out_reset;

@@ -1064,9 +1049,6 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
			trans->journal_u64s += jset_u64s(i->old_k.u64s);
	}

	trans_for_each_wb_update(trans, wb)
		trans->journal_u64s += jset_u64s(wb->k.k.u64s);

	if (trans->extra_journal_res) {
		ret = bch2_disk_reservation_add(c, trans->disk_res,
				trans->extra_journal_res,
+0 −3
Original line number Diff line number Diff line
@@ -388,8 +388,6 @@ struct btree_trans {
	u8			fn_idx;
	u8			nr_sorted;
	u8			nr_updates;
	u8			nr_wb_updates;
	u8			wb_updates_size;
	bool			srcu_held:1;
	bool			used_mempool:1;
	bool			in_traverse_all:1;
@@ -424,7 +422,6 @@ struct btree_trans {
	u8			sorted[BTREE_ITER_MAX + 8];
	struct btree_path	paths[BTREE_ITER_MAX];
	struct btree_insert_entry updates[BTREE_ITER_MAX];
	struct btree_write_buffered_key *wb_updates;

	/* update path: */
	struct btree_trans_commit_hook *hooks;
Loading