bcachefs: Fix incorrect multiple dev check in journal write path
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 28 May 2025 00:37:50 +0000 (20:37 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 30 May 2025 05:21:12 +0000 (01:21 -0400)
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 <kent.overstreet@linux.dev>
fs/bcachefs/journal_io.c

index 30122ab..527ce6f 100644 (file)
@@ -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));