bcachefs: Fix error path in bch2_journal_flush_device_pins()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 9 Jul 2023 02:21:45 +0000 (22:21 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:06 +0000 (17:10 -0400)
We need to always call bch2_replicas_gc_end() after we've called
bch2_replicas_gc_start(), else we leave state around that needs to be
cleaned up.

Partial fix for: https://github.com/koverstreet/bcachefs/issues/560

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/journal_reclaim.c
fs/bcachefs/replicas.c

index 72486f1f8a8e28fe6af9bede873e3a669ba912b6..8de83e10375187803730214e3bee4c3cd425256c 100644 (file)
@@ -845,10 +845,8 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx)
         * 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;
-       }
+       if (ret)
+               goto err;
 
        seq = 0;
        spin_lock(&j->lock);
@@ -867,7 +865,7 @@ int bch2_journal_flush_device_pins(struct journal *j, int dev_idx)
                spin_lock(&j->lock);
        }
        spin_unlock(&j->lock);
-
+err:
        ret = bch2_replicas_gc_end(c, ret);
        mutex_unlock(&c->replicas_gc_lock);
 
index d4c1d43e8c418c8224387b22a9ddb1396d2ffceb..5b591c59bc3eadaf86ffd83360609950c9eaad5a 100644 (file)
@@ -462,6 +462,9 @@ int bch2_replicas_gc_end(struct bch_fs *c, int ret)
 {
        lockdep_assert_held(&c->replicas_gc_lock);
 
+       if (ret)
+               goto err;
+
        mutex_lock(&c->sb_lock);
        percpu_down_write(&c->mark_lock);