2 * Copyright (C) 2018 Western Digital Corporation or its affiliates.
4 * This file is released under the GPL.
19 #include "oslib/asprintf.h"
26 * zbd_get_zoned_model - Get a device zoned model
27 * @td: FIO thread data
28 * @f: FIO file for which to get model information
30 int zbd_get_zoned_model(struct thread_data *td, struct fio_file *f,
31 enum zbd_zoned_model *model)
35 if (td->io_ops && td->io_ops->get_zoned_model)
36 ret = td->io_ops->get_zoned_model(td, f, model);
38 ret = blkzoned_get_zoned_model(td, f, model);
40 td_verror(td, errno, "get zoned model failed");
41 log_err("%s: get zoned model failed (%d).\n",
49 * zbd_report_zones - Get zone information
50 * @td: FIO thread data.
51 * @f: FIO file for which to get zone information
52 * @offset: offset from which to report zones
53 * @zones: Array of struct zbd_zone
54 * @nr_zones: Size of @zones array
56 * Get zone information into @zones starting from the zone at offset @offset
57 * for the device specified by @f.
59 * Returns the number of zones reported upon success and a negative error code
60 * upon failure. If the zone report is empty, always assume an error (device
61 * problem) and return -EIO.
63 int zbd_report_zones(struct thread_data *td, struct fio_file *f,
64 uint64_t offset, struct zbd_zone *zones,
65 unsigned int nr_zones)
69 if (td->io_ops && td->io_ops->report_zones)
70 ret = td->io_ops->report_zones(td, f, offset, zones, nr_zones);
72 ret = blkzoned_report_zones(td, f, offset, zones, nr_zones);
74 td_verror(td, errno, "report zones failed");
75 log_err("%s: report zones from sector %llu failed (%d).\n",
76 f->file_name, (unsigned long long)offset >> 9, errno);
77 } else if (ret == 0) {
78 td_verror(td, errno, "Empty zone report");
79 log_err("%s: report zones from sector %llu is empty.\n",
80 f->file_name, (unsigned long long)offset >> 9);
88 * zbd_reset_wp - reset the write pointer of a range of zones
89 * @td: FIO thread data.
90 * @f: FIO file for which to reset zones
91 * @offset: Starting offset of the first zone to reset
92 * @length: Length of the range of zones to reset
94 * Reset the write pointer of all zones in the range @offset...@offset+@length.
95 * Returns 0 upon success and a negative error code upon failure.
97 int zbd_reset_wp(struct thread_data *td, struct fio_file *f,
98 uint64_t offset, uint64_t length)
102 if (td->io_ops && td->io_ops->reset_wp)
103 ret = td->io_ops->reset_wp(td, f, offset, length);
105 ret = blkzoned_reset_wp(td, f, offset, length);
107 td_verror(td, errno, "resetting wp failed");
108 log_err("%s: resetting wp for %llu sectors at sector %llu failed (%d).\n",
109 f->file_name, (unsigned long long)length >> 9,
110 (unsigned long long)offset >> 9, errno);
117 * zbd_zone_idx - convert an offset into a zone number
119 * @offset: offset in bytes. If this offset is in the first zone_size bytes
120 * past the disk size then the index of the sentinel is returned.
122 static uint32_t zbd_zone_idx(const struct fio_file *f, uint64_t offset)
126 if (f->zbd_info->zone_size_log2 > 0)
127 zone_idx = offset >> f->zbd_info->zone_size_log2;
129 zone_idx = offset / f->zbd_info->zone_size;
131 return min(zone_idx, f->zbd_info->nr_zones);
135 * zbd_zone_end - Return zone end location
136 * @z: zone info pointer.
138 static inline uint64_t zbd_zone_end(const struct fio_zone_info *z)
144 * zbd_zone_capacity_end - Return zone capacity limit end location
145 * @z: zone info pointer.
147 static inline uint64_t zbd_zone_capacity_end(const struct fio_zone_info *z)
149 return z->start + z->capacity;
153 * zbd_zone_full - verify whether a minimum number of bytes remain in a zone
155 * @z: zone info pointer.
156 * @required: minimum number of bytes that must remain in a zone.
158 * The caller must hold z->mutex.
160 static bool zbd_zone_full(const struct fio_file *f, struct fio_zone_info *z,
163 assert((required & 511) == 0);
166 z->wp + required > zbd_zone_capacity_end(z);
169 static void zone_lock(struct thread_data *td, const struct fio_file *f,
170 struct fio_zone_info *z)
172 struct zoned_block_device_info *zbd = f->zbd_info;
173 uint32_t nz = z - zbd->zone_info;
175 /* A thread should never lock zones outside its working area. */
176 assert(f->min_zone <= nz && nz < f->max_zone);
181 * Lock the io_u target zone. The zone will be unlocked if io_u offset
182 * is changed or when io_u completes and zbd_put_io() executed.
183 * To avoid multiple jobs doing asynchronous I/Os from deadlocking each
184 * other waiting for zone locks when building an io_u batch, first
185 * only trylock the zone. If the zone is already locked by another job,
186 * process the currently queued I/Os so that I/O progress is made and
189 if (pthread_mutex_trylock(&z->mutex) != 0) {
190 if (!td_ioengine_flagged(td, FIO_SYNCIO))
192 pthread_mutex_lock(&z->mutex);
196 static inline void zone_unlock(struct fio_zone_info *z)
201 ret = pthread_mutex_unlock(&z->mutex);
205 static bool is_valid_offset(const struct fio_file *f, uint64_t offset)
207 return (uint64_t)(offset - f->file_offset) < f->io_size;
210 static inline struct fio_zone_info *get_zone(const struct fio_file *f,
211 unsigned int zone_nr)
213 return &f->zbd_info->zone_info[zone_nr];
216 /* Verify whether direct I/O is used for all host-managed zoned drives. */
217 static bool zbd_using_direct_io(void)
219 struct thread_data *td;
224 if (td->o.odirect || !(td->o.td_ddir & TD_DDIR_WRITE))
226 for_each_file(td, f, j) {
228 f->zbd_info->model == ZBD_HOST_MANAGED)
236 /* Whether or not the I/O range for f includes one or more sequential zones */
237 static bool zbd_is_seq_job(struct fio_file *f)
239 uint32_t zone_idx, zone_idx_b, zone_idx_e;
244 zone_idx_b = zbd_zone_idx(f, f->file_offset);
245 zone_idx_e = zbd_zone_idx(f, f->file_offset + f->io_size - 1);
246 for (zone_idx = zone_idx_b; zone_idx <= zone_idx_e; zone_idx++)
247 if (get_zone(f, zone_idx)->has_wp)
254 * Verify whether offset and size parameters are aligned with zone boundaries.
256 static bool zbd_verify_sizes(void)
258 const struct fio_zone_info *z;
259 struct thread_data *td;
261 uint64_t new_offset, new_end;
266 for_each_file(td, f, j) {
269 if (f->file_offset >= f->real_file_size)
271 if (!zbd_is_seq_job(f))
274 if (!td->o.zone_size) {
275 td->o.zone_size = f->zbd_info->zone_size;
276 if (!td->o.zone_size) {
277 log_err("%s: invalid 0 zone size\n",
281 } else if (td->o.zone_size != f->zbd_info->zone_size) {
282 log_err("%s: job parameter zonesize %llu does not match disk zone size %llu.\n",
283 f->file_name, (unsigned long long) td->o.zone_size,
284 (unsigned long long) f->zbd_info->zone_size);
288 if (td->o.zone_skip &&
289 (td->o.zone_skip < td->o.zone_size ||
290 td->o.zone_skip % td->o.zone_size)) {
291 log_err("%s: zoneskip %llu is not a multiple of the device zone size %llu.\n",
292 f->file_name, (unsigned long long) td->o.zone_skip,
293 (unsigned long long) td->o.zone_size);
297 zone_idx = zbd_zone_idx(f, f->file_offset);
298 z = get_zone(f, zone_idx);
299 if ((f->file_offset != z->start) &&
300 (td->o.td_ddir != TD_DDIR_READ)) {
301 new_offset = zbd_zone_end(z);
302 if (new_offset >= f->file_offset + f->io_size) {
303 log_info("%s: io_size must be at least one zone\n",
307 log_info("%s: rounded up offset from %llu to %llu\n",
308 f->file_name, (unsigned long long) f->file_offset,
309 (unsigned long long) new_offset);
310 f->io_size -= (new_offset - f->file_offset);
311 f->file_offset = new_offset;
313 zone_idx = zbd_zone_idx(f, f->file_offset + f->io_size);
314 z = get_zone(f, zone_idx);
316 if ((td->o.td_ddir != TD_DDIR_READ) &&
317 (f->file_offset + f->io_size != new_end)) {
318 if (new_end <= f->file_offset) {
319 log_info("%s: io_size must be at least one zone\n",
323 log_info("%s: rounded down io_size from %llu to %llu\n",
324 f->file_name, (unsigned long long) f->io_size,
325 (unsigned long long) new_end - f->file_offset);
326 f->io_size = new_end - f->file_offset;
334 static bool zbd_verify_bs(void)
336 struct thread_data *td;
342 for_each_file(td, f, j) {
345 zone_size = f->zbd_info->zone_size;
346 for (k = 0; k < FIO_ARRAY_SIZE(td->o.bs); k++) {
347 if (td->o.verify != VERIFY_NONE &&
348 zone_size % td->o.bs[k] != 0) {
349 log_info("%s: block size %llu is not a divisor of the zone size %d\n",
350 f->file_name, td->o.bs[k],
360 static int ilog2(uint64_t i)
372 * Initialize f->zbd_info for devices that are not zoned block devices. This
373 * allows to execute a ZBD workload against a non-ZBD device.
375 static int init_zone_info(struct thread_data *td, struct fio_file *f)
378 struct fio_zone_info *p;
379 uint64_t zone_size = td->o.zone_size;
380 uint64_t zone_capacity = td->o.zone_capacity;
381 struct zoned_block_device_info *zbd_info = NULL;
384 if (zone_size == 0) {
385 log_err("%s: Specifying the zone size is mandatory for regular block devices with --zonemode=zbd\n\n",
390 if (zone_size < 512) {
391 log_err("%s: zone size must be at least 512 bytes for --zonemode=zbd\n\n",
396 if (zone_capacity == 0)
397 zone_capacity = zone_size;
399 if (zone_capacity > zone_size) {
400 log_err("%s: job parameter zonecapacity %llu is larger than zone size %llu\n",
401 f->file_name, (unsigned long long) td->o.zone_capacity,
402 (unsigned long long) td->o.zone_size);
406 nr_zones = (f->real_file_size + zone_size - 1) / zone_size;
407 zbd_info = scalloc(1, sizeof(*zbd_info) +
408 (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
412 mutex_init_pshared(&zbd_info->mutex);
413 zbd_info->refcount = 1;
414 p = &zbd_info->zone_info[0];
415 for (i = 0; i < nr_zones; i++, p++) {
416 mutex_init_pshared_with_type(&p->mutex,
417 PTHREAD_MUTEX_RECURSIVE);
418 p->start = i * zone_size;
420 p->type = ZBD_ZONE_TYPE_SWR;
421 p->cond = ZBD_ZONE_COND_EMPTY;
422 p->capacity = zone_capacity;
426 p->start = nr_zones * zone_size;
428 f->zbd_info = zbd_info;
429 f->zbd_info->zone_size = zone_size;
430 f->zbd_info->zone_size_log2 = is_power_of_2(zone_size) ?
431 ilog2(zone_size) : 0;
432 f->zbd_info->nr_zones = nr_zones;
437 * Maximum number of zones to report in one operation.
439 #define ZBD_REPORT_MAX_ZONES 8192U
442 * Parse the device zone report and store it in f->zbd_info. Must be called
443 * only for devices that are zoned, namely those with a model != ZBD_NONE.
445 static int parse_zone_info(struct thread_data *td, struct fio_file *f)
448 struct zbd_zone *zones, *z;
449 struct fio_zone_info *p;
450 uint64_t zone_size, offset;
451 struct zoned_block_device_info *zbd_info = NULL;
452 int i, j, ret = -ENOMEM;
454 zones = calloc(ZBD_REPORT_MAX_ZONES, sizeof(struct zbd_zone));
458 nrz = zbd_report_zones(td, f, 0, zones, ZBD_REPORT_MAX_ZONES);
461 log_info("fio: report zones (offset 0) failed for %s (%d).\n",
466 zone_size = zones[0].len;
467 nr_zones = (f->real_file_size + zone_size - 1) / zone_size;
469 if (td->o.zone_size == 0) {
470 td->o.zone_size = zone_size;
471 } else if (td->o.zone_size != zone_size) {
472 log_err("fio: %s job parameter zonesize %llu does not match disk zone size %llu.\n",
473 f->file_name, (unsigned long long) td->o.zone_size,
474 (unsigned long long) zone_size);
479 dprint(FD_ZBD, "Device %s has %d zones of size %llu KB\n", f->file_name,
480 nr_zones, (unsigned long long) zone_size / 1024);
482 zbd_info = scalloc(1, sizeof(*zbd_info) +
483 (nr_zones + 1) * sizeof(zbd_info->zone_info[0]));
486 mutex_init_pshared(&zbd_info->mutex);
487 zbd_info->refcount = 1;
488 p = &zbd_info->zone_info[0];
489 for (offset = 0, j = 0; j < nr_zones;) {
491 for (i = 0; i < nrz; i++, j++, z++, p++) {
492 mutex_init_pshared_with_type(&p->mutex,
493 PTHREAD_MUTEX_RECURSIVE);
495 p->capacity = z->capacity;
497 case ZBD_ZONE_COND_NOT_WP:
498 case ZBD_ZONE_COND_FULL:
499 p->wp = p->start + p->capacity;
502 assert(z->start <= z->wp);
503 assert(z->wp <= z->start + zone_size);
509 case ZBD_ZONE_TYPE_SWR:
518 if (j > 0 && p->start != p[-1].start + zone_size) {
519 log_info("%s: invalid zone data\n",
526 offset = z->start + z->len;
529 nrz = zbd_report_zones(td, f, offset, zones,
530 min((uint32_t)(nr_zones - j),
531 ZBD_REPORT_MAX_ZONES));
534 log_info("fio: report zones (offset %llu) failed for %s (%d).\n",
535 (unsigned long long)offset,
542 zbd_info->zone_info[nr_zones].start = offset;
544 f->zbd_info = zbd_info;
545 f->zbd_info->zone_size = zone_size;
546 f->zbd_info->zone_size_log2 = is_power_of_2(zone_size) ?
547 ilog2(zone_size) : 0;
548 f->zbd_info->nr_zones = nr_zones;
559 * Allocate zone information and store it into f->zbd_info if zonemode=zbd.
561 * Returns 0 upon success and a negative error code upon failure.
563 static int zbd_create_zone_info(struct thread_data *td, struct fio_file *f)
565 enum zbd_zoned_model zbd_model;
568 assert(td->o.zone_mode == ZONE_MODE_ZBD);
570 ret = zbd_get_zoned_model(td, f, &zbd_model);
578 case ZBD_HOST_MANAGED:
579 ret = parse_zone_info(td, f);
582 ret = init_zone_info(td, f);
585 td_verror(td, EINVAL, "Unsupported zoned model");
586 log_err("Unsupported zoned model\n");
591 f->zbd_info->model = zbd_model;
592 f->zbd_info->max_open_zones = td->o.max_open_zones;
597 void zbd_free_zone_info(struct fio_file *f)
603 pthread_mutex_lock(&f->zbd_info->mutex);
604 refcount = --f->zbd_info->refcount;
605 pthread_mutex_unlock(&f->zbd_info->mutex);
607 assert((int32_t)refcount >= 0);
614 * Initialize f->zbd_info.
616 * Returns 0 upon success and a negative error code upon failure.
618 * Note: this function can only work correctly if it is called before the first
621 static int zbd_init_zone_info(struct thread_data *td, struct fio_file *file)
623 struct thread_data *td2;
627 for_each_td(td2, i) {
628 for_each_file(td2, f2, j) {
629 if (td2 == td && f2 == file)
632 strcmp(f2->file_name, file->file_name) != 0)
634 file->zbd_info = f2->zbd_info;
635 file->zbd_info->refcount++;
640 ret = zbd_create_zone_info(td, file);
642 td_verror(td, -ret, "zbd_create_zone_info() failed");
646 static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
648 static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
649 struct fio_zone_info *z);
651 int zbd_setup_files(struct thread_data *td)
656 for_each_file(td, f, i) {
657 if (zbd_init_zone_info(td, f))
661 if (!zbd_using_direct_io()) {
662 log_err("Using direct I/O is mandatory for writing to ZBD drives\n\n");
666 if (!zbd_verify_sizes())
669 if (!zbd_verify_bs())
672 for_each_file(td, f, i) {
673 struct zoned_block_device_info *zbd = f->zbd_info;
674 struct fio_zone_info *z;
680 f->min_zone = zbd_zone_idx(f, f->file_offset);
681 f->max_zone = zbd_zone_idx(f, f->file_offset + f->io_size);
684 * When all zones in the I/O range are conventional, io_size
685 * can be smaller than zone size, making min_zone the same
686 * as max_zone. This is why the assert below needs to be made
689 if (zbd_is_seq_job(f))
690 assert(f->min_zone < f->max_zone);
692 zbd->max_open_zones = zbd->max_open_zones ?: ZBD_MAX_OPEN_ZONES;
694 if (td->o.max_open_zones > 0 &&
695 zbd->max_open_zones != td->o.max_open_zones) {
696 log_err("Different 'max_open_zones' values\n");
699 if (zbd->max_open_zones > ZBD_MAX_OPEN_ZONES) {
700 log_err("'max_open_zones' value is limited by %u\n", ZBD_MAX_OPEN_ZONES);
704 for (zi = f->min_zone; zi < f->max_zone; zi++) {
705 z = &zbd->zone_info[zi];
706 if (z->cond != ZBD_ZONE_COND_IMP_OPEN &&
707 z->cond != ZBD_ZONE_COND_EXP_OPEN)
709 if (zbd_open_zone(td, f, zi))
712 * If the number of open zones exceeds specified limits,
713 * reset all extra open zones.
715 if (zbd_reset_zone(td, f, z) < 0) {
716 log_err("Failed to reest zone %d\n", zi);
725 static inline unsigned int zbd_zone_nr(const struct fio_file *f,
726 struct fio_zone_info *zone)
728 return zone - f->zbd_info->zone_info;
732 * zbd_reset_zone - reset the write pointer of a single zone
733 * @td: FIO thread data.
734 * @f: FIO file associated with the disk for which to reset a write pointer.
737 * Returns 0 upon success and a negative error code upon failure.
739 * The caller must hold z->mutex.
741 static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
742 struct fio_zone_info *z)
744 uint64_t offset = z->start;
745 uint64_t length = (z+1)->start - offset;
746 uint64_t data_in_zone = z->wp - z->start;
752 assert(is_valid_offset(f, offset + length - 1));
754 dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
756 switch (f->zbd_info->model) {
758 case ZBD_HOST_MANAGED:
759 ret = zbd_reset_wp(td, f, offset, length);
767 pthread_mutex_lock(&f->zbd_info->mutex);
768 f->zbd_info->sectors_with_data -= data_in_zone;
769 f->zbd_info->wp_sectors_with_data -= data_in_zone;
770 pthread_mutex_unlock(&f->zbd_info->mutex);
774 td->ts.nr_zone_resets++;
779 /* The caller must hold f->zbd_info->mutex */
780 static void zbd_close_zone(struct thread_data *td, const struct fio_file *f,
781 unsigned int zone_idx)
783 uint32_t open_zone_idx = 0;
785 for (; open_zone_idx < f->zbd_info->num_open_zones; open_zone_idx++) {
786 if (f->zbd_info->open_zones[open_zone_idx] == zone_idx)
789 if (open_zone_idx == f->zbd_info->num_open_zones)
792 dprint(FD_ZBD, "%s: closing zone %d\n", f->file_name, zone_idx);
793 memmove(f->zbd_info->open_zones + open_zone_idx,
794 f->zbd_info->open_zones + open_zone_idx + 1,
795 (ZBD_MAX_OPEN_ZONES - (open_zone_idx + 1)) *
796 sizeof(f->zbd_info->open_zones[0]));
797 f->zbd_info->num_open_zones--;
798 td->num_open_zones--;
799 get_zone(f, zone_idx)->open = 0;
803 * Reset a range of zones. Returns 0 upon success and 1 upon failure.
804 * @td: fio thread data.
805 * @f: fio file for which to reset zones
806 * @zb: first zone to reset.
807 * @ze: first zone not to reset.
808 * @all_zones: whether to reset all zones or only those zones for which the
809 * write pointer is not a multiple of td->o.min_bs[DDIR_WRITE].
811 static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
812 struct fio_zone_info *const zb,
813 struct fio_zone_info *const ze, bool all_zones)
815 struct fio_zone_info *z;
816 const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
822 dprint(FD_ZBD, "%s: examining zones %u .. %u\n", f->file_name,
823 zbd_zone_nr(f, zb), zbd_zone_nr(f, ze));
824 for (z = zb; z < ze; z++) {
825 uint32_t nz = zbd_zone_nr(f, z);
831 pthread_mutex_lock(&f->zbd_info->mutex);
832 zbd_close_zone(td, f, nz);
833 pthread_mutex_unlock(&f->zbd_info->mutex);
835 reset_wp = z->wp != z->start;
837 reset_wp = z->wp % min_bs != 0;
840 dprint(FD_ZBD, "%s: resetting zone %u\n",
841 f->file_name, zbd_zone_nr(f, z));
842 if (zbd_reset_zone(td, f, z) < 0)
852 * Reset zbd_info.write_cnt, the counter that counts down towards the next
855 static void _zbd_reset_write_cnt(const struct thread_data *td,
856 const struct fio_file *f)
858 assert(0 <= td->o.zrf.u.f && td->o.zrf.u.f <= 1);
860 f->zbd_info->write_cnt = td->o.zrf.u.f ?
861 min(1.0 / td->o.zrf.u.f, 0.0 + UINT_MAX) : UINT_MAX;
864 static void zbd_reset_write_cnt(const struct thread_data *td,
865 const struct fio_file *f)
867 pthread_mutex_lock(&f->zbd_info->mutex);
868 _zbd_reset_write_cnt(td, f);
869 pthread_mutex_unlock(&f->zbd_info->mutex);
872 static bool zbd_dec_and_reset_write_cnt(const struct thread_data *td,
873 const struct fio_file *f)
875 uint32_t write_cnt = 0;
877 pthread_mutex_lock(&f->zbd_info->mutex);
878 assert(f->zbd_info->write_cnt);
879 if (f->zbd_info->write_cnt)
880 write_cnt = --f->zbd_info->write_cnt;
882 _zbd_reset_write_cnt(td, f);
883 pthread_mutex_unlock(&f->zbd_info->mutex);
885 return write_cnt == 0;
893 /* Calculate the number of sectors with data (swd) and perform action 'a' */
894 static uint64_t zbd_process_swd(struct thread_data *td,
895 const struct fio_file *f, enum swd_action a)
897 struct fio_zone_info *zb, *ze, *z;
901 zb = get_zone(f, f->min_zone);
902 ze = get_zone(f, f->max_zone);
903 for (z = zb; z < ze; z++) {
906 wp_swd += z->wp - z->start;
908 swd += z->wp - z->start;
910 pthread_mutex_lock(&f->zbd_info->mutex);
913 assert(f->zbd_info->sectors_with_data == swd);
914 assert(f->zbd_info->wp_sectors_with_data == wp_swd);
917 f->zbd_info->sectors_with_data = swd;
918 f->zbd_info->wp_sectors_with_data = wp_swd;
921 pthread_mutex_unlock(&f->zbd_info->mutex);
922 for (z = zb; z < ze; z++)
930 * The swd check is useful for debugging but takes too much time to leave
931 * it enabled all the time. Hence it is disabled by default.
933 static const bool enable_check_swd = false;
935 /* Check whether the values of zbd_info.*sectors_with_data are correct. */
936 static void zbd_check_swd(struct thread_data *td, const struct fio_file *f)
938 if (!enable_check_swd)
941 zbd_process_swd(td, f, CHECK_SWD);
944 void zbd_file_reset(struct thread_data *td, struct fio_file *f)
946 struct fio_zone_info *zb, *ze;
949 if (!f->zbd_info || !td_write(td))
952 zb = get_zone(f, f->min_zone);
953 ze = get_zone(f, f->max_zone);
954 swd = zbd_process_swd(td, f, SET_SWD);
955 dprint(FD_ZBD, "%s(%s): swd = %" PRIu64 "\n", __func__, f->file_name,
958 * If data verification is enabled reset the affected zones before
959 * writing any data to avoid that a zone reset has to be issued while
960 * writing data, which causes data loss.
962 zbd_reset_zones(td, f, zb, ze, td->o.verify != VERIFY_NONE &&
963 td->runstate != TD_VERIFYING);
964 zbd_reset_write_cnt(td, f);
967 /* The caller must hold f->zbd_info->mutex. */
968 static bool is_zone_open(const struct thread_data *td, const struct fio_file *f,
969 unsigned int zone_idx)
971 struct zoned_block_device_info *zbdi = f->zbd_info;
974 assert(td->o.job_max_open_zones == 0 || td->num_open_zones <= td->o.job_max_open_zones);
975 assert(td->o.job_max_open_zones <= zbdi->max_open_zones);
976 assert(zbdi->num_open_zones <= zbdi->max_open_zones);
978 for (i = 0; i < zbdi->num_open_zones; i++)
979 if (zbdi->open_zones[i] == zone_idx)
986 * Open a ZBD zone if it was not yet open. Returns true if either the zone was
987 * already open or if opening a new zone is allowed. Returns false if the zone
988 * was not yet open and opening a new zone would cause the zone limit to be
991 static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
994 const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
995 struct fio_zone_info *z = get_zone(f, zone_idx);
998 if (z->cond == ZBD_ZONE_COND_OFFLINE)
1002 * Skip full zones with data verification enabled because resetting a
1003 * zone causes data loss and hence causes verification to fail.
1005 if (td->o.verify != VERIFY_NONE && zbd_zone_full(f, z, min_bs))
1008 pthread_mutex_lock(&f->zbd_info->mutex);
1009 if (is_zone_open(td, f, zone_idx)) {
1011 * If the zone is already open and going to be full by writes
1012 * in-flight, handle it as a full zone instead of an open zone.
1014 if (z->wp >= zbd_zone_capacity_end(z))
1019 /* Zero means no limit */
1020 if (td->o.job_max_open_zones > 0 &&
1021 td->num_open_zones >= td->o.job_max_open_zones)
1023 if (f->zbd_info->num_open_zones >= f->zbd_info->max_open_zones)
1025 dprint(FD_ZBD, "%s: opening zone %d\n", f->file_name, zone_idx);
1026 f->zbd_info->open_zones[f->zbd_info->num_open_zones++] = zone_idx;
1027 td->num_open_zones++;
1032 pthread_mutex_unlock(&f->zbd_info->mutex);
1036 /* Anything goes as long as it is not a constant. */
1037 static uint32_t pick_random_zone_idx(const struct fio_file *f,
1038 const struct io_u *io_u)
1040 return io_u->offset * f->zbd_info->num_open_zones / f->real_file_size;
1044 * Modify the offset of an I/O unit that does not refer to an open zone such
1045 * that it refers to an open zone. Close an open zone and open a new zone if
1046 * necessary. The open zone is searched across sequential zones.
1047 * This algorithm can only work correctly if all write pointers are
1048 * a multiple of the fio block size. The caller must neither hold z->mutex
1049 * nor f->zbd_info->mutex. Returns with z->mutex held upon success.
1051 static struct fio_zone_info *zbd_convert_to_open_zone(struct thread_data *td,
1054 const uint32_t min_bs = td->o.min_bs[io_u->ddir];
1055 struct fio_file *f = io_u->file;
1056 struct fio_zone_info *z;
1057 unsigned int open_zone_idx = -1;
1058 uint32_t zone_idx, new_zone_idx;
1060 bool wait_zone_close;
1062 assert(is_valid_offset(f, io_u->offset));
1064 if (td->o.max_open_zones || td->o.job_max_open_zones) {
1066 * This statement accesses f->zbd_info->open_zones[] on purpose
1069 zone_idx = f->zbd_info->open_zones[pick_random_zone_idx(f, io_u)];
1071 zone_idx = zbd_zone_idx(f, io_u->offset);
1073 if (zone_idx < f->min_zone)
1074 zone_idx = f->min_zone;
1075 else if (zone_idx >= f->max_zone)
1076 zone_idx = f->max_zone - 1;
1077 dprint(FD_ZBD, "%s(%s): starting from zone %d (offset %lld, buflen %lld)\n",
1078 __func__, f->file_name, zone_idx, io_u->offset, io_u->buflen);
1081 * Since z->mutex is the outer lock and f->zbd_info->mutex the inner
1082 * lock it can happen that the state of the zone with index zone_idx
1083 * has changed after 'z' has been assigned and before f->zbd_info->mutex
1084 * has been obtained. Hence the loop.
1089 z = get_zone(f, zone_idx);
1091 zone_lock(td, f, z);
1092 pthread_mutex_lock(&f->zbd_info->mutex);
1093 if (z->cond != ZBD_ZONE_COND_OFFLINE &&
1094 td->o.max_open_zones == 0 && td->o.job_max_open_zones == 0)
1096 if (f->zbd_info->num_open_zones == 0) {
1097 dprint(FD_ZBD, "%s(%s): no zones are open\n",
1098 __func__, f->file_name);
1099 goto open_other_zone;
1103 * List of opened zones is per-device, shared across all threads.
1104 * Start with quasi-random candidate zone.
1105 * Ignore zones which don't belong to thread's offset/size area.
1107 open_zone_idx = pick_random_zone_idx(f, io_u);
1108 assert(open_zone_idx < f->zbd_info->num_open_zones);
1109 tmp_idx = open_zone_idx;
1110 for (i = 0; i < f->zbd_info->num_open_zones; i++) {
1113 if (tmp_idx >= f->zbd_info->num_open_zones)
1115 tmpz = f->zbd_info->open_zones[tmp_idx];
1116 if (f->min_zone <= tmpz && tmpz < f->max_zone) {
1117 open_zone_idx = tmp_idx;
1118 goto found_candidate_zone;
1124 dprint(FD_ZBD, "%s(%s): no candidate zone\n",
1125 __func__, f->file_name);
1126 pthread_mutex_unlock(&f->zbd_info->mutex);
1130 found_candidate_zone:
1131 new_zone_idx = f->zbd_info->open_zones[open_zone_idx];
1132 if (new_zone_idx == zone_idx)
1134 zone_idx = new_zone_idx;
1135 pthread_mutex_unlock(&f->zbd_info->mutex);
1139 /* Both z->mutex and f->zbd_info->mutex are held. */
1142 if (z->wp + min_bs <= zbd_zone_capacity_end(z)) {
1143 pthread_mutex_unlock(&f->zbd_info->mutex);
1148 /* Check if number of open zones reaches one of limits. */
1150 f->zbd_info->num_open_zones == f->max_zone - f->min_zone ||
1151 (td->o.max_open_zones &&
1152 f->zbd_info->num_open_zones == td->o.max_open_zones) ||
1153 (td->o.job_max_open_zones &&
1154 td->num_open_zones == td->o.job_max_open_zones);
1156 pthread_mutex_unlock(&f->zbd_info->mutex);
1158 /* Only z->mutex is held. */
1161 * When number of open zones reaches to one of limits, wait for
1162 * zone close before opening a new zone.
1164 if (wait_zone_close) {
1165 dprint(FD_ZBD, "%s(%s): quiesce to allow open zones to close\n",
1166 __func__, f->file_name);
1170 /* Zone 'z' is full, so try to open a new zone. */
1171 for (i = f->io_size / f->zbd_info->zone_size; i > 0; i--) {
1176 if (!is_valid_offset(f, z->start)) {
1178 zone_idx = f->min_zone;
1179 z = get_zone(f, zone_idx);
1181 assert(is_valid_offset(f, z->start));
1184 zone_lock(td, f, z);
1187 if (zbd_open_zone(td, f, zone_idx))
1191 /* Only z->mutex is held. */
1193 /* Check whether the write fits in any of the already opened zones. */
1194 pthread_mutex_lock(&f->zbd_info->mutex);
1195 for (i = 0; i < f->zbd_info->num_open_zones; i++) {
1196 zone_idx = f->zbd_info->open_zones[i];
1197 if (zone_idx < f->min_zone || zone_idx >= f->max_zone)
1199 pthread_mutex_unlock(&f->zbd_info->mutex);
1202 z = get_zone(f, zone_idx);
1204 zone_lock(td, f, z);
1205 if (z->wp + min_bs <= zbd_zone_capacity_end(z))
1207 pthread_mutex_lock(&f->zbd_info->mutex);
1209 pthread_mutex_unlock(&f->zbd_info->mutex);
1211 dprint(FD_ZBD, "%s(%s): did not open another zone\n", __func__,
1216 dprint(FD_ZBD, "%s(%s): returning zone %d\n", __func__, f->file_name,
1218 io_u->offset = z->start;
1220 assert(z->cond != ZBD_ZONE_COND_OFFLINE);
1224 /* The caller must hold z->mutex. */
1225 static struct fio_zone_info *zbd_replay_write_order(struct thread_data *td,
1227 struct fio_zone_info *z)
1229 const struct fio_file *f = io_u->file;
1230 const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
1232 if (!zbd_open_zone(td, f, zbd_zone_nr(f, z))) {
1234 z = zbd_convert_to_open_zone(td, io_u);
1238 if (z->verify_block * min_bs >= z->capacity)
1239 log_err("%s: %d * %d >= %llu\n", f->file_name, z->verify_block,
1240 min_bs, (unsigned long long)z->capacity);
1241 io_u->offset = z->start + z->verify_block++ * min_bs;
1246 * Find another zone for which @io_u fits in the readable data in the zone.
1247 * Search in zones @zb + 1 .. @zl. For random workload, also search in zones
1250 * Either returns NULL or returns a zone pointer. When the zone has write
1251 * pointer, hold the mutex for the zone.
1253 static struct fio_zone_info *
1254 zbd_find_zone(struct thread_data *td, struct io_u *io_u,
1255 struct fio_zone_info *zb, struct fio_zone_info *zl)
1257 const uint32_t min_bs = td->o.min_bs[io_u->ddir];
1258 struct fio_file *f = io_u->file;
1259 struct fio_zone_info *z1, *z2;
1260 const struct fio_zone_info *const zf = get_zone(f, f->min_zone);
1263 * Skip to the next non-empty zone in case of sequential I/O and to
1264 * the nearest non-empty zone in case of random I/O.
1266 for (z1 = zb + 1, z2 = zb - 1; z1 < zl || z2 >= zf; z1++, z2--) {
1267 if (z1 < zl && z1->cond != ZBD_ZONE_COND_OFFLINE) {
1269 zone_lock(td, f, z1);
1270 if (z1->start + min_bs <= z1->wp)
1274 } else if (!td_random(td)) {
1277 if (td_random(td) && z2 >= zf &&
1278 z2->cond != ZBD_ZONE_COND_OFFLINE) {
1280 zone_lock(td, f, z2);
1281 if (z2->start + min_bs <= z2->wp)
1287 dprint(FD_ZBD, "%s: adjusting random read offset failed\n",
1293 * zbd_end_zone_io - update zone status at command completion
1295 * @z: zone info pointer
1297 * If the write command made the zone full, close it.
1299 * The caller must hold z->mutex.
1301 static void zbd_end_zone_io(struct thread_data *td, const struct io_u *io_u,
1302 struct fio_zone_info *z)
1304 const struct fio_file *f = io_u->file;
1306 if (io_u->ddir == DDIR_WRITE &&
1307 io_u->offset + io_u->buflen >= zbd_zone_capacity_end(z)) {
1308 pthread_mutex_lock(&f->zbd_info->mutex);
1309 zbd_close_zone(td, f, zbd_zone_nr(f, z));
1310 pthread_mutex_unlock(&f->zbd_info->mutex);
1315 * zbd_queue_io - update the write pointer of a sequential zone
1317 * @success: Whether or not the I/O unit has been queued successfully
1318 * @q: queueing status (busy, completed or queued).
1320 * For write and trim operations, update the write pointer of the I/O unit
1323 static void zbd_queue_io(struct thread_data *td, struct io_u *io_u, int q,
1326 const struct fio_file *f = io_u->file;
1327 struct zoned_block_device_info *zbd_info = f->zbd_info;
1328 struct fio_zone_info *z;
1335 zone_idx = zbd_zone_idx(f, io_u->offset);
1336 assert(zone_idx < zbd_info->nr_zones);
1337 z = get_zone(f, zone_idx);
1345 "%s: queued I/O (%lld, %llu) for zone %u\n",
1346 f->file_name, io_u->offset, io_u->buflen, zone_idx);
1348 switch (io_u->ddir) {
1350 zone_end = min((uint64_t)(io_u->offset + io_u->buflen),
1351 zbd_zone_capacity_end(z));
1352 pthread_mutex_lock(&zbd_info->mutex);
1354 * z->wp > zone_end means that one or more I/O errors
1357 if (z->wp <= zone_end) {
1358 zbd_info->sectors_with_data += zone_end - z->wp;
1359 zbd_info->wp_sectors_with_data += zone_end - z->wp;
1361 pthread_mutex_unlock(&zbd_info->mutex);
1365 assert(z->wp == z->start);
1371 if (q == FIO_Q_COMPLETED && !io_u->error)
1372 zbd_end_zone_io(td, io_u, z);
1375 if (!success || q != FIO_Q_QUEUED) {
1376 /* BUSY or COMPLETED: unlock the zone */
1378 io_u->zbd_put_io = NULL;
1383 * zbd_put_io - Unlock an I/O unit target zone lock
1386 static void zbd_put_io(struct thread_data *td, const struct io_u *io_u)
1388 const struct fio_file *f = io_u->file;
1389 struct zoned_block_device_info *zbd_info = f->zbd_info;
1390 struct fio_zone_info *z;
1396 zone_idx = zbd_zone_idx(f, io_u->offset);
1397 assert(zone_idx < zbd_info->nr_zones);
1398 z = get_zone(f, zone_idx);
1403 "%s: terminate I/O (%lld, %llu) for zone %u\n",
1404 f->file_name, io_u->offset, io_u->buflen, zone_idx);
1406 zbd_end_zone_io(td, io_u, z);
1409 zbd_check_swd(td, f);
1413 * Windows and MacOS do not define this.
1416 #define EREMOTEIO 121 /* POSIX value */
1419 bool zbd_unaligned_write(int error_code)
1421 switch (error_code) {
1430 * setup_zbd_zone_mode - handle zoneskip as necessary for ZBD drives
1431 * @td: FIO thread data.
1432 * @io_u: FIO I/O unit.
1434 * For sequential workloads, change the file offset to skip zoneskip bytes when
1435 * no more IO can be performed in the current zone.
1436 * - For read workloads, zoneskip is applied when the io has reached the end of
1437 * the zone or the zone write position (when td->o.read_beyond_wp is false).
1438 * - For write workloads, zoneskip is applied when the zone is full.
1439 * This applies only to read and write operations.
1441 void setup_zbd_zone_mode(struct thread_data *td, struct io_u *io_u)
1443 struct fio_file *f = io_u->file;
1444 enum fio_ddir ddir = io_u->ddir;
1445 struct fio_zone_info *z;
1448 assert(td->o.zone_mode == ZONE_MODE_ZBD);
1449 assert(td->o.zone_size);
1451 zone_idx = zbd_zone_idx(f, f->last_pos[ddir]);
1452 z = get_zone(f, zone_idx);
1455 * When the zone capacity is smaller than the zone size and the I/O is
1456 * sequential write, skip to zone end if the latest position is at the
1457 * zone capacity limit.
1459 if (z->capacity < f->zbd_info->zone_size && !td_random(td) &&
1460 ddir == DDIR_WRITE &&
1461 f->last_pos[ddir] >= zbd_zone_capacity_end(z)) {
1463 "%s: Jump from zone capacity limit to zone end:"
1464 " (%llu -> %llu) for zone %u (%llu)\n",
1465 f->file_name, (unsigned long long) f->last_pos[ddir],
1466 (unsigned long long) zbd_zone_end(z), zone_idx,
1467 (unsigned long long) z->capacity);
1468 td->io_skip_bytes += zbd_zone_end(z) - f->last_pos[ddir];
1469 f->last_pos[ddir] = zbd_zone_end(z);
1473 * zone_skip is valid only for sequential workloads.
1475 if (td_random(td) || !td->o.zone_skip)
1479 * It is time to switch to a new zone if:
1480 * - zone_bytes == zone_size bytes have already been accessed
1481 * - The last position reached the end of the current zone.
1482 * - For reads with td->o.read_beyond_wp == false, the last position
1483 * reached the zone write pointer.
1485 if (td->zone_bytes >= td->o.zone_size ||
1486 f->last_pos[ddir] >= zbd_zone_end(z) ||
1487 (ddir == DDIR_READ &&
1488 (!td->o.read_beyond_wp) && f->last_pos[ddir] >= z->wp)) {
1493 f->file_offset += td->o.zone_size + td->o.zone_skip;
1496 * Wrap from the beginning, if we exceed the file size
1498 if (f->file_offset >= f->real_file_size)
1499 f->file_offset = get_start_offset(td, f);
1501 f->last_pos[ddir] = f->file_offset;
1502 td->io_skip_bytes += td->o.zone_skip;
1507 * zbd_adjust_ddir - Adjust an I/O direction for zonemode=zbd.
1509 * @td: FIO thread data.
1510 * @io_u: FIO I/O unit.
1511 * @ddir: I/O direction before adjustment.
1513 * Return adjusted I/O direction.
1515 enum fio_ddir zbd_adjust_ddir(struct thread_data *td, struct io_u *io_u,
1519 * In case read direction is chosen for the first random I/O, fio with
1520 * zonemode=zbd stops because no data can be read from zoned block
1521 * devices with all empty zones. Overwrite the first I/O direction as
1522 * write to make sure data to read exists.
1524 if (ddir != DDIR_READ || !td_rw(td))
1527 if (io_u->file->zbd_info->sectors_with_data ||
1528 td->o.read_beyond_wp)
1535 * zbd_adjust_block - adjust the offset and length as necessary for ZBD drives
1536 * @td: FIO thread data.
1537 * @io_u: FIO I/O unit.
1539 * Locking strategy: returns with z->mutex locked if and only if z refers
1540 * to a sequential zone and if io_u_accept is returned. z is the zone that
1541 * corresponds to io_u->offset at the end of this function.
1543 enum io_u_action zbd_adjust_block(struct thread_data *td, struct io_u *io_u)
1545 struct fio_file *f = io_u->file;
1546 uint32_t zone_idx_b;
1547 struct fio_zone_info *zb, *zl, *orig_zb;
1548 uint32_t orig_len = io_u->buflen;
1549 uint32_t min_bs = td->o.min_bs[io_u->ddir];
1557 assert(is_valid_offset(f, io_u->offset));
1558 assert(io_u->buflen);
1559 zone_idx_b = zbd_zone_idx(f, io_u->offset);
1560 zb = get_zone(f, zone_idx_b);
1564 /* Accept non-write I/Os for conventional zones. */
1565 if (io_u->ddir != DDIR_WRITE)
1568 * Make sure that writes to conventional zones
1569 * don't cross over to any sequential zones.
1571 if (!(zb + 1)->has_wp ||
1572 io_u->offset + io_u->buflen <= (zb + 1)->start)
1575 if (io_u->offset + min_bs > (zb + 1)->start) {
1577 "%s: off=%llu + min_bs=%u > next zone %lu\n",
1578 f->file_name, io_u->offset, min_bs,
1580 io_u->offset = zb->start + (zb + 1)->start - io_u->offset;
1581 new_len = min(io_u->buflen, (zb + 1)->start - io_u->offset);
1583 new_len = (zb + 1)->start - io_u->offset;
1585 io_u->buflen = new_len / min_bs * min_bs;
1590 * Accept the I/O offset for reads if reading beyond the write pointer
1593 if (zb->cond != ZBD_ZONE_COND_OFFLINE &&
1594 io_u->ddir == DDIR_READ && td->o.read_beyond_wp)
1597 zbd_check_swd(td, f);
1599 zone_lock(td, f, zb);
1601 switch (io_u->ddir) {
1603 if (td->runstate == TD_VERIFYING && td_write(td)) {
1604 zb = zbd_replay_write_order(td, io_u, zb);
1606 * Since we return with the zone lock still held,
1607 * add an annotation to let Coverity know that it
1610 /* coverity[missing_unlock] */
1614 * Check that there is enough written data in the zone to do an
1615 * I/O of at least min_bs B. If there isn't, find a new zone for
1618 range = zb->cond != ZBD_ZONE_COND_OFFLINE ?
1619 zb->wp - zb->start : 0;
1620 if (range < min_bs ||
1621 ((!td_random(td)) && (io_u->offset + min_bs > zb->wp))) {
1623 zl = get_zone(f, f->max_zone);
1624 zb = zbd_find_zone(td, io_u, zb, zl);
1627 "%s: zbd_find_zone(%lld, %llu) failed\n",
1628 f->file_name, io_u->offset,
1633 * zbd_find_zone() returned a zone with a range of at
1636 range = zb->wp - zb->start;
1637 assert(range >= min_bs);
1640 io_u->offset = zb->start;
1643 * Make sure the I/O is within the zone valid data range while
1644 * maximizing the I/O size and preserving randomness.
1646 if (range <= io_u->buflen)
1647 io_u->offset = zb->start;
1648 else if (td_random(td))
1649 io_u->offset = zb->start +
1650 ((io_u->offset - orig_zb->start) %
1651 (range - io_u->buflen)) / min_bs * min_bs;
1653 * When zbd_find_zone() returns a conventional zone,
1654 * we can simply accept the new i/o offset here.
1659 * Make sure the I/O does not cross over the zone wp position.
1661 new_len = min((unsigned long long)io_u->buflen,
1662 (unsigned long long)(zb->wp - io_u->offset));
1663 new_len = new_len / min_bs * min_bs;
1664 if (new_len < io_u->buflen) {
1665 io_u->buflen = new_len;
1666 dprint(FD_IO, "Changed length from %u into %llu\n",
1667 orig_len, io_u->buflen);
1669 assert(zb->start <= io_u->offset);
1670 assert(io_u->offset + io_u->buflen <= zb->wp);
1673 if (io_u->buflen > f->zbd_info->zone_size)
1675 if (!zbd_open_zone(td, f, zone_idx_b)) {
1677 zb = zbd_convert_to_open_zone(td, io_u);
1680 zone_idx_b = zbd_zone_nr(f, zb);
1682 /* Check whether the zone reset threshold has been exceeded */
1683 if (td->o.zrf.u.f) {
1684 if (f->zbd_info->wp_sectors_with_data >=
1685 f->io_size * td->o.zrt.u.f &&
1686 zbd_dec_and_reset_write_cnt(td, f)) {
1690 /* Reset the zone pointer if necessary */
1691 if (zb->reset_zone || zbd_zone_full(f, zb, min_bs)) {
1692 assert(td->o.verify == VERIFY_NONE);
1694 * Since previous write requests may have been submitted
1695 * asynchronously and since we will submit the zone
1696 * reset synchronously, wait until previously submitted
1697 * write requests have completed before issuing a
1702 if (zbd_reset_zone(td, f, zb) < 0)
1705 if (zb->capacity < min_bs) {
1706 log_err("zone capacity %llu smaller than minimum block size %d\n",
1707 (unsigned long long)zb->capacity,
1712 /* Make writes occur at the write pointer */
1713 assert(!zbd_zone_full(f, zb, min_bs));
1714 io_u->offset = zb->wp;
1715 if (!is_valid_offset(f, io_u->offset)) {
1716 dprint(FD_ZBD, "Dropped request with offset %llu\n",
1721 * Make sure that the buflen is a multiple of the minimal
1722 * block size. Give up if shrinking would make the request too
1725 new_len = min((unsigned long long)io_u->buflen,
1726 zbd_zone_capacity_end(zb) - io_u->offset);
1727 new_len = new_len / min_bs * min_bs;
1728 if (new_len == io_u->buflen)
1730 if (new_len >= min_bs) {
1731 io_u->buflen = new_len;
1732 dprint(FD_IO, "Changed length from %u into %llu\n",
1733 orig_len, io_u->buflen);
1736 log_err("Zone remainder %lld smaller than minimum block size %d\n",
1737 (zbd_zone_capacity_end(zb) - io_u->offset),
1744 case DDIR_SYNC_FILE_RANGE:
1755 assert(zb->cond != ZBD_ZONE_COND_OFFLINE);
1756 assert(!io_u->zbd_queue_io);
1757 assert(!io_u->zbd_put_io);
1758 io_u->zbd_queue_io = zbd_queue_io;
1759 io_u->zbd_put_io = zbd_put_io;
1763 if (zb && zb->has_wp)
1768 /* Return a string with ZBD statistics */
1769 char *zbd_write_status(const struct thread_stat *ts)
1773 if (asprintf(&res, "; %llu zone resets", (unsigned long long) ts->nr_zone_resets) < 0)