X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=zbd.c;h=d7e91e37e010c0194da07636b29ce058ebd2db13;hb=acd44dec8cfa476d91dc1695df64f249e52d06e3;hp=2da742b7212280cb5e2ab562836bd058bb156fbe;hpb=6f0c608564c3b5cc33330a22d1b347376e2cf1cc;p=fio.git diff --git a/zbd.c b/zbd.c index 2da742b7..d7e91e37 100644 --- a/zbd.c +++ b/zbd.c @@ -186,11 +186,14 @@ static bool zbd_verify_bs(void) * size of @buf. * * Returns 0 upon success and a negative error code upon failure. + * If the zone report is empty, always assume an error (device problem) and + * return -EIO. */ static int read_zone_info(int fd, uint64_t start_sector, void *buf, unsigned int bufsz) { struct blk_zone_report *hdr = buf; + int ret; if (bufsz < sizeof(*hdr)) return -EINVAL; @@ -199,7 +202,12 @@ static int read_zone_info(int fd, uint64_t start_sector, hdr->nr_zones = (bufsz - sizeof(*hdr)) / sizeof(struct blk_zone); hdr->sector = start_sector; - return ioctl(fd, BLKREPORTZONE, hdr) >= 0 ? 0 : -errno; + ret = ioctl(fd, BLKREPORTZONE, hdr); + if (ret) + return -errno; + if (!hdr->nr_zones) + return -EIO; + return 0; } /* @@ -418,8 +426,6 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) p->start = z->start << 9; switch (z->cond) { case BLK_ZONE_COND_NOT_WP: - p->wp = p->start; - break; case BLK_ZONE_COND_FULL: p->wp = p->start + zone_size; break;