linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size
@ 2025-05-22 18:26 Daeho Jeong
  2025-05-23  2:06 ` [f2fs-dev] " Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Daeho Jeong @ 2025-05-22 18:26 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel, kernel-team; +Cc: Daeho Jeong

From: Daeho Jeong <daehojeong@google.com>

Otherwise, it doesn't work with a crash.

Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
v2: relocate the code
---
 lib/libf2fs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index d2579d7..148dc12 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -1347,6 +1347,11 @@ int f2fs_get_f2fs_info(void)
 			}
 			c.zone_blocks = c.devices[i].zone_blocks;
 		}
+		if (c.zone_blocks < DEFAULT_BLOCKS_PER_SEGMENT) {
+			MSG(0, "\tError: zone size should not be less "
+				"than segment size\n");
+			return -1;
+		}
 
 		/*
 		 * Align sections to the device zone size and align F2FS zones
-- 
2.49.0.1151.ga128411c76-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size
  2025-05-22 18:26 [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size Daeho Jeong
@ 2025-05-23  2:06 ` Chao Yu
  2025-05-23 16:40   ` Daeho Jeong
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2025-05-23  2:06 UTC (permalink / raw)
  To: Daeho Jeong, linux-kernel, linux-f2fs-devel, kernel-team
  Cc: chao, Daeho Jeong

On 5/23/25 02:26, Daeho Jeong wrote:
> From: Daeho Jeong <daehojeong@google.com>
> 
> Otherwise, it doesn't work with a crash.
> 
> Signed-off-by: Daeho Jeong <daehojeong@google.com>
> ---
> v2: relocate the code
> ---
>  lib/libf2fs.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> index d2579d7..148dc12 100644
> --- a/lib/libf2fs.c
> +++ b/lib/libf2fs.c
> @@ -1347,6 +1347,11 @@ int f2fs_get_f2fs_info(void)
>  			}
>  			c.zone_blocks = c.devices[i].zone_blocks;
>  		}
> +		if (c.zone_blocks < DEFAULT_BLOCKS_PER_SEGMENT) {

If c.zone_blocks can not be aligned to DEFAULT_BLOCKS_PER_SEGMENT, do we need to
handle below code?

		/*
		 * Align sections to the device zone size and align F2FS zones
		 * to the device zones. For F2FS_ZONED_HA model without the
		 * BLKZONED feature set at format time, this is only an
		 * optimization as sequential writes will not be enforced.
		 */
		c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;

Thanks,

> +			MSG(0, "\tError: zone size should not be less "
> +				"than segment size\n");
> +			return -1;
> +		}
>  
>  		/*
>  		 * Align sections to the device zone size and align F2FS zones


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size
  2025-05-23  2:06 ` [f2fs-dev] " Chao Yu
@ 2025-05-23 16:40   ` Daeho Jeong
  2025-05-26  8:02     ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Daeho Jeong @ 2025-05-23 16:40 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel, kernel-team, Daeho Jeong

On Thu, May 22, 2025 at 7:06 PM Chao Yu <chao@kernel.org> wrote:
>
> On 5/23/25 02:26, Daeho Jeong wrote:
> > From: Daeho Jeong <daehojeong@google.com>
> >
> > Otherwise, it doesn't work with a crash.
> >
> > Signed-off-by: Daeho Jeong <daehojeong@google.com>
> > ---
> > v2: relocate the code
> > ---
> >  lib/libf2fs.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/lib/libf2fs.c b/lib/libf2fs.c
> > index d2579d7..148dc12 100644
> > --- a/lib/libf2fs.c
> > +++ b/lib/libf2fs.c
> > @@ -1347,6 +1347,11 @@ int f2fs_get_f2fs_info(void)
> >                       }
> >                       c.zone_blocks = c.devices[i].zone_blocks;
> >               }
> > +             if (c.zone_blocks < DEFAULT_BLOCKS_PER_SEGMENT) {
>
> If c.zone_blocks can not be aligned to DEFAULT_BLOCKS_PER_SEGMENT, do we need to
> handle below code?

We need to make sure that c.zone_blocks is a multiple of
DEFAULT_BLOCKS_PER_SEGMENT, right?

>
>                 /*
>                  * Align sections to the device zone size and align F2FS zones
>                  * to the device zones. For F2FS_ZONED_HA model without the
>                  * BLKZONED feature set at format time, this is only an
>                  * optimization as sequential writes will not be enforced.
>                  */
>                 c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>
> Thanks,
>
> > +                     MSG(0, "\tError: zone size should not be less "
> > +                             "than segment size\n");
> > +                     return -1;
> > +             }
> >
> >               /*
> >                * Align sections to the device zone size and align F2FS zones
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [f2fs-dev] [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size
  2025-05-23 16:40   ` Daeho Jeong
@ 2025-05-26  8:02     ` Chao Yu
  0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2025-05-26  8:02 UTC (permalink / raw)
  To: Daeho Jeong
  Cc: chao, linux-kernel, linux-f2fs-devel, kernel-team, Daeho Jeong

On 5/24/25 00:40, Daeho Jeong wrote:
> On Thu, May 22, 2025 at 7:06 PM Chao Yu <chao@kernel.org> wrote:
>>
>> On 5/23/25 02:26, Daeho Jeong wrote:
>>> From: Daeho Jeong <daehojeong@google.com>
>>>
>>> Otherwise, it doesn't work with a crash.
>>>
>>> Signed-off-by: Daeho Jeong <daehojeong@google.com>
>>> ---
>>> v2: relocate the code
>>> ---
>>>  lib/libf2fs.c | 5 +++++
>>>  1 file changed, 5 insertions(+)
>>>
>>> diff --git a/lib/libf2fs.c b/lib/libf2fs.c
>>> index d2579d7..148dc12 100644
>>> --- a/lib/libf2fs.c
>>> +++ b/lib/libf2fs.c
>>> @@ -1347,6 +1347,11 @@ int f2fs_get_f2fs_info(void)
>>>                       }
>>>                       c.zone_blocks = c.devices[i].zone_blocks;
>>>               }
>>> +             if (c.zone_blocks < DEFAULT_BLOCKS_PER_SEGMENT) {
>>
>> If c.zone_blocks can not be aligned to DEFAULT_BLOCKS_PER_SEGMENT, do we need to
>> handle below code?
> 
> We need to make sure that c.zone_blocks is a multiple of
> DEFAULT_BLOCKS_PER_SEGMENT, right?

Yes, if c.zone_blocks % DEFAULT_BLOCKS_PER_SEGMENT is true, we should fail mkfs?

Thanks,

> 
>>
>>                 /*
>>                  * Align sections to the device zone size and align F2FS zones
>>                  * to the device zones. For F2FS_ZONED_HA model without the
>>                  * BLKZONED feature set at format time, this is only an
>>                  * optimization as sequential writes will not be enforced.
>>                  */
>>                 c.segs_per_sec = c.zone_blocks / DEFAULT_BLOCKS_PER_SEGMENT;
>>
>> Thanks,
>>
>>> +                     MSG(0, "\tError: zone size should not be less "
>>> +                             "than segment size\n");
>>> +                     return -1;
>>> +             }
>>>
>>>               /*
>>>                * Align sections to the device zone size and align F2FS zones
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-26  8:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22 18:26 [PATCH v2] mkfs.f2fs: ensure zone size is equal or bigger than segment size Daeho Jeong
2025-05-23  2:06 ` [f2fs-dev] " Chao Yu
2025-05-23 16:40   ` Daeho Jeong
2025-05-26  8:02     ` Chao Yu

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).