Skip to content

Commit 9cca498

Browse files
Eric SandeenJaegeuk Kim
authored andcommitted
f2fs: defer readonly check vs norecovery
Defer the readonly-vs-norecovery check until after option parsing is done so that option parsing does not require an active superblock for the test. Add a helpful message, while we're at it. (I think could be moved back into parsing after we switch to the new mount API if desired, as the fs context will have RO state available.) Signed-off-by: Eric Sandeen <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 0edcb21 commit 9cca498

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/f2fs/super.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,8 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
730730
set_opt(sbi, DISABLE_ROLL_FORWARD);
731731
break;
732732
case Opt_norecovery:
733-
/* this option mounts f2fs with ro */
733+
/* requires ro mount, checked in f2fs_default_check */
734734
set_opt(sbi, NORECOVERY);
735-
if (!f2fs_readonly(sb))
736-
return -EINVAL;
737735
break;
738736
case Opt_discard:
739737
if (!f2fs_hw_support_discard(sbi)) {
@@ -1417,6 +1415,12 @@ static int f2fs_default_check(struct f2fs_sb_info *sbi)
14171415
f2fs_err(sbi, "Allow to mount readonly mode only");
14181416
return -EROFS;
14191417
}
1418+
1419+
if (test_opt(sbi, NORECOVERY) && !f2fs_readonly(sbi->sb)) {
1420+
f2fs_err(sbi, "norecovery requires readonly mount");
1421+
return -EINVAL;
1422+
}
1423+
14201424
return 0;
14211425
}
14221426

0 commit comments

Comments
 (0)