*/
        bch2_journal_flush_all_pins(&c->journal);
 
+       /*
+        * If the allocator threads didn't all start up, the btree updates to
+        * write out alloc info aren't going to work:
+        */
        if (!test_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags))
-               goto allocator_not_running;
+               goto nowrote_alloc;
 
        do {
                wrote = false;
                        bch2_fs_inconsistent(c, "error writing out alloc info %i", ret);
 
                if (ret)
-                       break;
+                       goto nowrote_alloc;
 
                for_each_member_device(ca, c, i)
                        bch2_dev_allocator_quiesce(c, ca);
 
                clean_passes = wrote ? 0 : clean_passes + 1;
        } while (clean_passes < 2);
-allocator_not_running:
+
+       set_bit(BCH_FS_ALLOC_CLEAN, &c->flags);
+nowrote_alloc:
        for_each_member_device(ca, c, i)
                bch2_dev_allocator_stop(ca);
 
            !test_bit(BCH_FS_ERROR, &c->flags) &&
            !test_bit(BCH_FS_EMERGENCY_RO, &c->flags) &&
            test_bit(BCH_FS_STARTED, &c->flags) &&
+           test_bit(BCH_FS_ALLOC_CLEAN, &c->flags) &&
            !c->opts.norecovery)
                bch2_fs_mark_clean(c);
 
        if (ret)
                goto err;
 
+       clear_bit(BCH_FS_ALLOC_CLEAN, &c->flags);
+
        for_each_rw_member(ca, c, i)
                bch2_dev_allocator_add(c, ca);
        bch2_recalc_capacity(c);