zbd: Rename zbd_init()
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index c30454b91daaa29a1bd0e622dcc8913f0102ea80..db6d09f2bbd5ddefcced111c11bb5e0ad3abc4ef 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -546,8 +546,7 @@ void zbd_free_zone_info(struct fio_file *f)
 {
        uint32_t refcount;
 
-       if (!f->zbd_info)
-               return;
+       assert(f->zbd_info);
 
        pthread_mutex_lock(&f->zbd_info->mutex);
        refcount = --f->zbd_info->refcount;
@@ -592,7 +591,7 @@ static int zbd_init_zone_info(struct thread_data *td, struct fio_file *file)
        return ret;
 }
 
-int zbd_init(struct thread_data *td)
+int zbd_setup_files(struct thread_data *td)
 {
        struct fio_file *f;
        int i;
@@ -743,8 +742,7 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
 
                        reset_wp = z->wp != z->start;
                } else {
-                       reset_wp = (td->o.td_ddir & TD_DDIR_WRITE) &&
-                                       z->wp % min_bs != 0;
+                       reset_wp = z->wp % min_bs != 0;
                }
                if (reset_wp) {
                        dprint(FD_ZBD, "%s: resetting zone %u\n",
@@ -856,7 +854,7 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f)
        struct fio_zone_info *zb, *ze;
        uint32_t zone_idx_e;
 
-       if (!f->zbd_info)
+       if (!f->zbd_info || !td_write(td))
                return;
 
        zb = &f->zbd_info->zone_info[zbd_zone_idx(f, f->file_offset)];
@@ -869,7 +867,6 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f)
         * writing data, which causes data loss.
         */
        zbd_reset_zones(td, f, zb, ze, td->o.verify != VERIFY_NONE &&
-                       (td->o.td_ddir & TD_DDIR_WRITE) &&
                        td->runstate != TD_VERIFYING);
        zbd_reset_write_cnt(td, f);
 }