zbd: Support finishing zones on Android
PATCH 1/1 zbd: Support finishing zones on Android
BLKFINISHZONE is missing from older versions of the Android NDK header files. Hence, define BLKFINISHZONE if it has not been defined and detect at runtime whether or not the kernel supports finishing zones.
--- oslib/linux-blkzoned.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
oslib/linux-blkzoned.c +12 -12
@@ -22,6 +22,9 @@#include "zbd_types.h" #include <linux/blkzoned.h> +#ifndef BLKFINISHZONE +#define BLKFINISHZONE _IOW(0x12, 136, struct blk_zone_range) +#endif /* * If the uapi headers installed on the system lacks zone capacity support,
@@ -312,7 +315,6 @@ int blkzoned_reset_wp(struct thread_data *td, struct fio_file *f,int blkzoned_finish_zone (struct thread_data *td,struct fio_file *f,uint64_t offset,uint64_t length) { -#ifdef BLKFINISHZONE struct blk_zone_range zr = { .sector = offset >>9 , .nr_sectors = length >>9 ,
@@ -327,21 +329,19 @@ int blkzoned_finish_zone(struct thread_data *td, struct fio_file *f,return -errno; } -if (ioctl (fd,BLKFINISHZONE , &zr) <0 ) +if (ioctl (fd,BLKFINISHZONE , &zr) <0 ) { ret = -errno; +/* +* Kernel versions older than 5.5 do not support BLKFINISHZONE +* and return the ENOTTY error code. These old kernels only +* support block devices that close zones automatically. +*/ +if (ret ==ENOTTY ) + ret =0 ; + }if (f->fd <0 )close (fd);return ret; -#else -/* -* Kernel versions older than 5.5 does not support BLKFINISHZONE. These -* old kernels assumed zones are closed automatically at max_open_zones -* limit. Also they did not support max_active_zones limit. Then there -* was no need to finish zones to avoid errors caused by max_open_zones -* or max_active_zones. For those old versions, just do nothing. -*/ -return 0 ; -#endif }
Jens Axboe
AppliedQuoted 5 lines · Bart Van Assche
BLKFINISHZONE is missing from older versions of the Android NDK header files. Hence, define BLKFINISHZONE if it has not been defined and detect at runtime whether or not the kernel supports finishing zones.
Applied, thanks!
[1/1] zbd: Support finishing zones on Android
commit: 8e2b81b854286f32eae7951a434dddebd968f9d5
Best regards,
Signature · 1 line
Jens Axboe
Quoted 7 lines · Bart Van Assche
BLKFINISHZONE is missing from older versions of the Android NDK header files. Hence, define BLKFINISHZONE if it has not been defined and detect at runtime whether or not the kernel supports finishing zones.
Cc Damien Le Moal <[email protected]>Cc Shin'ichiro Kawasaki <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Late as Jens already applied the patch, but anyway, looks good to me.
Quoted 57 lines
--- oslib/linux-blkzoned.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)oslib/linux-blkzoned.c +12
-12@@ -22,6 +22,9 @@#include "zbd_types.h" #include <linux/blkzoned.h> +#ifndef BLKFINISHZONE +#define BLKFINISHZONE _IOW(0x12, 136, struct blk_zone_range) +#endif /* * If the uapi headers installed on the system lacks zone capacity support, @@ -312,7 +315,6 @@ int blkzoned_reset_wp(struct thread_data *td, struct fio_file *f,int blkzoned_finish_zone (struct thread_data *td,struct fio_file *f,uint64_t offset,uint64_t length) { -#ifdef BLKFINISHZONE struct blk_zone_range zr = { .sector = offset >>9 , .nr_sectors = length >>9 ,@@ -327,21 +329,19 @@ int blkzoned_finish_zone(struct thread_data *td, struct fio_file *f,return -errno; } -if (ioctl (fd,BLKFINISHZONE , &zr) <0 ) +if (ioctl (fd,BLKFINISHZONE , &zr) <0 ) { ret = -errno; +/* +* Kernel versions older than 5.5 do not support BLKFINISHZONE +* and return the ENOTTY error code. These old kernels only +* support block devices that close zones automatically. +*/ +if (ret ==ENOTTY ) + ret =0 ; + }if (f->fd <0 )close (fd);return ret; -#else -/* -* Kernel versions older than 5.5 does not support BLKFINISHZONE. These -* old kernels assumed zones are closed automatically at max_open_zones -* limit. Also they did not support max_active_zones limit. Then there -* was no need to finish zones to avoid errors caused by max_open_zones -* or max_active_zones. For those old versions, just do nothing. -*/ -return 0 ; -#endif }
Signature · 2 lines
Damien Le Moal Western Digital Research
Quoted 5 lines · Damien Le Moal
Quoted 4 lines · Bart Van Assche
BLKFINISHZONE is missing from older versions of the Android NDK header files. Hence, define BLKFINISHZONE if it has not been defined and detect at runtime whether or not the kernel supports finishing zones.
Quoted 7 lines
Quoted 3 lines
Cc Damien Le Moal <[email protected]>Cc Shin'ichiro Kawasaki <[email protected]>Signed-off-by Bart Van Assche <[email protected]>Late as Jens already applied the patch, but anyway, looks good to me.
Reviewed-by Damien Le Moal <[email protected]>
Thanks, I think these replies are still useful even if it's already applied, as it's still documented on lore.
Signature · 1 line
Jens Axboe