From: Damien Le Moal Date: Wed, 1 Sep 2021 06:41:53 +0000 (+0900) Subject: oslib: Fix blkzoned_get_max_open_zones() X-Git-Tag: fio-3.28~15 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=f3463241727215e228a60dc3b9a1ba2996f149a1;p=fio.git oslib: Fix blkzoned_get_max_open_zones() 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 Signed-off-by: Damien Le Moal Signed-off-by: Jens Axboe --- 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);