Commit 23738e74 authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim
Browse files

f2fs: fix to restrict mount condition on readonly block device



When we mount an unclean f2fs image in a readonly block device, let's
make mount() succeed only when there is no recoverable data in that
image, otherwise after mount(), file fsyned won't be recovered as user
expected.

Fixes: 938a1842 ("f2fs: give a warning only for readonly partition")
Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 5911d2d1
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -3966,9 +3966,17 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
		 * previous checkpoint was not done by clean system shutdown.
		 */
		if (f2fs_hw_is_readonly(sbi)) {
			if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG))
				f2fs_err(sbi, "Need to recover fsync data, but write access unavailable");
			else
			if (!is_set_ckpt_flags(sbi, CP_UMOUNT_FLAG)) {
				err = f2fs_recover_fsync_data(sbi, true);
				if (err > 0) {
					err = -EROFS;
					f2fs_err(sbi, "Need to recover fsync data, but "
						"write access unavailable, please try "
						"mount w/ disable_roll_forward or norecovery");
				}
				if (err < 0)
					goto free_meta;
			}
			f2fs_info(sbi, "write access unavailable, skipping recovery");
			goto reset_checkpoint;
		}