summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-04-12 21:07:05 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-04-13 22:48:17 -0400
commit82cf18f23e1ae17053983e325e550194f947e1f1 (patch)
treef0826692f9b52f4be2b8929b5dc8cd79d295e244 /fs/bcachefs
parent4518e80adfdbfdec1cc79c98bc73677ff44d96bd (diff)
downloadlinux-stable-82cf18f23e1ae17053983e325e550194f947e1f1.tar.gz
linux-stable-82cf18f23e1ae17053983e325e550194f947e1f1.tar.bz2
linux-stable-82cf18f23e1ae17053983e325e550194f947e1f1.zip
bcachefs: Fix deadlock in journal replay
btree_key_can_insert_cached() should be checking the watermark - BCH_TRANS_COMMIT_journal_replay really means nonblocking mode when watermark < reclaim, it was being used incorrectly. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r--fs/bcachefs/btree_trans_commit.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c
index 9609ad370d71..bbec91e8e650 100644
--- a/fs/bcachefs/btree_trans_commit.c
+++ b/fs/bcachefs/btree_trans_commit.c
@@ -397,12 +397,13 @@ static int btree_key_can_insert_cached(struct btree_trans *trans, unsigned flags
struct bkey_cached *ck = (void *) path->l[0].b;
unsigned new_u64s;
struct bkey_i *new_k;
+ unsigned watermark = flags & BCH_WATERMARK_MASK;
EBUG_ON(path->level);
- if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags) &&
- bch2_btree_key_cache_must_wait(c) &&
- !(flags & BCH_TRANS_COMMIT_journal_reclaim))
+ if (watermark < BCH_WATERMARK_reclaim &&
+ !test_bit(BKEY_CACHED_DIRTY, &ck->flags) &&
+ bch2_btree_key_cache_must_wait(c))
return -BCH_ERR_btree_insert_need_journal_reclaim;
/*