diff mbox

[4/5] f2fs: should fail mount when trying to recover data on read-only dev

Message ID 1422401503-4769-4-git-send-email-jaegeuk@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Jaegeuk Kim Jan. 27, 2015, 11:31 p.m. UTC
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.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

?? Jan. 29, 2015, 12:16 p.m. UTC | #1
Hi Jaegeuk,

> -----Original Message-----
> From: linux-fsdevel-owner@vger.kernel.org [mailto:linux-fsdevel-owner@vger.kernel.org] On
> Behalf Of Jaegeuk Kim
> Sent: Wednesday, January 28, 2015 7:32 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [PATCH 4/5] 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.

Now, with 'fastboot' option, f2fs will write cp with CP_UMOUNT_FLAG, but we count not
guarantee there is no abnormally power cut after data fsynced.

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/super.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 0ca1fb2..7039969 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,
> --
> 2.1.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
?? Jan. 30, 2015, 5:15 a.m. UTC | #2
> -----Original Message-----
> From: linux-fsdevel-owner@vger.kernel.org [mailto:linux-fsdevel-owner@vger.kernel.org] On
> Behalf Of Jaegeuk Kim
> Sent: Wednesday, January 28, 2015 7:32 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [PATCH 4/5] 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.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao2.yu@samsung.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 0ca1fb2..7039969 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,