mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] f2fs: fix zoned block device information initialization
@ 2024-01-23  8:12 Wenjie Qi
  2024-01-23  9:18 ` [f2fs-dev] " Yongpeng Yang
  0 siblings, 1 reply; 4+ messages in thread
From: Wenjie Qi @ 2024-01-23  8:12 UTC (permalink / raw)
  To: jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj, Wenjie Qi

If the max active zones of zoned devices are less than
the active logs of F2FS, the device may error due to
insufficient zone resources when multiple active logs are
being written at the same time. If this value is 0, there is no limit.

Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
---
 fs/f2fs/f2fs.h  |  1 +
 fs/f2fs/super.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 65294e3b0bef..669f84f6b0e5 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1551,6 +1551,7 @@ struct f2fs_sb_info {
 
 #ifdef CONFIG_BLK_DEV_ZONED
 	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
+	unsigned int max_active_zones;		/* max zone resources of the zoned device */
 #endif
 
 	/* for node-related operations */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 206d03c82d96..aef41b54098c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2385,6 +2385,16 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 	if (err)
 		goto restore_opts;
 
+#ifdef CONFIG_BLK_DEV_ZONED
+	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max active zones %u is too small, need at least %u active zones",
+				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
+		err = -EINVAL;
+		goto restore_opts;
+	}
+#endif
+
 	/* flush outstanding errors before changing fs state */
 	flush_work(&sbi->s_error_work);
 
@@ -3932,6 +3942,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
 	if (!f2fs_sb_has_blkzoned(sbi))
 		return 0;
 
+	sbi->max_active_zones = bdev_max_active_zones(bdev);
+	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max active zones %u is too small, need at least %u active zones",
+				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
+		return -EINVAL;
+	}
+
 	zone_sectors = bdev_zone_sectors(bdev);
 	if (!is_power_of_2(zone_sectors)) {
 		f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");
-- 
2.34.1


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

* Re: [f2fs-dev] [PATCH v3] f2fs: fix zoned block device information initialization
  2024-01-23  8:12 [PATCH v3] f2fs: fix zoned block device information initialization Wenjie Qi
@ 2024-01-23  9:18 ` Yongpeng Yang
  2024-02-01 14:47   ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Yongpeng Yang @ 2024-01-23  9:18 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

Hi Wenjie,
It seems more reasonable to use bdev_max_open_zones instead of 
bdev_max_active_zones.

If an NVMe device has multiple namespaces, and the device contains a 
total of 11 open zones, two of the namespaces, nvme0n1 and nvme0n2, each 
correspond to an instance of the F2FS filesystem, and both filesystem 
instances can be initialized successfully. Since multiple namespaces 
share all open zones, the number of open zones is not equal to the 
number of open zones available to F2FS in a multi-namespace scenario. 
This patch does not yet cover this scenario.

On 1/23/2024 4:12 PM, Wenjie Qi wrote:
> If the max active zones of zoned devices are less than
> the active logs of F2FS, the device may error due to
> insufficient zone resources when multiple active logs are
> being written at the same time. If this value is 0, there is no limit.
> 
> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> ---
>   fs/f2fs/f2fs.h  |  1 +
>   fs/f2fs/super.c | 18 ++++++++++++++++++
>   2 files changed, 19 insertions(+)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 65294e3b0bef..669f84f6b0e5 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1551,6 +1551,7 @@ struct f2fs_sb_info {
>   
>   #ifdef CONFIG_BLK_DEV_ZONED
>   	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
> +	unsigned int max_active_zones;		/* max zone resources of the zoned device */
>   #endif
>   
>   	/* for node-related operations */
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 206d03c82d96..aef41b54098c 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2385,6 +2385,16 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>   	if (err)
>   		goto restore_opts;
>   
> +#ifdef CONFIG_BLK_DEV_ZONED
> +	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max active zones %u is too small, need at least %u active zones",
> +				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
> +		err = -EINVAL;
> +		goto restore_opts;
> +	}
> +#endif
> +
>   	/* flush outstanding errors before changing fs state */
>   	flush_work(&sbi->s_error_work);
>   
> @@ -3932,6 +3942,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
>   	if (!f2fs_sb_has_blkzoned(sbi))
>   		return 0;
>   
> +	sbi->max_active_zones = bdev_max_active_zones(bdev);
> +	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max active zones %u is too small, need at least %u active zones",
> +				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
> +		return -EINVAL;
> +	}
> +
>   	zone_sectors = bdev_zone_sectors(bdev);
>   	if (!is_power_of_2(zone_sectors)) {
>   		f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");

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

* Re: [f2fs-dev] [PATCH v3] f2fs: fix zoned block device information initialization
  2024-01-23  9:18 ` [f2fs-dev] " Yongpeng Yang
@ 2024-02-01 14:47   ` Chao Yu
  2024-02-01 15:37     ` Wenjie Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2024-02-01 14:47 UTC (permalink / raw)
  To: Yongpeng Yang, Wenjie Qi, hustqwj; +Cc: jaegeuk, linux-f2fs-devel, linux-kernel

On 2024/1/23 17:18, Yongpeng Yang wrote:
> Hi Wenjie,
> It seems more reasonable to use bdev_max_open_zones instead of
> bdev_max_active_zones.

Hi all,

I guess it needs to be initialized w/ bdev_max_open_zones(), due
to the max of open zones of zoned device limits the number of
zones that a host software can simultaneously write [1], right?

[1] https://zonedstorage.io/docs/introduction/zoned-storage#active-zones-limit

Thanks,

> 
> If an NVMe device has multiple namespaces, and the device contains a
> total of 11 open zones, two of the namespaces, nvme0n1 and nvme0n2, each
> correspond to an instance of the F2FS filesystem, and both filesystem
> instances can be initialized successfully. Since multiple namespaces
> share all open zones, the number of open zones is not equal to the
> number of open zones available to F2FS in a multi-namespace scenario.
> This patch does not yet cover this scenario.
> 
> On 1/23/2024 4:12 PM, Wenjie Qi wrote:
>> If the max active zones of zoned devices are less than
>> the active logs of F2FS, the device may error due to
>> insufficient zone resources when multiple active logs are
>> being written at the same time. If this value is 0, there is no limit.
>>
>> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
>> ---
>>    fs/f2fs/f2fs.h  |  1 +
>>    fs/f2fs/super.c | 18 ++++++++++++++++++
>>    2 files changed, 19 insertions(+)
>>
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index 65294e3b0bef..669f84f6b0e5 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -1551,6 +1551,7 @@ struct f2fs_sb_info {
>>    
>>    #ifdef CONFIG_BLK_DEV_ZONED
>>    	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
>> +	unsigned int max_active_zones;		/* max zone resources of the zoned device */
>>    #endif
>>    
>>    	/* for node-related operations */
>> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
>> index 206d03c82d96..aef41b54098c 100644
>> --- a/fs/f2fs/super.c
>> +++ b/fs/f2fs/super.c
>> @@ -2385,6 +2385,16 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
>>    	if (err)
>>    		goto restore_opts;
>>    
>> +#ifdef CONFIG_BLK_DEV_ZONED
>> +	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
>> +		f2fs_err(sbi,
>> +			"zoned: max active zones %u is too small, need at least %u active zones",
>> +				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
>> +		err = -EINVAL;
>> +		goto restore_opts;
>> +	}
>> +#endif
>> +
>>    	/* flush outstanding errors before changing fs state */
>>    	flush_work(&sbi->s_error_work);
>>    
>> @@ -3932,6 +3942,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
>>    	if (!f2fs_sb_has_blkzoned(sbi))
>>    		return 0;
>>    
>> +	sbi->max_active_zones = bdev_max_active_zones(bdev);
>> +	if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
>> +		f2fs_err(sbi,
>> +			"zoned: max active zones %u is too small, need at least %u active zones",
>> +				 sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
>> +		return -EINVAL;
>> +	}
>> +
>>    	zone_sectors = bdev_zone_sectors(bdev);
>>    	if (!is_power_of_2(zone_sectors)) {
>>    		f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");

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

* Re: [f2fs-dev] [PATCH v3] f2fs: fix zoned block device information initialization
  2024-02-01 14:47   ` Chao Yu
@ 2024-02-01 15:37     ` Wenjie Qi
  0 siblings, 0 replies; 4+ messages in thread
From: Wenjie Qi @ 2024-02-01 15:37 UTC (permalink / raw)
  To: Chao Yu; +Cc: Yongpeng Yang, hustqwj, jaegeuk, linux-f2fs-devel, linux-kernel

Hi all,

Yes, I also agree with using bdev_max_open_zones() instead of
bdev_max_active_zones().
I will submit a revised version as soon as possible.

Thanks,

On Thu, Feb 1, 2024 at 10:47 PM Chao Yu <chao@kernel.org> wrote:
>
> On 2024/1/23 17:18, Yongpeng Yang wrote:
> > Hi Wenjie,
> > It seems more reasonable to use bdev_max_open_zones instead of
> > bdev_max_active_zones.
>
> Hi all,
>
> I guess it needs to be initialized w/ bdev_max_open_zones(), due
> to the max of open zones of zoned device limits the number of
> zones that a host software can simultaneously write [1], right?
>
> [1] https://zonedstorage.io/docs/introduction/zoned-storage#active-zones-limit
>
> Thanks,
>
> >
> > If an NVMe device has multiple namespaces, and the device contains a
> > total of 11 open zones, two of the namespaces, nvme0n1 and nvme0n2, each
> > correspond to an instance of the F2FS filesystem, and both filesystem
> > instances can be initialized successfully. Since multiple namespaces
> > share all open zones, the number of open zones is not equal to the
> > number of open zones available to F2FS in a multi-namespace scenario.
> > This patch does not yet cover this scenario.
> >
> > On 1/23/2024 4:12 PM, Wenjie Qi wrote:
> >> If the max active zones of zoned devices are less than
> >> the active logs of F2FS, the device may error due to
> >> insufficient zone resources when multiple active logs are
> >> being written at the same time. If this value is 0, there is no limit.
> >>
> >> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> >> ---
> >>    fs/f2fs/f2fs.h  |  1 +
> >>    fs/f2fs/super.c | 18 ++++++++++++++++++
> >>    2 files changed, 19 insertions(+)
> >>
> >> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> >> index 65294e3b0bef..669f84f6b0e5 100644
> >> --- a/fs/f2fs/f2fs.h
> >> +++ b/fs/f2fs/f2fs.h
> >> @@ -1551,6 +1551,7 @@ struct f2fs_sb_info {
> >>
> >>    #ifdef CONFIG_BLK_DEV_ZONED
> >>      unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
> >> +    unsigned int max_active_zones;          /* max zone resources of the zoned device */
> >>    #endif
> >>
> >>      /* for node-related operations */
> >> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> >> index 206d03c82d96..aef41b54098c 100644
> >> --- a/fs/f2fs/super.c
> >> +++ b/fs/f2fs/super.c
> >> @@ -2385,6 +2385,16 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
> >>      if (err)
> >>              goto restore_opts;
> >>
> >> +#ifdef CONFIG_BLK_DEV_ZONED
> >> +    if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
> >> +            f2fs_err(sbi,
> >> +                    "zoned: max active zones %u is too small, need at least %u active zones",
> >> +                             sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
> >> +            err = -EINVAL;
> >> +            goto restore_opts;
> >> +    }
> >> +#endif
> >> +
> >>      /* flush outstanding errors before changing fs state */
> >>      flush_work(&sbi->s_error_work);
> >>
> >> @@ -3932,6 +3942,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
> >>      if (!f2fs_sb_has_blkzoned(sbi))
> >>              return 0;
> >>
> >> +    sbi->max_active_zones = bdev_max_active_zones(bdev);
> >> +    if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) {
> >> +            f2fs_err(sbi,
> >> +                    "zoned: max active zones %u is too small, need at least %u active zones",
> >> +                             sbi->max_active_zones, F2FS_OPTION(sbi).active_logs);
> >> +            return -EINVAL;
> >> +    }
> >> +
> >>      zone_sectors = bdev_zone_sectors(bdev);
> >>      if (!is_power_of_2(zone_sectors)) {
> >>              f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");

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

end of thread, other threads:[~2024-02-01 15:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-23  8:12 [PATCH v3] f2fs: fix zoned block device information initialization Wenjie Qi
2024-01-23  9:18 ` [f2fs-dev] " Yongpeng Yang
2024-02-01 14:47   ` Chao Yu
2024-02-01 15:37     ` Wenjie Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®