]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/journal_reclaim.c
Update bcachefs sources to 25de2b00dc bcachefs: Change check for invalid key types
[bcachefs-tools-debian] / libbcachefs / journal_reclaim.c
index 2c7f8aca9319df668b5779a7cf8dae2d9aa587cc..72486f1f8a8e28fe6af9bede873e3a669ba912b6 100644 (file)
@@ -361,7 +361,7 @@ void bch2_journal_pin_drop(struct journal *j,
        spin_unlock(&j->lock);
 }
 
-enum journal_pin_type journal_pin_type(journal_pin_flush_fn fn)
+static enum journal_pin_type journal_pin_type(journal_pin_flush_fn fn)
 {
        if (fn == bch2_btree_node_flush0 ||
            fn == bch2_btree_node_flush1)
@@ -837,8 +837,20 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx)
        mutex_lock(&c->replicas_gc_lock);
        bch2_replicas_gc_start(c, 1 << BCH_DATA_journal);
 
-       seq = 0;
+       /*
+        * Now that we've populated replicas_gc, write to the journal to mark
+        * active journal devices. This handles the case where the journal might
+        * be empty. Otherwise we could clear all journal replicas and
+        * temporarily put the fs into an unrecoverable state. Journal recovery
+        * expects to find devices marked for journal data on unclean mount.
+        */
+       ret = bch2_journal_meta(&c->journal);
+       if (ret) {
+               mutex_unlock(&c->replicas_gc_lock);
+               return ret;
+       }
 
+       seq = 0;
        spin_lock(&j->lock);
        while (!ret) {
                struct bch_replicas_padded replicas;