提交 081d78c2 编写于 作者: J Jaegeuk Kim

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: NChao Yu <chao2.yu@samsung.com>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
上级 119ee914
...@@ -1149,6 +1149,15 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -1149,6 +1149,15 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
/* recover fsynced data */ /* recover fsynced data */
if (!test_opt(sbi, DISABLE_ROLL_FORWARD)) { 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); err = recover_fsync_data(sbi);
if (err) { if (err) {
f2fs_msg(sb, KERN_ERR, f2fs_msg(sb, KERN_ERR,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册