summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-15 05:15:55 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:00 +0300
commit0ef107859bc868f783cbbbf055a907c702896661 (patch)
tree823ac62f358bc1fcb28bd65d603510599a619a1b
parent1b9374adecea64244b0c67aa27e032feae1f1bca (diff)
downloadlinux-0ef107859bc868f783cbbbf055a907c702896661.tar.xz
bcachefs: Fix journal_reclaim_wait_done()
Can't run arbitrary code inside a wait_event() conditional, due to task state being weird... Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/btree_update_leaf.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 9a747b420180..21a26987f975 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -629,25 +629,11 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans,
static int journal_reclaim_wait_done(struct bch_fs *c)
{
- int ret;
-
- ret = bch2_journal_error(&c->journal);
- if (ret)
- return ret;
-
- ret = !bch2_btree_key_cache_must_wait(c);
- if (ret)
- return ret;
-
- journal_reclaim_kick(&c->journal);
-
- if (mutex_trylock(&c->journal.reclaim_lock)) {
- ret = bch2_journal_reclaim(&c->journal);
- mutex_unlock(&c->journal.reclaim_lock);
- }
+ int ret = bch2_journal_error(&c->journal) ?:
+ !bch2_btree_key_cache_must_wait(c);
if (!ret)
- ret = !bch2_btree_key_cache_must_wait(c);
+ journal_reclaim_kick(&c->journal);
return ret;
}
@@ -735,8 +721,8 @@ int bch2_trans_commit_error(struct btree_trans *trans,
case BTREE_INSERT_NEED_JOURNAL_RECLAIM:
bch2_trans_unlock(trans);
- wait_event(c->journal.reclaim_wait,
- (ret = journal_reclaim_wait_done(c)));
+ wait_event_freezable(c->journal.reclaim_wait,
+ (ret = journal_reclaim_wait_done(c)));
if (ret < 0)
return ret;