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

bcachefs: Don't drop journal pins in exit path



There's no need to drop journal pins in our exit paths - the code was
trying to have everything cleaned up on any shutdown, but better to just
tweak the assertions a bit.

This fixes a bug where calling into journal reclaim in the exit path
would cass a null ptr deref.

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 33cc938e
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include "debug.h"
#include "errcode.h"
#include "error.h"
#include "journal.h"
#include "trace.h"

#include <linux/prefetch.h>
@@ -424,14 +425,11 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
		BUG_ON(btree_node_read_in_flight(b) ||
		       btree_node_write_in_flight(b));

		if (btree_node_dirty(b))
			bch2_btree_complete_write(c, b, btree_current_write(b));
		clear_btree_node_dirty_acct(c, b);

		btree_node_data_free(c, b);
	}

	BUG_ON(atomic_read(&c->btree_cache.dirty));
	BUG_ON(!bch2_journal_error(&c->journal) &&
	       atomic_read(&c->btree_cache.dirty));

	list_splice(&bc->freed_pcpu, &bc->freed_nonpcpu);

+2 −2
Original line number Diff line number Diff line
@@ -1704,7 +1704,7 @@ int bch2_btree_root_read(struct bch_fs *c, enum btree_id id,
	return bch2_trans_run(c, __bch2_btree_root_read(trans, id, k, level));
}

void bch2_btree_complete_write(struct bch_fs *c, struct btree *b,
static void bch2_btree_complete_write(struct bch_fs *c, struct btree *b,
				      struct btree_write *w)
{
	unsigned long old, new, v = READ_ONCE(b->will_make_reachable);
+0 −3
Original line number Diff line number Diff line
@@ -134,9 +134,6 @@ void bch2_btree_node_read(struct bch_fs *, struct btree *, bool);
int bch2_btree_root_read(struct bch_fs *, enum btree_id,
			 const struct bkey_i *, unsigned);

void bch2_btree_complete_write(struct bch_fs *, struct btree *,
			      struct btree_write *);

bool bch2_btree_post_write_cleanup(struct bch_fs *, struct btree *);

enum btree_write_flags {
+0 −2
Original line number Diff line number Diff line
@@ -992,8 +992,6 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc)
	list_for_each_entry_safe(ck, n, &items, list) {
		cond_resched();

		bch2_journal_pin_drop(&c->journal, &ck->journal);

		list_del(&ck->list);
		kfree(ck->k);
		six_lock_exit(&ck->c.lock);