zbd: Fix potential deadlock on read operations
[fio.git] / zbd.c
diff --git a/zbd.c b/zbd.c
index 8dc3c39792931803b07d714ec222b1807c353102..5aaf1e2cf19c7e9645c56f1585bd47fc34b1f147 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -1141,7 +1141,7 @@ zbd_find_zone(struct thread_data *td, struct io_u *io_u,
         */
        for (z1 = zb + 1, z2 = zb - 1; z1 < zl || z2 >= zf; z1++, z2--) {
                if (z1 < zl && z1->cond != ZBD_ZONE_COND_OFFLINE) {
-                       pthread_mutex_lock(&z1->mutex);
+                       zone_lock(td, z1);
                        if (z1->start + min_bs <= z1->wp)
                                return z1;
                        pthread_mutex_unlock(&z1->mutex);
@@ -1150,7 +1150,7 @@ zbd_find_zone(struct thread_data *td, struct io_u *io_u,
                }
                if (td_random(td) && z2 >= zf &&
                    z2->cond != ZBD_ZONE_COND_OFFLINE) {
-                       pthread_mutex_lock(&z2->mutex);
+                       zone_lock(td, z2);
                        if (z2->start + min_bs <= z2->wp)
                                return z2;
                        pthread_mutex_unlock(&z2->mutex);