From: Jaegeuk Kim Date: Sat, 24 Jan 2015 03:16:59 +0000 (-0800) Subject: f2fs: should fail mount when trying to recover data on read-only dev X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=081d78c2fc4ab2fef4cdf1100dd22155c73f8657;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git f2fs: should fail mount when trying to recover data on read-only dev If device is read-only, we should not proceed data recovery. But, if the previous checkpoint was done by normal clean shutdown, it's safe to proceed the recovery, since there will be no data to be recovered. Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index bfeab3c81a48..1e92c2ea6bc1 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1149,6 +1149,15 @@ try_onemore: /* recover fsynced data */ if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) { + /* + * mount should be failed, when device has readonly mode, and + * previous checkpoint was not done by clean system shutdown. + */ + if (bdev_read_only(sb->s_bdev) && + !is_set_ckpt_flags(sbi->ckpt, CP_UMOUNT_FLAG)) { + err = -EROFS; + goto free_kobj; + } err = recover_fsync_data(sbi); if (err) { f2fs_msg(sb, KERN_ERR,