[Ocfs2-tools-devel] [PATCH] mount.ocfs2: return -EROFS if file system is readonly

piaojun piaojun at huawei.com
Wed Dec 27 01:12:39 PST 2017


If metadata is corrupted such as 'invalid inode block', we will get
-EROFS by calling 'mount()'. In this situation we need fix it by fsck,
and mount again rather than doing meaningless retry.

Signed-off-by: Jun Piao <piaojun at huawei.com>
---
 mount.ocfs2/mount.ocfs2.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
index e3d8871..1ab07ac 100644
--- a/mount.ocfs2/mount.ocfs2.c
+++ b/mount.ocfs2/mount.ocfs2.c
@@ -434,8 +434,15 @@ int main(int argc, char **argv)
 			o2cb_complete_group_join(&cluster, &desc, errno);
 		}
 		block_signals (SIG_UNBLOCK);
-		com_err(progname, ret, "while mounting %s on %s. Check 'dmesg' "
-			"for more information on this error.", mo.dev, mo.dir);
+		if (ret == -EROFS)
+			com_err(progname, 0, "file system is now readonly due to "
+				"on-disk corruption while mounting %s on %s, please "
+				"fix this by fsck.ocfs2 and then retry mounting",
+				mo.dev, mo.dir);
+		else
+			com_err(progname, OCFS2_ET_INTERNAL_FAILURE,
+				"while mounting %s on %s. Check 'dmesg' for more "
+				"information on this error.", mo.dev, mo.dir);
 		goto bail;
 	}
 	if (group_join) {
@@ -478,5 +485,5 @@ bail:
 	if (opts_string)
 		free(opts_string);

-	return ret ? 1 : 0;
+	return ret;
 }
-- 



More information about the Ocfs2-tools-devel mailing list