Skip to content

Commit

Permalink
f2fs: fix to restrict mount condition on readonly block device
Browse files Browse the repository at this point in the history
[ Upstream commit 23738e7 ]

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: 938a184 ("f2fs: give a warning only for readonly partition")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
chaseyu authored and gregkh committed May 19, 2021
1 parent 70dbc32 commit 83e2064
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fs/f2fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -3929,10 +3929,18 @@ 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
f2fs_info(sbi, "write access unavailable, skipping recovery");
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;
}

Expand Down

0 comments on commit 83e2064

Please sign in to comment.