From 3aea434272884b8dc77c57624a6d3fec55ade898 Mon Sep 17 00:00:00 2001
From: Kent Overstreet <kent.overstreet@gmail.com>
Date: Sat, 9 Mar 2019 14:53:03 -0500
Subject: [PATCH] bcachefs: Fix for shutting down before fs started marking it
 clean

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
---
 fs/bcachefs/super.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index c79aa11f2120..4f627e91f041 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -299,7 +299,8 @@ void bch2_fs_read_only(struct bch_fs *c)
 
 	if (!bch2_journal_error(&c->journal) &&
 	    !test_bit(BCH_FS_ERROR, &c->flags) &&
-	    !test_bit(BCH_FS_EMERGENCY_RO, &c->flags))
+	    !test_bit(BCH_FS_EMERGENCY_RO, &c->flags) &&
+	    test_bit(BCH_FS_STARTED, &c->flags))
 		bch2_fs_mark_clean(c, true);
 
 	if (c->state != BCH_FS_STOPPING)
-- 
2.30.9