fuse2fs: check for recorded fs errors before touching things

Refuse the mount if there are errors recorded in the superblock.  We
should not be trying to replay the journal on damaged filesystems.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index c201f95..415f174 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -4723,6 +4723,12 @@
 		goto out;
 	}
 
+	if (global_fs->super->s_state & EXT2_ERROR_FS) {
+		err_printf(&fctx, "%s\n",
+ _("Errors detected; running e2fsck is required."));
+		goto out;
+	}
+
 	/*
 	 * ext4 can't do COW of shared blocks, so if the feature is enabled,
 	 * we must force ro mode.
@@ -4784,12 +4790,6 @@
 		err_printf(&fctx, "%s\n",
  _("Orphans detected; running e2fsck is recommended."));
 
-	if (global_fs->super->s_state & EXT2_ERROR_FS) {
-		err_printf(&fctx, "%s\n",
- _("Errors detected; running e2fsck is required."));
-		goto out;
-	}
-
 	/* Clear the valid flag so that an unclean shutdown forces a fsck */
 	if (global_fs->flags & EXT2_FLAG_RW) {
 		global_fs->super->s_mnt_count++;