From: Kent Overstreet Date: Wed, 28 May 2025 00:37:50 +0000 (-0400) Subject: bcachefs: Fix incorrect multiple dev check in journal write path X-Git-Tag: v6.16-rc1~48^2~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=813825d24135aa3109cf7746ce11f1ec2ab901fd;p=thirdparty%2Fkernel%2Flinux.git bcachefs: Fix incorrect multiple dev check in journal write path It's uncomon to have multiple devices with journalling only on a subset, but can be specified with the 'data_allowed' option. We need to know if we're doing data/metadata writes to multiple devices, as that requires issuing flushes before the journal writes. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 30122abf3e2c7..527ce6f74b630 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1635,6 +1635,16 @@ retry_alloc: done: BUG_ON(bkey_val_u64s(&w->key.k) > BCH_REPLICAS_MAX); +#if 0 + /* + * XXX: we need a way to alert the user when we go degraded for any + * reason + */ + if (*replicas < min(replicas_want, + dev_mask_nr(&c->rw_devs[BCH_DATA_free]))) { + } +#endif + return *replicas >= replicas_need ? 0 : -BCH_ERR_insufficient_journal_devices; } @@ -2112,7 +2122,7 @@ CLOSURE_CALLBACK(bch2_journal_write) struct journal *j = container_of(w, struct journal, buf[w->idx]); struct bch_fs *c = container_of(j, struct bch_fs, journal); union bch_replicas_padded replicas; - unsigned nr_rw_members = dev_mask_nr(&c->rw_devs[BCH_DATA_journal]); + unsigned nr_rw_members = dev_mask_nr(&c->rw_devs[BCH_DATA_free]); int ret; BUG_ON(BCH_SB_CLEAN(c->disk_sb.sb));