* [f2fs-dev] [PATCH 1/2] resize.f2fs: fix wrong ovp calculation
@ 2021-04-02 3:26 Jaegeuk Kim
2021-04-02 3:26 ` [f2fs-dev] [PATCH 2/2] resize.f2fs: add force option to rewrite broken calculation Jaegeuk Kim
0 siblings, 1 reply; 2+ messages in thread
From: Jaegeuk Kim @ 2021-04-02 3:26 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
beroal reported a mount failure due to broken valid_user_blocks.
[ 6890.647749] F2FS-fs (loop0): Wrong valid_user_blocks: 16040048,
user_block_count: 10016768
From fsck,
segment_count_main [0x 9a95 : 39573]
-> 39573 * 2MB = 78GB as user space
overprov_segment_count [0x 4e29 : 20009]
-> 20009 * 2MB = 40GB as overprovisioned space which user can't see.
But,
[FSCK] valid_block_count matching with CP [Ok..] [0xf4c070]
-> 0xf4c070 = 16040048
valid_block_count [0x f4c070 : 16040048]
-> So, this is correct.
It turns out resize.f2fs gave very large and wrong overprovisioning space
result in shortage of user blocks. The root cause was f2fs_get_usable_segments()
didn't consider resize case which needs segment_count_main from new superblock.
Fixes: f8410857b7a8 ("f2fs-tools: zns zone-capacity support")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
lib/libf2fs_zoned.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 56c97d1a65f7..ce73b9af66ec 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -495,6 +495,9 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
int i, j;
uint32_t usable_segs = 0, zone_segs;
+ if (c.func == RESIZE)
+ return get_sb(segment_count_main);
+
for (i = 0; i < c.ndevs; i++) {
if (c.devices[i].zoned_model != F2FS_ZONED_HM) {
usable_segs += c.devices[i].total_segments;
--
2.31.0.208.g409f899ff0-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [f2fs-dev] [PATCH 2/2] resize.f2fs: add force option to rewrite broken calculation
2021-04-02 3:26 [f2fs-dev] [PATCH 1/2] resize.f2fs: fix wrong ovp calculation Jaegeuk Kim
@ 2021-04-02 3:26 ` Jaegeuk Kim
0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2021-04-02 3:26 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim
This patch adds "-f" for resize.f2fs to fix broken resized f2fs.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fsck/main.c | 6 +++++-
fsck/resize.c | 5 +++--
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/fsck/main.c b/fsck/main.c
index be30e0073a5e..64efa8789cd4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -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;
diff --git a/fsck/resize.c b/fsck/resize.c
index 46b1cfb218cf..0425498b9760 100644
--- a/fsck/resize.c
+++ b/fsck/resize.c
@@ -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");
--
2.31.0.208.g409f899ff0-goog
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-02 3:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-02 3:26 [f2fs-dev] [PATCH 1/2] resize.f2fs: fix wrong ovp calculation Jaegeuk Kim
2021-04-02 3:26 ` [f2fs-dev] [PATCH 2/2] resize.f2fs: add force option to rewrite broken calculation Jaegeuk Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).