Fio 3.37
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index 61b5b688ca9aba5df7f9103590da914be6786d03..3741766051547fbc71a46ab42efe72a181826993 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -104,8 +104,7 @@ static void zone_lock(struct thread_data *td, const struct fio_file *f,
                      struct fio_zone_info *z)
 {
 #ifndef NDEBUG
-       struct zoned_block_device_info *zbd = f->zbd_info;
-       uint32_t const nz = z - zbd->zone_info;
+       unsigned int const nz = zbd_zone_idx(f, z);
        /* A thread should never lock zones outside its working area. */
        assert(f->min_zone <= nz && nz < f->max_zone);
        assert(z->has_wp);
@@ -674,9 +673,20 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td,
                return false;
        }
 
+       if (td->o.td_ddir == TD_DDIR_READ) {
+               z = zbd_offset_to_zone(f, f->file_offset + f->io_size);
+               new_end = z->start;
+               if (f->file_offset + f->io_size > new_end) {
+                       log_info("%s: rounded io_size from %"PRIu64" to %"PRIu64"\n",
+                                f->file_name, f->io_size,
+                                new_end - f->file_offset);
+                       f->io_size = new_end - f->file_offset;
+               }
+               return true;
+       }
+
        z = zbd_offset_to_zone(f, f->file_offset);
-       if ((f->file_offset != z->start) &&
-           (td->o.td_ddir != TD_DDIR_READ)) {
+       if (f->file_offset != z->start) {
                new_offset = zbd_zone_end(z);
                if (new_offset >= f->file_offset + f->io_size) {
                        log_info("%s: io_size must be at least one zone\n",
@@ -692,8 +702,7 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td,
 
        z = zbd_offset_to_zone(f, f->file_offset + f->io_size);
        new_end = z->start;
-       if ((td->o.td_ddir != TD_DDIR_READ) &&
-           (f->file_offset + f->io_size != new_end)) {
+       if (f->file_offset + f->io_size != new_end) {
                if (new_end <= f->file_offset) {
                        log_info("%s: io_size must be at least one zone\n",
                                 f->file_name);