return z->start + z->capacity;
}
+/**
+ * zbd_zone_remainder - Return the number of bytes that are still available for
+ * writing before the zone gets full
+ * @z: zone info pointer.
+ */
+static inline uint64_t zbd_zone_remainder(struct fio_zone_info *z)
+{
+ if (z->wp >= zbd_zone_capacity_end(z))
+ return 0;
+
+ return zbd_zone_capacity_end(z) - z->wp;
+}
+
/**
* zbd_zone_full - verify whether a minimum number of bytes remain in a zone
* @f: file pointer.
{
assert((required & 511) == 0);
- return z->has_wp &&
- z->wp + required > zbd_zone_capacity_end(z);
+ return z->has_wp && required > zbd_zone_remainder(z);
}
static void zone_lock(struct thread_data *td, const struct fio_file *f,
* already in-flight, handle it as a full zone instead of an
* open zone.
*/
- if (z->wp >= zbd_zone_capacity_end(z))
+ if (!zbd_zone_remainder(z))
res = false;
goto out;
}
/* Both z->mutex and zbdi->mutex are held. */
examine_zone:
- if (z->wp + min_bs <= zbd_zone_capacity_end(z)) {
+ if (zbd_zone_remainder(z) >= min_bs) {
pthread_mutex_unlock(&zbdi->mutex);
goto out;
}
z = zbd_get_zone(f, zone_idx);
zone_lock(td, f, z);
- if (z->wp + min_bs <= zbd_zone_capacity_end(z))
+ if (zbd_zone_remainder(z) >= min_bs)
goto out;
pthread_mutex_lock(&zbdi->mutex);
}