* [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed
@ 2025-05-16 11:10 Cherniaev Andrei
2025-07-29 14:59 ` Jaegeuk Kim via Linux-f2fs-devel
2025-07-30 7:26 ` Chao Yu via Linux-f2fs-devel
0 siblings, 2 replies; 3+ messages in thread
From: Cherniaev Andrei @ 2025-05-16 11:10 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: jaegeuk, Cherniaev Andrei
I think my optimization makes mkfs.f2fs faster in case of invalid volume size. So with the commit user will get err faster.
Before start I suggest add debug printf() to `f2fs_fs.h` like this:
```
for (; candidate <= end; candidate += diff) {
reserved = get_reserved(sb, candidate);
ovp = (usable_main_segs - reserved) * candidate / 100;
MSG(0, "ovp=%f usable_main_segs=%u reserved=%u candidate=%f\n", ovp, usable_main_segs, reserved, candidate); //debug printf()
if (ovp <= 0)
continue;
space = usable_main_segs - max((double)reserved, ovp) -
overprovision_segment_buffer(sb);
MSG(0, "space=%f max_space=%f\n", space, max_space); //debug printf()
if (max_space < space) {
max_space = space;
max_ovp = candidate;
}
}
```
Test instruction is based on "boot/grub2/readme.txt" https://gitlab.com/buildroot.org/buildroot/-/blob/master/boot/grub2/readme.txt You can use Ubuntu 24 or similar OS.
1. Create a disk image
```
cd /tmp
dd if=/dev/zero of=disk.img bs=1M count=32
```
2. Partition it with GPT partitions usinig `cgdisk disk.img` or
```
parted --script disk.img mklabel gpt mkpart primary 1MiB 31MiB
```
3. Setup loop device and loop partitions
```
loop_dev=$(sudo losetup -f --show disk.img)
sudo partx -a "$loop_dev"
```
5. Prepare the root partition
```
sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
```
6. Cleanup loop device
```
partx -d "$loop_dev"
losetup -d "$loop_dev"
```
In log you can see that for ovp==0.0 space calculation looks not necessary...
```
a@Linux:~$ sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2025-05-06)
Info: Debug level = 0
Info: Add new cold file extension list
Info: Add new hot file extension list
Info: Label = mylable123
Info: Trim is enabled
Info: Enable Compression
Info: Segments per section = 1
Info: Sections per zone = 1
Info: sector size = 512
Info: total sectors = 65536 (32 MB)
Info: zone aligned segment0 blkaddr: 512
ovp=429496728.700000 usable_main_segs=8 reserved=17 candidate=10.000000
space=-429496726.700000 max_space=0.000000
ovp=644245093.650000 usable_main_segs=8 reserved=13 candidate=15.000000
space=-644245091.650000 max_space=0.000000
ovp=858993458.400000 usable_main_segs=8 reserved=12 candidate=20.000000
space=-858993456.400000 max_space=0.000000
ovp=1073741823.250000 usable_main_segs=8 reserved=11 candidate=25.000000
space=-1073741821.250000 max_space=0.000000
ovp=1288490188.200000 usable_main_segs=8 reserved=10 candidate=30.000000
space=-1288490186.200000 max_space=0.000000
ovp=1503238553.250000 usable_main_segs=8 reserved=9 candidate=35.000000
space=-1503238551.250000 max_space=0.000000
ovp=1717986918.000000 usable_main_segs=8 reserved=9 candidate=40.000000
space=-1717986916.000000 max_space=0.000000
ovp=1932735282.750000 usable_main_segs=8 reserved=9 candidate=45.000000
space=-1932735280.750000 max_space=0.000000
ovp=2147483647.500000 usable_main_segs=8 reserved=9 candidate=50.000000
space=-2147483645.500000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=55.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=60.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=65.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=70.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=75.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=80.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=85.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=90.000000
space=-6.000000 max_space=0.000000
ovp=0.000000 usable_main_segs=8 reserved=8 candidate=95.000000
space=-6.000000 max_space=0.000000
Error: Device size is not sufficient for F2FS volume
Error: Failed to prepare a super block!!!
Error: Could not format the device!!!
```
Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
---
include/f2fs_fs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index f7268d1..41755af 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1891,7 +1891,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
for (; candidate <= end; candidate += diff) {
reserved = get_reserved(sb, candidate);
ovp = (usable_main_segs - reserved) * candidate / 100;
- if (ovp < 0)
+ if (ovp <= 0)
continue;
space = usable_main_segs - max((double)reserved, ovp) -
overprovision_segment_buffer(sb);
--
2.45.2
_______________________________________________
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] 3+ messages in thread* Re: [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed
2025-05-16 11:10 [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed Cherniaev Andrei
@ 2025-07-29 14:59 ` Jaegeuk Kim via Linux-f2fs-devel
2025-07-30 7:26 ` Chao Yu via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim via Linux-f2fs-devel @ 2025-07-29 14:59 UTC (permalink / raw)
To: Cherniaev Andrei; +Cc: linux-f2fs-devel
Applied with limiting 80 columns.
On 05/16, Cherniaev Andrei wrote:
> I think my optimization makes mkfs.f2fs faster in case of invalid volume size. So with the commit user will get err faster.
> Before start I suggest add debug printf() to `f2fs_fs.h` like this:
> ```
> for (; candidate <= end; candidate += diff) {
> reserved = get_reserved(sb, candidate);
> ovp = (usable_main_segs - reserved) * candidate / 100;
> MSG(0, "ovp=%f usable_main_segs=%u reserved=%u candidate=%f\n", ovp, usable_main_segs, reserved, candidate); //debug printf()
> if (ovp <= 0)
> continue;
> space = usable_main_segs - max((double)reserved, ovp) -
> overprovision_segment_buffer(sb);
> MSG(0, "space=%f max_space=%f\n", space, max_space); //debug printf()
> if (max_space < space) {
> max_space = space;
> max_ovp = candidate;
> }
> }
> ```
>
> Test instruction is based on "boot/grub2/readme.txt" https://gitlab.com/buildroot.org/buildroot/-/blob/master/boot/grub2/readme.txt You can use Ubuntu 24 or similar OS.
> 1. Create a disk image
> ```
> cd /tmp
> dd if=/dev/zero of=disk.img bs=1M count=32
> ```
> 2. Partition it with GPT partitions usinig `cgdisk disk.img` or
> ```
> parted --script disk.img mklabel gpt mkpart primary 1MiB 31MiB
> ```
> 3. Setup loop device and loop partitions
> ```
> loop_dev=$(sudo losetup -f --show disk.img)
> sudo partx -a "$loop_dev"
> ```
> 5. Prepare the root partition
> ```
> sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
> ```
> 6. Cleanup loop device
> ```
> partx -d "$loop_dev"
> losetup -d "$loop_dev"
> ```
> In log you can see that for ovp==0.0 space calculation looks not necessary...
> ```
> a@Linux:~$ sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
>
> F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2025-05-06)
>
> Info: Debug level = 0
> Info: Add new cold file extension list
> Info: Add new hot file extension list
> Info: Label = mylable123
> Info: Trim is enabled
> Info: Enable Compression
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 65536 (32 MB)
> Info: zone aligned segment0 blkaddr: 512
> ovp=429496728.700000 usable_main_segs=8 reserved=17 candidate=10.000000
> space=-429496726.700000 max_space=0.000000
> ovp=644245093.650000 usable_main_segs=8 reserved=13 candidate=15.000000
> space=-644245091.650000 max_space=0.000000
> ovp=858993458.400000 usable_main_segs=8 reserved=12 candidate=20.000000
> space=-858993456.400000 max_space=0.000000
> ovp=1073741823.250000 usable_main_segs=8 reserved=11 candidate=25.000000
> space=-1073741821.250000 max_space=0.000000
> ovp=1288490188.200000 usable_main_segs=8 reserved=10 candidate=30.000000
> space=-1288490186.200000 max_space=0.000000
> ovp=1503238553.250000 usable_main_segs=8 reserved=9 candidate=35.000000
> space=-1503238551.250000 max_space=0.000000
> ovp=1717986918.000000 usable_main_segs=8 reserved=9 candidate=40.000000
> space=-1717986916.000000 max_space=0.000000
> ovp=1932735282.750000 usable_main_segs=8 reserved=9 candidate=45.000000
> space=-1932735280.750000 max_space=0.000000
> ovp=2147483647.500000 usable_main_segs=8 reserved=9 candidate=50.000000
> space=-2147483645.500000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=55.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=60.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=65.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=70.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=75.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=80.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=85.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=90.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=95.000000
> space=-6.000000 max_space=0.000000
> Error: Device size is not sufficient for F2FS volume
> Error: Failed to prepare a super block!!!
> Error: Could not format the device!!!
> ```
>
> Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
> ---
> include/f2fs_fs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> index f7268d1..41755af 100644
> --- a/include/f2fs_fs.h
> +++ b/include/f2fs_fs.h
> @@ -1891,7 +1891,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb)
> for (; candidate <= end; candidate += diff) {
> reserved = get_reserved(sb, candidate);
> ovp = (usable_main_segs - reserved) * candidate / 100;
> - if (ovp < 0)
> + if (ovp <= 0)
> continue;
> space = usable_main_segs - max((double)reserved, ovp) -
> overprovision_segment_buffer(sb);
> --
> 2.45.2
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed
2025-05-16 11:10 [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed Cherniaev Andrei
2025-07-29 14:59 ` Jaegeuk Kim via Linux-f2fs-devel
@ 2025-07-30 7:26 ` Chao Yu via Linux-f2fs-devel
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu via Linux-f2fs-devel @ 2025-07-30 7:26 UTC (permalink / raw)
To: Cherniaev Andrei, linux-f2fs-devel; +Cc: jaegeuk
On 5/16/25 19:10, Cherniaev Andrei wrote:
> I think my optimization makes mkfs.f2fs faster in case of invalid volume size. So with the commit user will get err faster.
> Before start I suggest add debug printf() to `f2fs_fs.h` like this:
> ```
> for (; candidate <= end; candidate += diff) {
> reserved = get_reserved(sb, candidate);
> ovp = (usable_main_segs - reserved) * candidate / 100;
> MSG(0, "ovp=%f usable_main_segs=%u reserved=%u candidate=%f\n", ovp, usable_main_segs, reserved, candidate); //debug printf()
> if (ovp <= 0)
> continue;
> space = usable_main_segs - max((double)reserved, ovp) -
> overprovision_segment_buffer(sb);
> MSG(0, "space=%f max_space=%f\n", space, max_space); //debug printf()
> if (max_space < space) {
> max_space = space;
> max_ovp = candidate;
> }
> }
> ```
>
> Test instruction is based on "boot/grub2/readme.txt" https://gitlab.com/buildroot.org/buildroot/-/blob/master/boot/grub2/readme.txt You can use Ubuntu 24 or similar OS.
> 1. Create a disk image
> ```
> cd /tmp
> dd if=/dev/zero of=disk.img bs=1M count=32
> ```
> 2. Partition it with GPT partitions usinig `cgdisk disk.img` or
> ```
> parted --script disk.img mklabel gpt mkpart primary 1MiB 31MiB
> ```
> 3. Setup loop device and loop partitions
> ```
> loop_dev=$(sudo losetup -f --show disk.img)
> sudo partx -a "$loop_dev"
> ```
> 5. Prepare the root partition
> ```
> sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
> ```
> 6. Cleanup loop device
> ```
> partx -d "$loop_dev"
> losetup -d "$loop_dev"
> ```
> In log you can see that for ovp==0.0 space calculation looks not necessary...
> ```
> a@Linux:~$ sudo mkfs.f2fs -f -l mylable123 -i -O extra_attr,inode_checksum,sb_checksum,compression -e raw -E bin "$loop_dev"
>
> F2FS-tools: mkfs.f2fs Ver: 1.16.0 (2025-05-06)
>
> Info: Debug level = 0
> Info: Add new cold file extension list
> Info: Add new hot file extension list
> Info: Label = mylable123
> Info: Trim is enabled
> Info: Enable Compression
> Info: Segments per section = 1
> Info: Sections per zone = 1
> Info: sector size = 512
> Info: total sectors = 65536 (32 MB)
> Info: zone aligned segment0 blkaddr: 512
> ovp=429496728.700000 usable_main_segs=8 reserved=17 candidate=10.000000
> space=-429496726.700000 max_space=0.000000
> ovp=644245093.650000 usable_main_segs=8 reserved=13 candidate=15.000000
> space=-644245091.650000 max_space=0.000000
> ovp=858993458.400000 usable_main_segs=8 reserved=12 candidate=20.000000
> space=-858993456.400000 max_space=0.000000
> ovp=1073741823.250000 usable_main_segs=8 reserved=11 candidate=25.000000
> space=-1073741821.250000 max_space=0.000000
> ovp=1288490188.200000 usable_main_segs=8 reserved=10 candidate=30.000000
> space=-1288490186.200000 max_space=0.000000
> ovp=1503238553.250000 usable_main_segs=8 reserved=9 candidate=35.000000
> space=-1503238551.250000 max_space=0.000000
> ovp=1717986918.000000 usable_main_segs=8 reserved=9 candidate=40.000000
> space=-1717986916.000000 max_space=0.000000
> ovp=1932735282.750000 usable_main_segs=8 reserved=9 candidate=45.000000
> space=-1932735280.750000 max_space=0.000000
> ovp=2147483647.500000 usable_main_segs=8 reserved=9 candidate=50.000000
> space=-2147483645.500000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=55.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=60.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=65.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=70.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=75.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=80.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=85.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=90.000000
> space=-6.000000 max_space=0.000000
> ovp=0.000000 usable_main_segs=8 reserved=8 candidate=95.000000
> space=-6.000000 max_space=0.000000
> Error: Device size is not sufficient for F2FS volume
> Error: Failed to prepare a super block!!!
> Error: Could not format the device!!!
> ```
>
> Signed-off-by: Cherniaev Andrei <dungeonlords789@naver.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-30 7:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 11:10 [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed Cherniaev Andrei
2025-07-29 14:59 ` Jaegeuk Kim via Linux-f2fs-devel
2025-07-30 7:26 ` Chao Yu via Linux-f2fs-devel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.