All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Cherniaev Andrei <dungeonlords789@naver.com>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/1] f2fs-tools: increase overprovision finding speed
Date: Tue, 29 Jul 2025 14:59:28 +0000	[thread overview]
Message-ID: <aIjh0Moy6-MJmTE-@google.com> (raw)
In-Reply-To: <20250516111026.134657-1-dungeonlords789@naver.com>

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

  reply	other threads:[~2025-07-29 14:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-07-30  7:26 ` Chao Yu via Linux-f2fs-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIjh0Moy6-MJmTE-@google.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=dungeonlords789@naver.com \
    --cc=jaegeuk@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.