All of lore.kernel.org
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  3:10 ` Wenjie Qi
  0 siblings, 0 replies; 10+ messages in thread
From: Wenjie Qi @ 2024-02-04  3:10 UTC (permalink / raw)
  To: jaegeuk, chao, yangyongpeng1, linux-f2fs-devel, linux-kernel
  Cc: Wenjie Qi, hustqwj

If the max open 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.

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

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 543898482f8b..161107f2d3bd 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
 
 #ifdef CONFIG_BLK_DEV_ZONED
 	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
+	unsigned int max_open_zones;		/* max open zone resources of the zoned device */
 #endif
 
 	/* for node-related operations */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1b718bebfaa1..c6709efbc294 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_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);
 
@@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
 	sector_t nr_sectors = bdev_nr_sectors(bdev);
 	struct f2fs_report_zones_args rep_zone_arg;
 	u64 zone_sectors;
+	unsigned int max_open_zones;
 	int ret;
 
 	if (!f2fs_sb_has_blkzoned(sbi))
 		return 0;
 
+	max_open_zones = bdev_max_open_zones(bdev);
+	if (max_open_zones && (max_open_zones < sbi->max_open_zones))
+		sbi->max_open_zones = max_open_zones;
+	if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_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");
@@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
 
 	logical_blksize = bdev_logical_block_size(sbi->sb->s_bdev);
 	sbi->aligned_blksize = true;
+#ifdef CONFIG_BLK_DEV_ZONED
+	sbi->max_open_zones = UINT_MAX;
+#endif
 
 	for (i = 0; i < max_devices; i++) {
 		if (i == 0)
-- 
2.34.1



_______________________________________________
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] 10+ messages in thread

* [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  3:10 ` Wenjie Qi
  0 siblings, 0 replies; 10+ messages in thread
From: Wenjie Qi @ 2024-02-04  3:10 UTC (permalink / raw)
  To: jaegeuk, chao, yangyongpeng1, linux-f2fs-devel, linux-kernel
  Cc: hustqwj, Wenjie Qi

If the max open 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.

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

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 543898482f8b..161107f2d3bd 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
 
 #ifdef CONFIG_BLK_DEV_ZONED
 	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
+	unsigned int max_open_zones;		/* max open zone resources of the zoned device */
 #endif
 
 	/* for node-related operations */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 1b718bebfaa1..c6709efbc294 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_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);
 
@@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
 	sector_t nr_sectors = bdev_nr_sectors(bdev);
 	struct f2fs_report_zones_args rep_zone_arg;
 	u64 zone_sectors;
+	unsigned int max_open_zones;
 	int ret;
 
 	if (!f2fs_sb_has_blkzoned(sbi))
 		return 0;
 
+	max_open_zones = bdev_max_open_zones(bdev);
+	if (max_open_zones && (max_open_zones < sbi->max_open_zones))
+		sbi->max_open_zones = max_open_zones;
+	if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
+		f2fs_err(sbi,
+			"zoned: max open zones %u is too small, need at least %u open zones",
+				 sbi->max_open_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");
@@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
 
 	logical_blksize = bdev_logical_block_size(sbi->sb->s_bdev);
 	sbi->aligned_blksize = true;
+#ifdef CONFIG_BLK_DEV_ZONED
+	sbi->max_open_zones = UINT_MAX;
+#endif
 
 	for (i = 0; i < max_devices; i++) {
 		if (i == 0)
-- 
2.34.1


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

* Re: [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization
  2024-02-04  3:10 ` Wenjie Qi
@ 2024-02-04  3:13   ` Chao Yu
  -1 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2024-02-04  3:13 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, yangyongpeng1, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

On 2024/2/4 11:10, Wenjie Qi wrote:
> If the max open 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.
> 
> Signed-off-by: Wenjie Qi <qwjhust@gmail.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] 10+ messages in thread

* Re: [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  3:13   ` Chao Yu
  0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2024-02-04  3:13 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, yangyongpeng1, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

On 2024/2/4 11:10, Wenjie Qi wrote:
> If the max open 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.
> 
> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

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

* Re: [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization
  2024-02-04  3:10 ` Wenjie Qi
@ 2024-02-04  3:35   ` Yongpeng Yang
  -1 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang via Linux-f2fs-devel @ 2024-02-04  3:35 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

Hi Wenjie,
"max_open_zones < sbi->max_open_zones" seems meaningless, this condition 
is false only if "max_open_zones == UINT_MAX"(rarely happen). Although 
it doesn't affect the correctness, I think less jmp instruction is better.

On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> max_open_zones < sbi->max_open_zones


_______________________________________________
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] 10+ messages in thread

* Re: [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  3:35   ` Yongpeng Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang @ 2024-02-04  3:35 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

Hi Wenjie,
"max_open_zones < sbi->max_open_zones" seems meaningless, this condition 
is false only if "max_open_zones == UINT_MAX"(rarely happen). Although 
it doesn't affect the correctness, I think less jmp instruction is better.

On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> max_open_zones < sbi->max_open_zones

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

* Re: [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization
  2024-02-04  3:10 ` Wenjie Qi
@ 2024-02-04  4:53   ` Yongpeng Yang
  -1 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang via Linux-f2fs-devel @ 2024-02-04  4:53 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

1. f2fs_scan_devices call init_blkz_info for each zoned device, is it 
reasonable that every device need to have 6 open zones at least?
2. we should add all open_zones of every zoned device to 
sbi->max_open_zones, sbi->max_open_zones will be UINT_MAX or accumulated 
open_zones. Is it more reasonable?


On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> If the max open 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.
> 
> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> ---
>   fs/f2fs/f2fs.h  |  1 +
>   fs/f2fs/super.c | 24 ++++++++++++++++++++++++
>   2 files changed, 25 insertions(+)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 543898482f8b..161107f2d3bd 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
>   
>   #ifdef CONFIG_BLK_DEV_ZONED
>   	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
> +	unsigned int max_open_zones;		/* max open zone resources of the zoned device */
>   #endif
>   
>   	/* for node-related operations */
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 1b718bebfaa1..c6709efbc294 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max open zones %u is too small, need at least %u open zones",
> +				 sbi->max_open_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);
>   
> @@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
>   	sector_t nr_sectors = bdev_nr_sectors(bdev);
>   	struct f2fs_report_zones_args rep_zone_arg;
>   	u64 zone_sectors;
> +	unsigned int max_open_zones;
>   	int ret;
>   
>   	if (!f2fs_sb_has_blkzoned(sbi))
>   		return 0;
>   
> +	max_open_zones = bdev_max_open_zones(bdev);
> +	if (max_open_zones && (max_open_zones < sbi->max_open_zones))
> +		sbi->max_open_zones = max_open_zones;
> +	if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max open zones %u is too small, need at least %u open zones",
> +				 sbi->max_open_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");
> @@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
>   
>   	logical_blksize = bdev_logical_block_size(sbi->sb->s_


_______________________________________________
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] 10+ messages in thread

* Re: [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  4:53   ` Yongpeng Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Yongpeng Yang @ 2024-02-04  4:53 UTC (permalink / raw)
  To: Wenjie Qi, jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: hustqwj

1. f2fs_scan_devices call init_blkz_info for each zoned device, is it 
reasonable that every device need to have 6 open zones at least?
2. we should add all open_zones of every zoned device to 
sbi->max_open_zones, sbi->max_open_zones will be UINT_MAX or accumulated 
open_zones. Is it more reasonable?


On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> If the max open 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.
> 
> Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> ---
>   fs/f2fs/f2fs.h  |  1 +
>   fs/f2fs/super.c | 24 ++++++++++++++++++++++++
>   2 files changed, 25 insertions(+)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 543898482f8b..161107f2d3bd 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
>   
>   #ifdef CONFIG_BLK_DEV_ZONED
>   	unsigned int blocks_per_blkz;		/* F2FS blocks per zone */
> +	unsigned int max_open_zones;		/* max open zone resources of the zoned device */
>   #endif
>   
>   	/* for node-related operations */
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 1b718bebfaa1..c6709efbc294 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max open zones %u is too small, need at least %u open zones",
> +				 sbi->max_open_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);
>   
> @@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
>   	sector_t nr_sectors = bdev_nr_sectors(bdev);
>   	struct f2fs_report_zones_args rep_zone_arg;
>   	u64 zone_sectors;
> +	unsigned int max_open_zones;
>   	int ret;
>   
>   	if (!f2fs_sb_has_blkzoned(sbi))
>   		return 0;
>   
> +	max_open_zones = bdev_max_open_zones(bdev);
> +	if (max_open_zones && (max_open_zones < sbi->max_open_zones))
> +		sbi->max_open_zones = max_open_zones;
> +	if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
> +		f2fs_err(sbi,
> +			"zoned: max open zones %u is too small, need at least %u open zones",
> +				 sbi->max_open_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");
> @@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
>   
>   	logical_blksize = bdev_logical_block_size(sbi->sb->s_

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

* Re: [PATCH v5] f2fs: fix zoned block device information initialization
  2024-02-04  4:53   ` Yongpeng Yang
@ 2024-02-04  7:29     ` Wenjie Qi
  -1 siblings, 0 replies; 10+ messages in thread
From: Wenjie Qi @ 2024-02-04  7:29 UTC (permalink / raw)
  To: Yongpeng Yang; +Cc: jaegeuk, chao, linux-f2fs-devel, linux-kernel, hustqwj

On Sun, Feb 4, 2024 at 12:53 PM Yongpeng Yang <yangyongpeng1@oppo.com> wrote:
>
> 1. f2fs_scan_devices call init_blkz_info for each zoned device, is it
> reasonable that every device need to have 6 open zones at least?

Because it is possible for all active logs to write to the same zoned
device at the same time,
each zoned device must have at least the same number of open zone
resources as active logs.

> 2. we should add all open_zones of every zoned device to
> sbi->max_open_zones, sbi->max_open_zones will be UINT_MAX or accumulated
> open_zones. Is it more reasonable?

I don't think that's right.
sbi->max_open_zone is the number of resources that are the least of
all zoned devices.

Thanks.

>
>
> On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> > If the max open 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.
> >
> > Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> > ---
> >   fs/f2fs/f2fs.h  |  1 +
> >   fs/f2fs/super.c | 24 ++++++++++++++++++++++++
> >   2 files changed, 25 insertions(+)
> >
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 543898482f8b..161107f2d3bd 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
> >
> >   #ifdef CONFIG_BLK_DEV_ZONED
> >       unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
> > +     unsigned int max_open_zones;            /* max open zone resources of the zoned device */
> >   #endif
> >
> >       /* for node-related operations */
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 1b718bebfaa1..c6709efbc294 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
> > +             f2fs_err(sbi,
> > +                     "zoned: max open zones %u is too small, need at least %u open zones",
> > +                              sbi->max_open_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);
> >
> > @@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
> >       sector_t nr_sectors = bdev_nr_sectors(bdev);
> >       struct f2fs_report_zones_args rep_zone_arg;
> >       u64 zone_sectors;
> > +     unsigned int max_open_zones;
> >       int ret;
> >
> >       if (!f2fs_sb_has_blkzoned(sbi))
> >               return 0;
> >
> > +     max_open_zones = bdev_max_open_zones(bdev);
> > +     if (max_open_zones && (max_open_zones < sbi->max_open_zones))
> > +             sbi->max_open_zones = max_open_zones;
> > +     if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
> > +             f2fs_err(sbi,
> > +                     "zoned: max open zones %u is too small, need at least %u open zones",
> > +                              sbi->max_open_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");
> > @@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> >
> >       logical_blksize = bdev_logical_block_size(sbi->sb->s_

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

* Re: [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization
@ 2024-02-04  7:29     ` Wenjie Qi
  0 siblings, 0 replies; 10+ messages in thread
From: Wenjie Qi @ 2024-02-04  7:29 UTC (permalink / raw)
  To: Yongpeng Yang; +Cc: jaegeuk, linux-kernel, hustqwj, linux-f2fs-devel

On Sun, Feb 4, 2024 at 12:53 PM Yongpeng Yang <yangyongpeng1@oppo.com> wrote:
>
> 1. f2fs_scan_devices call init_blkz_info for each zoned device, is it
> reasonable that every device need to have 6 open zones at least?

Because it is possible for all active logs to write to the same zoned
device at the same time,
each zoned device must have at least the same number of open zone
resources as active logs.

> 2. we should add all open_zones of every zoned device to
> sbi->max_open_zones, sbi->max_open_zones will be UINT_MAX or accumulated
> open_zones. Is it more reasonable?

I don't think that's right.
sbi->max_open_zone is the number of resources that are the least of
all zoned devices.

Thanks.

>
>
> On 2/4/2024 11:10 AM, Wenjie Qi wrote:
> > If the max open 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.
> >
> > Signed-off-by: Wenjie Qi <qwjhust@gmail.com>
> > ---
> >   fs/f2fs/f2fs.h  |  1 +
> >   fs/f2fs/super.c | 24 ++++++++++++++++++++++++
> >   2 files changed, 25 insertions(+)
> >
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index 543898482f8b..161107f2d3bd 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -1558,6 +1558,7 @@ struct f2fs_sb_info {
> >
> >   #ifdef CONFIG_BLK_DEV_ZONED
> >       unsigned int blocks_per_blkz;           /* F2FS blocks per zone */
> > +     unsigned int max_open_zones;            /* max open zone resources of the zoned device */
> >   #endif
> >
> >       /* for node-related operations */
> > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> > index 1b718bebfaa1..c6709efbc294 100644
> > --- a/fs/f2fs/super.c
> > +++ b/fs/f2fs/super.c
> > @@ -2388,6 +2388,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_open_zones < F2FS_OPTION(sbi).active_logs) {
> > +             f2fs_err(sbi,
> > +                     "zoned: max open zones %u is too small, need at least %u open zones",
> > +                              sbi->max_open_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);
> >
> > @@ -3930,11 +3940,22 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
> >       sector_t nr_sectors = bdev_nr_sectors(bdev);
> >       struct f2fs_report_zones_args rep_zone_arg;
> >       u64 zone_sectors;
> > +     unsigned int max_open_zones;
> >       int ret;
> >
> >       if (!f2fs_sb_has_blkzoned(sbi))
> >               return 0;
> >
> > +     max_open_zones = bdev_max_open_zones(bdev);
> > +     if (max_open_zones && (max_open_zones < sbi->max_open_zones))
> > +             sbi->max_open_zones = max_open_zones;
> > +     if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) {
> > +             f2fs_err(sbi,
> > +                     "zoned: max open zones %u is too small, need at least %u open zones",
> > +                              sbi->max_open_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");
> > @@ -4253,6 +4274,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
> >
> >       logical_blksize = bdev_logical_block_size(sbi->sb->s_


_______________________________________________
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] 10+ messages in thread

end of thread, other threads:[~2024-02-04  7:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-04  3:10 [f2fs-dev] [PATCH v5] f2fs: fix zoned block device information initialization Wenjie Qi
2024-02-04  3:10 ` Wenjie Qi
2024-02-04  3:13 ` [f2fs-dev] " Chao Yu
2024-02-04  3:13   ` Chao Yu
2024-02-04  3:35 ` [f2fs-dev] " Yongpeng Yang via Linux-f2fs-devel
2024-02-04  3:35   ` Yongpeng Yang
2024-02-04  4:53 ` [f2fs-dev] " Yongpeng Yang via Linux-f2fs-devel
2024-02-04  4:53   ` Yongpeng Yang
2024-02-04  7:29   ` Wenjie Qi
2024-02-04  7:29     ` [f2fs-dev] " Wenjie Qi

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.