On Oct 10, 2022 / 15:15, Jaegeuk Kim wrote:
> As f2fs becomes more resilient for GCs, let's give the marginal overprovision
> space back to user.
>
> Signed-off-by: Jaegeuk Kim <[email protected]>
Hello Jaegeuk,
Using the dev branch of f2fs-tools repo, I observed mkfs.f2fs failure with zoned
block devices:
Error: Device size is not sufficient for F2FS volume
I found this patch in the branch triggers it. I also observed the same failure
is observed with non- zoned regular block devices when I specify -s options to
mkfs.f2fs command. With these conditions, number of segments in each section is
not zero, and it increases the number of reserved segments. My understanding is
that it makes reserved segments larger than overprovisioning segments all the
time in the loop of get_best_overprovision(). Then get_best_overprovision()
returns 0% overprovisioning ratio. Hence the error.
Could you take a look for fix?
FYI, I tried to fix and created a patch which allows reserved segments larger
than overprovisioning segments [1]. It compares those two, and take larger one
to subtract from usable segments to get the segments for users. I confirmed it
keeps small number of overprovisioning segments for no -s option case, and
avoids the mkfs.f2fs failure for the -s option and zoned block device cases.
However, it increases runtime of my test script which fills f2fs and do file
overwrites to test f2fs GC on zoned block devices. It takes +60% longer runtime.
Then GC performance looks worse than before, and this fix does not look good
for me.
[1]
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 8ca574a..4902953 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1634,9 +1634,10 @@ static inline double get_best_overprovision(struct
f2fs_super_block *sb)
reserved = (100 / candidate + 1 + NR_CURSEG_TYPE) *
round_up(usable_main_segs,
get_sb(section_count));
ovp = (usable_main_segs - reserved) * candidate / 100;
- if (reserved >= ovp)
+ if (ovp < 0)
continue;
- space = usable_main_segs - ovp;
+
+ space = usable_main_segs - max(reserved, ovp);
if (max_space < space) {
max_space = space;
max_ovp = candidate;
diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c
index c314d1c..08f4e66 100644
--- a/mkfs/f2fs_format.c
+++ b/mkfs/f2fs_format.c
@@ -764,11 +764,8 @@ static int f2fs_write_check_point_pack(void)
set_cp(overprov_segment_count, (f2fs_get_usable_segments(sb) -
get_cp(rsvd_segment_count)) *
c.overprovision / 100);
-
- if (get_cp(rsvd_segment_count) > get_cp(overprov_segment_count)) {
- MSG(0, "\tError: Wrong overprovision ratio\n");
- goto free_cp_payload;
- }
+ if (get_cp(overprov_segment_count) < get_cp(rsvd_segment_count))
+ set_cp(overprov_segment_count, get_cp(rsvd_segment_count));
if (f2fs_get_usable_segments(sb) <= get_cp(overprov_segment_count)) {
MSG(0, "\tError: Not enough segments to create F2FS Volume\n");
--
Shin'ichiro Kawasaki
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel