t/fiotestlib: use dictionaries for filenames and paths
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index d6f8f800e3130204c476876b1884d9f3e8508056..5f1a7d7f3edb46ecdd3179918995b412979335ad 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -213,8 +213,8 @@ static int zbd_report_zones(struct thread_data *td, struct fio_file *f,
                ret = blkzoned_report_zones(td, f, offset, zones, nr_zones);
        if (ret < 0) {
                td_verror(td, errno, "report zones failed");
-               log_err("%s: report zones from sector %"PRIu64" failed (%d).\n",
-                       f->file_name, offset >> 9, errno);
+               log_err("%s: report zones from sector %"PRIu64" failed (nr_zones=%d; errno=%d).\n",
+                       f->file_name, offset >> 9, nr_zones, errno);
        } else if (ret == 0) {
                td_verror(td, errno, "Empty zone report");
                log_err("%s: report zones from sector %"PRIu64" is empty.\n",
@@ -524,11 +524,10 @@ out:
 /* Verify whether direct I/O is used for all host-managed zoned block drives. */
 static bool zbd_using_direct_io(void)
 {
-       struct thread_data *td;
        struct fio_file *f;
-       int i, j;
+       int j;
 
-       for_each_td(td, i) {
+       for_each_td(td) {
                if (td->o.odirect || !(td->o.td_ddir & TD_DDIR_WRITE))
                        continue;
                for_each_file(td, f, j) {
@@ -536,7 +535,7 @@ static bool zbd_using_direct_io(void)
                            f->zbd_info->model == ZBD_HOST_MANAGED)
                                return false;
                }
-       }
+       } end_for_each();
 
        return true;
 }
@@ -639,27 +638,25 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td,
  */
 static bool zbd_verify_sizes(void)
 {
-       struct thread_data *td;
        struct fio_file *f;
-       int i, j;
+       int j;
 
-       for_each_td(td, i) {
+       for_each_td(td) {
                for_each_file(td, f, j) {
                        if (!zbd_zone_align_file_sizes(td, f))
                                return false;
                }
-       }
+       } end_for_each();
 
        return true;
 }
 
 static bool zbd_verify_bs(void)
 {
-       struct thread_data *td;
        struct fio_file *f;
-       int i, j;
+       int j;
 
-       for_each_td(td, i) {
+       for_each_td(td) {
                if (td_trim(td) &&
                    (td->o.min_bs[DDIR_TRIM] != td->o.max_bs[DDIR_TRIM] ||
                     td->o.bssplit_nr[DDIR_TRIM])) {
@@ -680,7 +677,7 @@ static bool zbd_verify_bs(void)
                                return false;
                        }
                }
-       }
+       } end_for_each();
        return true;
 }
 
@@ -779,7 +776,8 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
        int nr_zones, nrz;
        struct zbd_zone *zones, *z;
        struct fio_zone_info *p;
-       uint64_t zone_size, offset;
+       uint64_t zone_size, offset, capacity;
+       bool same_zone_cap = true;
        struct zoned_block_device_info *zbd_info = NULL;
        int i, j, ret = -ENOMEM;
 
@@ -796,6 +794,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
        }
 
        zone_size = zones[0].len;
+       capacity = zones[0].capacity;
        nr_zones = (f->real_file_size + zone_size - 1) / zone_size;
 
        if (td->o.zone_size == 0) {
@@ -807,8 +806,8 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
                goto out;
        }
 
-       dprint(FD_ZBD, "Device %s has %d zones of size %"PRIu64" KB and capacity %"PRIu64" KB\n",
-              f->file_name, nr_zones, zone_size / 1024, zones[0].capacity / 1024);
+       dprint(FD_ZBD, "Device %s has %d zones of size %"PRIu64" KB\n",
+              f->file_name, nr_zones, zone_size / 1024);
 
        zbd_info = scalloc(1, sizeof(*zbd_info) +
                           (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
@@ -824,6 +823,8 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
                                                     PTHREAD_MUTEX_RECURSIVE);
                        p->start = z->start;
                        p->capacity = z->capacity;
+                       if (capacity != z->capacity)
+                               same_zone_cap = false;
 
                        switch (z->cond) {
                        case ZBD_ZONE_COND_NOT_WP:
@@ -879,6 +880,11 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
        f->zbd_info->zone_size_log2 = is_power_of_2(zone_size) ?
                ilog2(zone_size) : 0;
        f->zbd_info->nr_zones = nr_zones;
+
+       if (same_zone_cap)
+               dprint(FD_ZBD, "Zone capacity = %"PRIu64" KB\n",
+                      capacity / 1024);
+
        zbd_info = NULL;
        ret = 0;
 
@@ -1010,11 +1016,10 @@ void zbd_free_zone_info(struct fio_file *f)
  */
 static int zbd_init_zone_info(struct thread_data *td, struct fio_file *file)
 {
-       struct thread_data *td2;
        struct fio_file *f2;
-       int i, j, ret;
+       int j, ret;
 
-       for_each_td(td2, i) {
+       for_each_td(td2) {
                for_each_file(td2, f2, j) {
                        if (td2 == td && f2 == file)
                                continue;
@@ -1025,7 +1030,7 @@ static int zbd_init_zone_info(struct thread_data *td, struct fio_file *file)
                        file->zbd_info->refcount++;
                        return 0;
                }
-       }
+       } end_for_each();
 
        ret = zbd_create_zone_info(td, file);
        if (ret < 0)
@@ -1289,13 +1294,10 @@ static uint32_t pick_random_zone_idx(const struct fio_file *f,
 
 static bool any_io_in_flight(void)
 {
-       struct thread_data *td;
-       int i;
-
-       for_each_td(td, i) {
+       for_each_td(td) {
                if (td->io_u_in_flight)
                        return true;
-       }
+       } end_for_each();
 
        return false;
 }