aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2021-04-01 20:13:55 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2021-04-01 20:19:10 -0700
commitf056fbeff08d30a6d9acdb9e06704461ceee3500 (patch)
tree638de96bff9013be60c9c1effb279bb00b093ec2
parent80dba0f97549d5fc45ea1530a02da51c5908082c (diff)
downloadf2fs-tools-f056fbeff08d30a6d9acdb9e06704461ceee3500.tar.gz
resize.f2fs: fix wrong ovp calculation
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>
-rw-r--r--lib/libf2fs_zoned.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 56c97d1..ce73b9a 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;