resize.f2fs: add force option to rewrite broken calculation

This patch adds "-f" for resize.f2fs to fix broken resized f2fs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim 2021-04-01 20:25:32 -07:00
parent f056fbeff0
commit 98e64635bd
2 changed files with 8 additions and 3 deletions

View File

@ -506,7 +506,7 @@ void f2fs_parse_options(int argc, char *argv[])
#endif
} else if (!strcmp("resize.f2fs", prog)) {
#ifdef WITH_RESIZE
const char *option_string = "d:st:iV";
const char *option_string = "d:fst:iV";
c.func = RESIZE;
while ((option = getopt(argc, argv, option_string)) != EOF) {
@ -522,6 +522,10 @@ void f2fs_parse_options(int argc, char *argv[])
MSG(0, "Info: Debug level = %d\n",
c.dbg_lv);
break;
case 'f':
c.force = 1;
MSG(0, "Info: Force to resize\n");
break;
case 's':
c.safe_resize = 1;
break;

View File

@ -714,8 +714,9 @@ int f2fs_resize(struct f2fs_sb_info *sbi)
} else {
return f2fs_resize_shrink(sbi);
}
else if ((c.target_sectors * c.sector_size >>
get_sb(log_blocksize)) > get_sb(block_count))
else if (((c.target_sectors * c.sector_size >>
get_sb(log_blocksize)) > get_sb(block_count)) ||
c.force)
return f2fs_resize_grow(sbi);
else {
MSG(0, "Nothing to resize.\n");