t/zbd: check log file for failed assertions
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index 85478aa5dc1569cf5c8c25d8c89504059529b2da..e4a480b7e7967216aa5ba9f5b7c21ac03b33d4c5 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -670,24 +670,33 @@ int zbd_setup_files(struct thread_data *td)
        return 0;
 }
 
+static unsigned int zbd_zone_nr(struct zoned_block_device_info *zbd_info,
+                               struct fio_zone_info *zone)
+{
+       return zone - zbd_info->zone_info;
+}
+
 /**
- * zbd_reset_range - reset zones for a range of sectors
+ * zbd_reset_zone - reset the write pointer of a single zone
  * @td: FIO thread data.
- * @f: Fio file for which to reset zones
- * @sector: Starting sector in units of 512 bytes
- * @nr_sectors: Number of sectors in units of 512 bytes
+ * @f: FIO file associated with the disk for which to reset a write pointer.
+ * @z: Zone to reset.
  *
  * Returns 0 upon success and a negative error code upon failure.
+ *
+ * The caller must hold z->mutex.
  */
-static int zbd_reset_range(struct thread_data *td, struct fio_file *f,
-                          uint64_t offset, uint64_t length)
+static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
+                         struct fio_zone_info *z)
 {
-       uint32_t zone_idx_b, zone_idx_e;
-       struct fio_zone_info *zb, *ze, *z;
+       uint64_t offset = z->start;
+       uint64_t length = (z+1)->start - offset;
        int ret = 0;
 
        assert(is_valid_offset(f, offset + length - 1));
 
+       dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
+               zbd_zone_nr(f->zbd_info, z));
        switch (f->zbd_info->model) {
        case ZBD_HOST_AWARE:
        case ZBD_HOST_MANAGED:
@@ -699,48 +708,17 @@ static int zbd_reset_range(struct thread_data *td, struct fio_file *f,
                break;
        }
 
-       zone_idx_b = zbd_zone_idx(f, offset);
-       zb = &f->zbd_info->zone_info[zone_idx_b];
-       zone_idx_e = zbd_zone_idx(f, offset + length);
-       ze = &f->zbd_info->zone_info[zone_idx_e];
-       for (z = zb; z < ze; z++) {
-               pthread_mutex_lock(&z->mutex);
-               pthread_mutex_lock(&f->zbd_info->mutex);
-               f->zbd_info->sectors_with_data -= z->wp - z->start;
-               pthread_mutex_unlock(&f->zbd_info->mutex);
-               z->wp = z->start;
-               z->verify_block = 0;
-               pthread_mutex_unlock(&z->mutex);
-       }
+       pthread_mutex_lock(&f->zbd_info->mutex);
+       f->zbd_info->sectors_with_data -= z->wp - z->start;
+       pthread_mutex_unlock(&f->zbd_info->mutex);
+       z->wp = z->start;
+       z->verify_block = 0;
 
-       td->ts.nr_zone_resets += ze - zb;
+       td->ts.nr_zone_resets++;
 
        return ret;
 }
 
-static unsigned int zbd_zone_nr(struct zoned_block_device_info *zbd_info,
-                               struct fio_zone_info *zone)
-{
-       return zone - zbd_info->zone_info;
-}
-
-/**
- * zbd_reset_zone - reset the write pointer of a single zone
- * @td: FIO thread data.
- * @f: FIO file associated with the disk for which to reset a write pointer.
- * @z: Zone to reset.
- *
- * Returns 0 upon success and a negative error code upon failure.
- */
-static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
-                         struct fio_zone_info *z)
-{
-       dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
-               zbd_zone_nr(f->zbd_info, z));
-
-       return zbd_reset_range(td, f, z->start, zbd_zone_end(z) - z->start);
-}
-
 /* The caller must hold f->zbd_info->mutex */
 static void zbd_close_zone(struct thread_data *td, const struct fio_file *f,
                           unsigned int open_zone_idx)
@@ -1371,9 +1349,11 @@ void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u)
            f->last_pos[ddir] >= zbd_zone_capacity_end(z)) {
                dprint(FD_ZBD,
                       "%s: Jump from zone capacity limit to zone end:"
-                      " (%lu -> %lu) for zone %u (%ld)\n",
-                      f->file_name, f->last_pos[ddir], zbd_zone_end(z),
-                      zbd_zone_nr(f->zbd_info, z), z->capacity);
+                      " (%llu -> %llu) for zone %u (%llu)\n",
+                      f->file_name, (unsigned long long) f->last_pos[ddir],
+                      (unsigned long long) zbd_zone_end(z),
+                      zbd_zone_nr(f->zbd_info, z),
+                      (unsigned long long) z->capacity);
                td->io_skip_bytes += zbd_zone_end(z) - f->last_pos[ddir];
                f->last_pos[ddir] = zbd_zone_end(z);
        }