Skip to content

Commit

Permalink
f2fs: fix to avoid changing 'check only' behaior of recovery
Browse files Browse the repository at this point in the history
The following two 'check only recovery' processes are very dependent on
the return value of f2fs_recover_fsync_data, especially when the return
value is greater than 0.
1. when device has readonly mode, shown as commit
23738e7 ("f2fs: fix to restrict mount condition on readonly block device")
2. mount optiont NORECOVERY or DISABLE_ROLL_FORWARD is set, shown as commit
6781eab ("f2fs: give -EINVAL for norecovery and rw mount")

However, commit c426d99 ("f2fs: Check write pointer consistency of open zones")
will change the return value unexpectedly, thereby changing the caller's behavior

This patch let the f2fs_recover_fsync_data return correct value,and not do
f2fs_check_and_fix_write_pointer when the device is read-only.

Fixes: c426d99 ("f2fs: Check write pointer consistency of open zones")
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Zhiguo Niu authored and Jaegeuk Kim committed Jan 22, 2025
1 parent 6d4008d commit edf3c08
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions fs/f2fs/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
* and the f2fs is not read only, check and fix zoned block devices'
* write pointer consistency.
*/
if (!err) {
if (!err)
err = f2fs_check_and_fix_write_pointer(sbi);
ret = err;
}

if (!err)
clear_sbi_flag(sbi, SBI_POR_DOING);
Expand Down
3 changes: 2 additions & 1 deletion fs/f2fs/segment.c
Original file line number Diff line number Diff line change
Expand Up @@ -5462,7 +5462,8 @@ int f2fs_check_and_fix_write_pointer(struct f2fs_sb_info *sbi)
{
int ret;

if (!f2fs_sb_has_blkzoned(sbi) || f2fs_readonly(sbi->sb))
if (!f2fs_sb_has_blkzoned(sbi) || f2fs_readonly(sbi->sb) ||
f2fs_hw_is_readonly(sbi))
return 0;

f2fs_notice(sbi, "Checking entire write pointers");
Expand Down

0 comments on commit edf3c08

Please sign in to comment.