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

bcachefs: Kill BCH_TRANS_COMMIT_lazy_rw



We unconditionally go read-write, if we're going to do so, before
journal replay: lazy_rw is obsolete.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent cc944fbe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -908,7 +908,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c)
					POS(ca->dev_idx, ca->mi.first_bucket),
					POS(ca->dev_idx, ca->mi.nbuckets - 1),
					BTREE_ITER_slots|BTREE_ITER_prefetch, k,
					NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
					NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
				bch2_alloc_write_key(trans, &iter, ca, k)));
		if (ret) {
			bch2_dev_put(ca);
+5 −26
Original line number Diff line number Diff line
@@ -971,24 +971,6 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags,
	return ret;
}

static noinline int
bch2_trans_commit_get_rw_cold(struct btree_trans *trans, unsigned flags)
{
	struct bch_fs *c = trans->c;
	int ret;

	if (likely(!(flags & BCH_TRANS_COMMIT_lazy_rw)) ||
	    test_bit(BCH_FS_started, &c->flags))
		return -BCH_ERR_erofs_trans_commit;

	ret = drop_locks_do(trans, bch2_fs_read_write_early(c));
	if (ret)
		return ret;

	bch2_write_ref_get(c, BCH_WRITE_REF_trans);
	return 0;
}

/*
 * This is for updates done in the early part of fsck - btree_gc - before we've
 * gone RW. we only add the new key to the list of keys for journal replay to
@@ -1037,15 +1019,12 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
	if (ret)
		goto out_reset;

	if (unlikely(!test_bit(BCH_FS_may_go_rw, &c->flags))) {
		ret = do_bch2_trans_commit_to_journal_replay(trans);
		goto out_reset;
	}

	if (!(flags & BCH_TRANS_COMMIT_no_check_rw) &&
	    unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_trans))) {
		ret = bch2_trans_commit_get_rw_cold(trans, flags);
		if (ret)
		if (unlikely(!test_bit(BCH_FS_may_go_rw, &c->flags)))
			ret = do_bch2_trans_commit_to_journal_replay(trans);
		else
			ret = -BCH_ERR_erofs_trans_commit;
		goto out_reset;
	}

+1 −2
Original line number Diff line number Diff line
@@ -865,8 +865,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
		memcpy(l->d, buf.buf, buf.pos);
		c->journal.early_journal_entries.nr += jset_u64s(u64s);
	} else {
		ret = bch2_trans_commit_do(c, NULL, NULL,
			BCH_TRANS_COMMIT_lazy_rw|commit_flags,
		ret = bch2_trans_commit_do(c, NULL, NULL, commit_flags,
			__bch2_trans_log_msg(trans, &buf, u64s));
	}
err:
+0 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ void bch2_btree_insert_key_leaf(struct btree_trans *, struct btree_path *,
#define BCH_TRANS_COMMIT_FLAGS()							\
	x(no_enospc,	"don't check for enospc")					\
	x(no_check_rw,	"don't attempt to take a ref on c->writes")			\
	x(lazy_rw,	"go read-write if we haven't yet - only for use in recovery")	\
	x(no_journal_res, "don't take a journal reservation, instead "			\
			"pin journal entry referred to by trans->journal_res.seq")	\
	x(journal_reclaim, "operation required for journal reclaim; may return error"	\
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ int bch2_check_lrus(struct bch_fs *c)
	int ret = bch2_trans_run(c,
		for_each_btree_key_commit(trans, iter,
				BTREE_ID_lru, POS_MIN, BTREE_ITER_prefetch, k,
				NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
				NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
			bch2_check_lru_key(trans, &iter, k, &last_flushed)));

	bch2_bkey_buf_exit(&last_flushed, c);
Loading