summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-12-04 18:16:25 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-12-21 01:36:22 -0500
commit49833ce27ed2eed91915a4c25690d82aae5b6a0b (patch)
treeb3d05da4d0f4ec860d9b9332ba0d3699e261b4c3
parentbcachefs: BCH_ERR_insufficient_journal_devices (diff)
downloadlinux-49833ce27ed2eed91915a4c25690d82aae5b6a0b.tar.gz
linux-49833ce27ed2eed91915a4c25690d82aae5b6a0b.zip
bcachefs: Fix failure to allocate journal write on discard retry
When allocating a journal write fails, then retries after doing discards, we were failing to count already allocated replicas. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/journal_io.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index e5fce5e497f2..d7dfea5f0181 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -1498,6 +1498,15 @@ static int journal_write_alloc(struct journal *j, struct journal_buf *w)
READ_ONCE(c->opts.metadata_replicas_required));
rcu_read_lock();
+
+ /* We might run more than once if we have to stop and do discards: */
+ struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(&w->key));
+ bkey_for_each_ptr(ptrs, p) {
+ struct bch_dev *ca = bch2_dev_rcu_noerror(c, p->dev);
+ if (ca)
+ replicas += ca->mi.durability;
+ }
+
retry:
devs = target_rw_devs(c, BCH_DATA_journal, target);