* [PATCH V2] oslib: Fix blkzoned_get_max_open_zones()
@ 2021-09-01 6:41 Damien Le Moal
2021-09-03 1:32 ` Damien Le Moal
2021-09-03 2:56 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Damien Le Moal @ 2021-09-01 6:41 UTC (permalink / raw)
To: fio, Jens Axboe
When the kernel does not have the sysfs atttribute file
queue/max_open_zones, blkzoned_get_max_open_zones() returns success
without initializing the max_open_zones value to 0 to indicate to the
caller (zbd_get_max_open_zones() in zbd.c) that the device limit is
unknown. If the max_open_zones variable in zbd_get_max_open_zones() is
not already 0 (depending on the memory status), the missing
initialization in blkzoned_get_max_open_zones() can cause errors or
misbehavior as an incorrect, random, limit may be used.
Fix this by always initializing max_open_zones to 0 when the
max_open_zones sysfs attribute file does not exist.
Reported-by: Bao-Hua Li <baohua.li@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
Changes from v1:
* Added missing reported-by tag
oslib/linux-blkzoned.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/oslib/linux-blkzoned.c b/oslib/linux-blkzoned.c
index 4e441d29..185bd501 100644
--- a/oslib/linux-blkzoned.c
+++ b/oslib/linux-blkzoned.c
@@ -169,8 +169,10 @@ int blkzoned_get_max_open_zones(struct thread_data *td, struct fio_file *f,
return -EIO;
max_open_str = blkzoned_get_sysfs_attr(f->file_name, "queue/max_open_zones");
- if (!max_open_str)
+ if (!max_open_str) {
+ *max_open_zones = 0;
return 0;
+ }
dprint(FD_ZBD, "%s: max open zones supported by device: %s\n",
f->file_name, max_open_str);
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] oslib: Fix blkzoned_get_max_open_zones()
2021-09-01 6:41 [PATCH V2] oslib: Fix blkzoned_get_max_open_zones() Damien Le Moal
@ 2021-09-03 1:32 ` Damien Le Moal
2021-09-03 2:56 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Damien Le Moal @ 2021-09-03 1:32 UTC (permalink / raw)
To: fio, Jens Axboe
On 2021/09/01 15:42, Damien Le Moal wrote:
> When the kernel does not have the sysfs atttribute file
> queue/max_open_zones, blkzoned_get_max_open_zones() returns success
> without initializing the max_open_zones value to 0 to indicate to the
> caller (zbd_get_max_open_zones() in zbd.c) that the device limit is
> unknown. If the max_open_zones variable in zbd_get_max_open_zones() is
> not already 0 (depending on the memory status), the missing
> initialization in blkzoned_get_max_open_zones() can cause errors or
> misbehavior as an incorrect, random, limit may be used.
>
> Fix this by always initializing max_open_zones to 0 when the
> max_open_zones sysfs attribute file does not exist.
Hi Jens,
We are getting problem reports from the field due to this bug. Could you apply
this patch please ?
Thanks !
>
> Reported-by: Bao-Hua Li <baohua.li@wdc.com>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>
> Changes from v1:
> * Added missing reported-by tag
>
> oslib/linux-blkzoned.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/oslib/linux-blkzoned.c b/oslib/linux-blkzoned.c
> index 4e441d29..185bd501 100644
> --- a/oslib/linux-blkzoned.c
> +++ b/oslib/linux-blkzoned.c
> @@ -169,8 +169,10 @@ int blkzoned_get_max_open_zones(struct thread_data *td, struct fio_file *f,
> return -EIO;
>
> max_open_str = blkzoned_get_sysfs_attr(f->file_name, "queue/max_open_zones");
> - if (!max_open_str)
> + if (!max_open_str) {
> + *max_open_zones = 0;
> return 0;
> + }
>
> dprint(FD_ZBD, "%s: max open zones supported by device: %s\n",
> f->file_name, max_open_str);
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] oslib: Fix blkzoned_get_max_open_zones()
2021-09-01 6:41 [PATCH V2] oslib: Fix blkzoned_get_max_open_zones() Damien Le Moal
2021-09-03 1:32 ` Damien Le Moal
@ 2021-09-03 2:56 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-09-03 2:56 UTC (permalink / raw)
To: Damien Le Moal, fio
On 9/1/21 12:41 AM, Damien Le Moal wrote:
> When the kernel does not have the sysfs atttribute file
> queue/max_open_zones, blkzoned_get_max_open_zones() returns success
> without initializing the max_open_zones value to 0 to indicate to the
> caller (zbd_get_max_open_zones() in zbd.c) that the device limit is
> unknown. If the max_open_zones variable in zbd_get_max_open_zones() is
> not already 0 (depending on the memory status), the missing
> initialization in blkzoned_get_max_open_zones() can cause errors or
> misbehavior as an incorrect, random, limit may be used.
>
> Fix this by always initializing max_open_zones to 0 when the
> max_open_zones sysfs attribute file does not exist.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-03 2:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01 6:41 [PATCH V2] oslib: Fix blkzoned_get_max_open_zones() Damien Le Moal
2021-09-03 1:32 ` Damien Le Moal
2021-09-03 2:56 ` Jens Axboe
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).