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

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
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "debug.h" #include "debug.h"
#include "errcode.h" #include "errcode.h"
#include "error.h" #include "error.h"
#include "journal.h"
#include "trace.h" #include "trace.h"
#include <linux/prefetch.h> #include <linux/prefetch.h>
...@@ -424,14 +425,11 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c) ...@@ -424,14 +425,11 @@ void bch2_fs_btree_cache_exit(struct bch_fs *c)
BUG_ON(btree_node_read_in_flight(b) || BUG_ON(btree_node_read_in_flight(b) ||
btree_node_write_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); 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); list_splice(&bc->freed_pcpu, &bc->freed_nonpcpu);
......
...@@ -1704,8 +1704,8 @@ int bch2_btree_root_read(struct bch_fs *c, enum btree_id id, ...@@ -1704,8 +1704,8 @@ 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)); 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) struct btree_write *w)
{ {
unsigned long old, new, v = READ_ONCE(b->will_make_reachable); unsigned long old, new, v = READ_ONCE(b->will_make_reachable);
......
...@@ -134,9 +134,6 @@ void bch2_btree_node_read(struct bch_fs *, struct btree *, bool); ...@@ -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, int bch2_btree_root_read(struct bch_fs *, enum btree_id,
const struct bkey_i *, unsigned); 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 *); bool bch2_btree_post_write_cleanup(struct bch_fs *, struct btree *);
enum btree_write_flags { enum btree_write_flags {
......
...@@ -992,8 +992,6 @@ void bch2_fs_btree_key_cache_exit(struct btree_key_cache *bc) ...@@ -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) { list_for_each_entry_safe(ck, n, &items, list) {
cond_resched(); cond_resched();
bch2_journal_pin_drop(&c->journal, &ck->journal);
list_del(&ck->list); list_del(&ck->list);
kfree(ck->k); kfree(ck->k);
six_lock_exit(&ck->c.lock); six_lock_exit(&ck->c.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment