zbd: return ENOMEM if zone buffer allocation fails
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index e8ecbb6f831e0a0fd23e2a150966e127ed004dbc..46992746fc2c437e6da7a9b063e850fcecc4292b 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -338,7 +338,7 @@ static bool zbd_verify_bs(void)
                        if (!f->zbd_info)
                                continue;
                        zone_size = f->zbd_info->zone_size;
-                       for (k = 0; k < ARRAY_SIZE(td->o.bs); k++) {
+                       for (k = 0; k < FIO_ARRAY_SIZE(td->o.bs); k++) {
                                if (td->o.verify != VERIFY_NONE &&
                                    zone_size % td->o.bs[k] != 0) {
                                        log_info("%s: block size %llu is not a divisor of the zone size %d\n",
@@ -443,7 +443,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
        struct fio_zone_info *p;
        uint64_t zone_size, offset;
        struct zoned_block_device_info *zbd_info = NULL;
-       int i, j, ret = 0;
+       int i, j, ret = -ENOMEM;
 
        zones = calloc(ZBD_REPORT_MAX_ZONES, sizeof(struct zbd_zone));
        if (!zones)
@@ -475,7 +475,6 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
 
        zbd_info = scalloc(1, sizeof(*zbd_info) +
                           (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
-       ret = -ENOMEM;
        if (!zbd_info)
                goto out;
        mutex_init_pshared(&zbd_info->mutex);
@@ -718,6 +717,9 @@ static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
        uint64_t length = (z+1)->start - offset;
        int ret = 0;
 
+       if (z->wp == z->start)
+               return 0;
+
        assert(is_valid_offset(f, offset + length - 1));
 
        dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
@@ -1546,6 +1548,7 @@ enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
        case DDIR_READ:
                if (td->runstate == TD_VERIFYING && td_write(td)) {
                        zb = zbd_replay_write_order(td, io_u, zb);
+                       pthread_mutex_unlock(&zb->mutex);
                        goto accept;
                }
                /*