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 <dlemoal@kernel.org>
Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20230705212915.3373438-1-bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
#include "zbd_types.h"
#include <linux/blkzoned.h>
#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,
/*
* If the uapi headers installed on the system lacks zone capacity support,
int blkzoned_finish_zone(struct thread_data *td, struct fio_file *f,
uint64_t offset, uint64_t length)
{
int blkzoned_finish_zone(struct thread_data *td, struct fio_file *f,
uint64_t offset, uint64_t length)
{
struct blk_zone_range zr = {
.sector = offset >> 9,
.nr_sectors = length >> 9,
struct blk_zone_range zr = {
.sector = offset >> 9,
.nr_sectors = length >> 9,
- if (ioctl(fd, BLKFINISHZONE, &zr) < 0)
+ if (ioctl(fd, BLKFINISHZONE, &zr) < 0) {
+ /*
+ * 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;
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