* [PATCH] libf2fs: Fix calculation of usable segments for single zoned
[not found] <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8>
@ 2024-10-07 5:21 ` Yonggil Song
2024-10-08 9:02 ` Chao Yu
2024-10-08 13:16 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Markus Elfring
0 siblings, 2 replies; 9+ messages in thread
From: Yonggil Song @ 2024-10-07 5:21 UTC (permalink / raw)
To: jaegeuk@kernel.org, chao@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Yonggil Song,
Siwoo Jung, Daejun Park
There was a bug that did not subtract the super block area when calculating
the usable segments for a single zoned device with a conventional zone.
This bug resulted in incorrect the overprovision and reserved area.
<256MiB legacy block + zoned block w/ 32MiB zone size>
Info: Overprovision ratio = 3.570%
Info: Overprovision segments = 656 (GC reserved = 560)
<8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
Info: Overprovision ratio = 3.700%
Info: Overprovision segments = 676 (GC reserved = 578)
This patch fixes the bug by subtracting the super block area when there is
only one zoned device.
Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
---
lib/libf2fs_zoned.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 89ba5ad73a76..cc5c064b7e3e 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
}
usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
get_sb(log_blocks_per_seg);
+
+ /* single zoned device needs to remove a super block area */
+ if (c.ndevs == 1)
+ usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
+
return usable_segs;
#endif
return get_sb(segment_count_main);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] libf2fs: Fix calculation of usable segments for single zoned
2024-10-07 5:21 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Yonggil Song
@ 2024-10-08 9:02 ` Chao Yu
2024-10-10 2:15 ` Yonggil Song
2024-10-08 13:16 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Markus Elfring
1 sibling, 1 reply; 9+ messages in thread
From: Chao Yu @ 2024-10-08 9:02 UTC (permalink / raw)
To: yonggil.song, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
Cc: Chao Yu
On 2024/10/7 13:21, Yonggil Song wrote:
> There was a bug that did not subtract the super block area when calculating
> the usable segments for a single zoned device with a conventional zone.
> This bug resulted in incorrect the overprovision and reserved area.
>
> <256MiB legacy block + zoned block w/ 32MiB zone size>
> Info: Overprovision ratio = 3.570%
> Info: Overprovision segments = 656 (GC reserved = 560)
>
> <8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
> Info: Overprovision ratio = 3.700%
> Info: Overprovision segments = 676 (GC reserved = 578)
>
> This patch fixes the bug by subtracting the super block area when there is
> only one zoned device.
>
> Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
> ---
> lib/libf2fs_zoned.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> index 89ba5ad73a76..cc5c064b7e3e 100644
> --- a/lib/libf2fs_zoned.c
> +++ b/lib/libf2fs_zoned.c
> @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
> }
> usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
> get_sb(log_blocks_per_seg);
> +
> + /* single zoned device needs to remove a super block area */
If we don't format zoned device, it doesn't need to do this?
Thanks,
> + if (c.ndevs == 1)
> + usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));> +
> return usable_segs;
> #endif
> return get_sb(segment_count_main);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] libf2fs: Fix calculation of usable segments for single zoned
2024-10-07 5:21 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Yonggil Song
2024-10-08 9:02 ` Chao Yu
@ 2024-10-08 13:16 ` Markus Elfring
1 sibling, 0 replies; 9+ messages in thread
From: Markus Elfring @ 2024-10-08 13:16 UTC (permalink / raw)
To: Yonggil Song, linux-f2fs-devel, Chao Yu, Daejun Park, Dongjin Kim,
Jaegeuk Kim, Siwoo Jung
Cc: LKML
…
> This patch fixes the bug by …
* How do you think about to choose another imperative wording
for an improved change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc2#n94
* Would you like to add any tags (like “Fixes” and “Cc”) accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE:(2) [PATCH] libf2fs: Fix calculation of usable segments for single zoned
2024-10-08 9:02 ` Chao Yu
@ 2024-10-10 2:15 ` Yonggil Song
2024-10-10 4:31 ` Yonggil Song
0 siblings, 1 reply; 9+ messages in thread
From: Yonggil Song @ 2024-10-10 2:15 UTC (permalink / raw)
To: Chao Yu, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
Cc: Yonggil Song
> On 2024/10/7 13:21, Yonggil Song wrote:
> > There was a bug that did not subtract the super block area when calculating
> > the usable segments for a single zoned device with a conventional zone.
> > This bug resulted in incorrect the overprovision and reserved area.
> >
> > <256MiB legacy block + zoned block w/ 32MiB zone size>
> > Info: Overprovision ratio = 3.570%
> > Info: Overprovision segments = 656 (GC reserved = 560)
> >
> > <8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
> > Info: Overprovision ratio = 3.700%
> > Info: Overprovision segments = 676 (GC reserved = 578)
> >
> > This patch fixes the bug by subtracting the super block area when there is
> > only one zoned device.
> >
> > Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
> > ---
> > lib/libf2fs_zoned.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> > index 89ba5ad73a76..cc5c064b7e3e 100644
> > --- a/lib/libf2fs_zoned.c
> > +++ b/lib/libf2fs_zoned.c
> > @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
> > }
> > usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
> > get_sb(log_blocks_per_seg);
> > +
> > + /* single zoned device needs to remove a super block area */
>
> If we don't format zoned device, it doesn't need to do this?
>
> Thanks,
>
Yes, single zoned block only needs this.
legacy block just return a segment_count_main.
thanks.
> > + if (c.ndevs == 1)
> > + usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));> +
> > return usable_segs;
> > #endif
> > return get_sb(segment_count_main);
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE:(3) [PATCH] libf2fs: Fix calculation of usable segments for single zoned
2024-10-10 2:15 ` Yonggil Song
@ 2024-10-10 4:31 ` Yonggil Song
2024-10-10 4:59 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Yonggil Song
0 siblings, 1 reply; 9+ messages in thread
From: Yonggil Song @ 2024-10-10 4:31 UTC (permalink / raw)
To: Yonggil Song, Chao Yu, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
> > On 2024/10/7 13:21, Yonggil Song wrote:
> > > There was a bug that did not subtract the super block area when calculating
> > > the usable segments for a single zoned device with a conventional zone.
> > > This bug resulted in incorrect the overprovision and reserved area.
> > >
> > > <256MiB legacy block + zoned block w/ 32MiB zone size>
> > > Info: Overprovision ratio = 3.570%
> > > Info: Overprovision segments = 656 (GC reserved = 560)
> > >
> > > <8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
> > > Info: Overprovision ratio = 3.700%
> > > Info: Overprovision segments = 676 (GC reserved = 578)
> > >
> > > This patch fixes the bug by subtracting the super block area when there is
> > > only one zoned device.
> > >
> > > Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
> > > ---
> > > lib/libf2fs_zoned.c | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> > > index 89ba5ad73a76..cc5c064b7e3e 100644
> > > --- a/lib/libf2fs_zoned.c
> > > +++ b/lib/libf2fs_zoned.c
> > > @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
> > > }
> > > usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
> > > get_sb(log_blocks_per_seg);
> > > +
> > > + /* single zoned device needs to remove a super block area */
> >
> > If we don't format zoned device, it doesn't need to do this?
> >
> > Thanks,
> >
> Yes, single zoned block only needs this.
>
> legacy block just return a segment_count_main.
>
> thanks.
Sorry, I misunderstood.
I'll resend v2 with zoned block checker.
thanks.
> > > + if (c.ndevs == 1)
> > > + usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));> +
> > > return usable_segs;
> > > #endif
> > > return get_sb(segment_count_main);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] libf2fs: Fix calculation of usable segments for single
2024-10-10 4:31 ` Yonggil Song
@ 2024-10-10 4:59 ` Yonggil Song
2024-10-10 5:08 ` [RESEND][PATCH v2] libf2fs: Fix calculation of usable segments for single zoned device Yonggil Song
2024-10-11 15:34 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Jaegeuk Kim
0 siblings, 2 replies; 9+ messages in thread
From: Yonggil Song @ 2024-10-10 4:59 UTC (permalink / raw)
To: Yonggil Song, Chao Yu, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
There was a problem that did not subtract the super block area when calculating
the usable segments for a single zoned device with a conventional zone.
This resulted in incorrect the overprovision and reserved area.
<256MiB legacy block + zoned block w/ 32MiB zone size>
Info: Overprovision ratio = 3.570%
Info: Overprovision segments = 656 (GC reserved = 560)
<8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
Info: Overprovision ratio = 3.700%
Info: Overprovision segments = 676 (GC reserved = 578)
This patch addresses the problem by subtracting the super block area when
there is only one zoned device.
Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
---
lib/libf2fs_zoned.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 89ba5ad73a76..1a0985378789 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
}
usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
get_sb(log_blocks_per_seg);
+
+ /* single zoned device needs to remove a super block area */
+ if (c.ndevs == 1 && c.devices[0].zoned_model == F2FS_ZONED_HM)
+ usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
+
return usable_segs;
#endif
return get_sb(segment_count_main);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [RESEND][PATCH v2] libf2fs: Fix calculation of usable segments for single zoned device
2024-10-10 4:59 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Yonggil Song
@ 2024-10-10 5:08 ` Yonggil Song
2024-10-11 15:34 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Jaegeuk Kim
1 sibling, 0 replies; 9+ messages in thread
From: Yonggil Song @ 2024-10-10 5:08 UTC (permalink / raw)
To: Yonggil Song, Chao Yu, jaegeuk@kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
There was a problem that did not subtract the super block area when calculating
the usable segments for a single zoned device with a conventional zone.
This resulted in incorrect the overprovision and reserved area.
<256MiB legacy block + zoned block w/ 32MiB zone size>
Info: Overprovision ratio = 3.570%
Info: Overprovision segments = 656 (GC reserved = 560)
<8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
Info: Overprovision ratio = 3.700%
Info: Overprovision segments = 676 (GC reserved = 578)
This patch addresses the problem by subtracting the super block area when
there is only one zoned device.
Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
---
lib/libf2fs_zoned.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index 89ba5ad73a76..1a0985378789 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
}
usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
get_sb(log_blocks_per_seg);
+
+ /* single zoned device needs to remove a super block area */
+ if (c.ndevs == 1 && c.devices[0].zoned_model == F2FS_ZONED_HM)
+ usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
+
return usable_segs;
#endif
return get_sb(segment_count_main);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] libf2fs: Fix calculation of usable segments for single
2024-10-10 4:59 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Yonggil Song
2024-10-10 5:08 ` [RESEND][PATCH v2] libf2fs: Fix calculation of usable segments for single zoned device Yonggil Song
@ 2024-10-11 15:34 ` Jaegeuk Kim
2024-10-14 1:43 ` Yonggil Song
1 sibling, 1 reply; 9+ messages in thread
From: Jaegeuk Kim @ 2024-10-11 15:34 UTC (permalink / raw)
To: Yonggil Song
Cc: Chao Yu, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park
On 10/10, Yonggil Song wrote:
> There was a problem that did not subtract the super block area when calculating
> the usable segments for a single zoned device with a conventional zone.
> This resulted in incorrect the overprovision and reserved area.
>
> <256MiB legacy block + zoned block w/ 32MiB zone size>
> Info: Overprovision ratio = 3.570%
> Info: Overprovision segments = 656 (GC reserved = 560)
>
> <8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
> Info: Overprovision ratio = 3.700%
> Info: Overprovision segments = 676 (GC reserved = 578)
>
> This patch addresses the problem by subtracting the super block area when
> there is only one zoned device.
>
> Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
> ---
> lib/libf2fs_zoned.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> index 89ba5ad73a76..1a0985378789 100644
> --- a/lib/libf2fs_zoned.c
> +++ b/lib/libf2fs_zoned.c
> @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
> }
> usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
> get_sb(log_blocks_per_seg);
> +
> + /* single zoned device needs to remove a super block area */
> + if (c.ndevs == 1 && c.devices[0].zoned_model == F2FS_ZONED_HM)
Does this work?
> + usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
> +
> return usable_segs;
> #endif
> return get_sb(segment_count_main);
> --
> 2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE:(2) [PATCH v2] libf2fs: Fix calculation of usable segments for single
2024-10-11 15:34 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Jaegeuk Kim
@ 2024-10-14 1:43 ` Yonggil Song
0 siblings, 0 replies; 9+ messages in thread
From: Yonggil Song @ 2024-10-14 1:43 UTC (permalink / raw)
To: Jaegeuk Kim
Cc: Chao Yu, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Dongjin Kim, Siwoo Jung,
Daejun Park, Yonggil Song
> On 10/10, Yonggil Song wrote:
> > There was a problem that did not subtract the super block area when calculating
> > the usable segments for a single zoned device with a conventional zone.
> > This resulted in incorrect the overprovision and reserved area.
> >
> > <256MiB legacy block + zoned block w/ 32MiB zone size>
> > Info: Overprovision ratio = 3.570%
> > Info: Overprovision segments = 656 (GC reserved = 560)
> >
> > <8 conventional zone + 1016 sequential zone w/ 32MiB zone size>
> > Info: Overprovision ratio = 3.700%
> > Info: Overprovision segments = 676 (GC reserved = 578)
> >
> > This patch addresses the problem by subtracting the super block area when
> > there is only one zoned device.
> >
> > Signed-off-by: Yonggil Song <yonggil.song@samsung.com>
> > ---
> > lib/libf2fs_zoned.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
> > index 89ba5ad73a76..1a0985378789 100644
> > --- a/lib/libf2fs_zoned.c
> > +++ b/lib/libf2fs_zoned.c
> > @@ -555,6 +555,11 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb)
> > }
> > usable_segs -= (get_sb(main_blkaddr) - get_sb(segment0_blkaddr)) >>
> > get_sb(log_blocks_per_seg);
> > +
> > + /* single zoned device needs to remove a super block area */
> > + if (c.ndevs == 1 && c.devices[0].zoned_model == F2FS_ZONED_HM)
>
> Does this work?
>
Yes, it works.
I have attached the results of test on null_blk below.
If you have any concerns, please feedback.
before after
legacy block (32GB) 136 (GC reserved = 130) 136 (GC reserved = 130)
single zoned block 676 (GC reserved = 578) 656 (GC reserved = 560)
(32GB, 32MB zone, 8 conv, 1016 seq)
legacy + zoned multi 656 (GC reserved = 560) 656 (GC reserved = 560)
(32GB, 256MB legacy block + 32MB zone, 1016 seq)
Thanks.
> > + usable_segs -= (get_sb(segment0_blkaddr) >> get_sb(log_blocks_per_seg));
> > +
> > return usable_segs;
> > #endif
> > return get_sb(segment_count_main);
> > --
> > 2.43.0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-10-14 1:43 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20241007052122epcms2p8a7a733c92a8da751ac64af8a29de0303@epcms2p8>
2024-10-07 5:21 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Yonggil Song
2024-10-08 9:02 ` Chao Yu
2024-10-10 2:15 ` Yonggil Song
2024-10-10 4:31 ` Yonggil Song
2024-10-10 4:59 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Yonggil Song
2024-10-10 5:08 ` [RESEND][PATCH v2] libf2fs: Fix calculation of usable segments for single zoned device Yonggil Song
2024-10-11 15:34 ` [PATCH v2] libf2fs: Fix calculation of usable segments for single Jaegeuk Kim
2024-10-14 1:43 ` Yonggil Song
2024-10-08 13:16 ` [PATCH] libf2fs: Fix calculation of usable segments for single zoned Markus Elfring
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).