}
/**
- * zbd_close_zone - Remove a zone from the open zones array.
+ * zbd_write_zone_put - Remove a zone from the write target zones array.
* @td: FIO thread data.
- * @f: FIO file associated with the disk for which to reset a write pointer.
+ * @f: FIO file that has the write zones array to remove.
* @zone_idx: Index of the zone to remove.
*
* The caller must hold f->zbd_info->mutex.
*/
-static void zbd_close_zone(struct thread_data *td, const struct fio_file *f,
- struct fio_zone_info *z)
+static void zbd_write_zone_put(struct thread_data *td, const struct fio_file *f,
+ struct fio_zone_info *z)
{
- uint32_t ozi;
+ uint32_t zi;
- if (!z->open)
+ if (!z->write)
return;
- for (ozi = 0; ozi < f->zbd_info->num_open_zones; ozi++) {
- if (zbd_get_zone(f, f->zbd_info->open_zones[ozi]) == z)
+ for (zi = 0; zi < f->zbd_info->num_write_zones; zi++) {
+ if (zbd_get_zone(f, f->zbd_info->write_zones[zi]) == z)
break;
}
- if (ozi == f->zbd_info->num_open_zones)
+ if (zi == f->zbd_info->num_write_zones)
return;
- dprint(FD_ZBD, "%s: closing zone %u\n",
+ dprint(FD_ZBD, "%s: removing zone %u from write zone array\n",
f->file_name, zbd_zone_idx(f, z));
- memmove(f->zbd_info->open_zones + ozi,
- f->zbd_info->open_zones + ozi + 1,
- (ZBD_MAX_OPEN_ZONES - (ozi + 1)) *
- sizeof(f->zbd_info->open_zones[0]));
+ memmove(f->zbd_info->write_zones + zi,
+ f->zbd_info->write_zones + zi + 1,
+ (ZBD_MAX_WRITE_ZONES - (zi + 1)) *
+ sizeof(f->zbd_info->write_zones[0]));
- f->zbd_info->num_open_zones--;
- td->num_open_zones--;
- z->open = 0;
+ f->zbd_info->num_write_zones--;
+ td->num_write_zones--;
+ z->write = 0;
}
/**
zone_lock(td, f, z);
pthread_mutex_lock(&f->zbd_info->mutex);
- zbd_close_zone(td, f, z);
+ zbd_write_zone_put(td, f, z);
pthread_mutex_unlock(&f->zbd_info->mutex);
if (z->wp != z->start) {
}
/**
- * zbd_open_zone - Add a zone to the array of open zones.
+ * zbd_write_zone_get - Add a zone to the array of write zones.
* @td: fio thread data.
- * @f: fio file that has the open zones to add.
+ * @f: fio file that has the write zones array to add.
* @zone_idx: Index of the zone to add.
*
- * Open a ZBD zone if it is not already open. Returns true if either the zone
- * was already open or if the zone was successfully added to the array of open
- * zones without exceeding the maximum number of open zones. Returns false if
- * the zone was not already open and opening the zone would cause the zone limit
- * to be exceeded.
+ * Add a ZBD zone to write target zones array, if it is not yet added. Returns
+ * true if either the zone was already added or if the zone was successfully
+ * added to the array without exceeding the maximum number of write zones.
+ * Returns false if the zone was not already added and addition of the zone
+ * would cause the zone limit to be exceeded.
*/
-static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
- struct fio_zone_info *z)
+static bool zbd_write_zone_get(struct thread_data *td, const struct fio_file *f,
+ struct fio_zone_info *z)
{
const uint64_t min_bs = td->o.min_bs[DDIR_WRITE];
struct zoned_block_device_info *zbdi = f->zbd_info;
return false;
/*
- * zbdi->max_open_zones == 0 means that there is no limit on the maximum
- * number of open zones. In this case, do no track open zones in
- * zbdi->open_zones array.
+ * zbdi->max_write_zones == 0 means that there is no limit on the
+ * maximum number of write target zones. In this case, do no track write
+ * target zones in zbdi->write_zones array.
*/
- if (!zbdi->max_open_zones)
+ if (!zbdi->max_write_zones)
return true;
pthread_mutex_lock(&zbdi->mutex);
- if (z->open) {
+ if (z->write) {
/*
* If the zone is going to be completely filled by writes
- * already in-flight, handle it as a full zone instead of an
- * open zone.
+ * already in-flight, handle it as a full zone instead of a
+ * write target zone.
*/
if (!zbd_zone_remainder(z))
res = false;
res = false;
/* Zero means no limit */
if (td->o.job_max_open_zones > 0 &&
- td->num_open_zones >= td->o.job_max_open_zones)
+ td->num_write_zones >= td->o.job_max_open_zones)
goto out;
- if (zbdi->num_open_zones >= zbdi->max_open_zones)
+ if (zbdi->num_write_zones >= zbdi->max_write_zones)
goto out;
- dprint(FD_ZBD, "%s: opening zone %u\n",
+ dprint(FD_ZBD, "%s: adding zone %u to write zone array\n",
f->file_name, zone_idx);
- zbdi->open_zones[zbdi->num_open_zones++] = zone_idx;
- td->num_open_zones++;
- z->open = 1;
+ zbdi->write_zones[zbdi->num_write_zones++] = zone_idx;
+ td->num_write_zones++;
+ z->write = 1;
res = true;
out:
return ret;
}
-static int zbd_set_max_open_zones(struct thread_data *td, struct fio_file *f)
+static int zbd_set_max_write_zones(struct thread_data *td, struct fio_file *f)
{
struct zoned_block_device_info *zbd = f->zbd_info;
unsigned int max_open_zones;
if (zbd->model != ZBD_HOST_MANAGED || td->o.ignore_zone_limits) {
/* Only host-managed devices have a max open limit */
- zbd->max_open_zones = td->o.max_open_zones;
+ zbd->max_write_zones = td->o.max_open_zones;
goto out;
}
if (!max_open_zones) {
/* No device limit */
- zbd->max_open_zones = td->o.max_open_zones;
+ zbd->max_write_zones = td->o.max_open_zones;
} else if (!td->o.max_open_zones) {
/* No user limit. Set limit to device limit */
- zbd->max_open_zones = max_open_zones;
+ zbd->max_write_zones = max_open_zones;
} else if (td->o.max_open_zones <= max_open_zones) {
/* Both user limit and dev limit. User limit not too large */
- zbd->max_open_zones = td->o.max_open_zones;
+ zbd->max_write_zones = td->o.max_open_zones;
} else {
/* Both user limit and dev limit. User limit too large */
td_verror(td, EINVAL,
out:
/* Ensure that the limit is not larger than FIO's internal limit */
- if (zbd->max_open_zones > ZBD_MAX_OPEN_ZONES) {
+ if (zbd->max_write_zones > ZBD_MAX_WRITE_ZONES) {
td_verror(td, EINVAL, "'max_open_zones' value is too large");
log_err("'max_open_zones' value is larger than %u\n",
- ZBD_MAX_OPEN_ZONES);
+ ZBD_MAX_WRITE_ZONES);
return -EINVAL;
}
- dprint(FD_ZBD, "%s: using max open zones limit: %"PRIu32"\n",
- f->file_name, zbd->max_open_zones);
+ dprint(FD_ZBD, "%s: using max write zones limit: %"PRIu32"\n",
+ f->file_name, zbd->max_write_zones);
return 0;
}
assert(f->zbd_info);
f->zbd_info->model = zbd_model;
- ret = zbd_set_max_open_zones(td, f);
+ ret = zbd_set_max_write_zones(td, f);
if (ret) {
zbd_free_zone_info(f);
return ret;
assert(f->min_zone < f->max_zone);
if (td->o.max_open_zones > 0 &&
- zbd->max_open_zones != td->o.max_open_zones) {
+ zbd->max_write_zones != td->o.max_open_zones) {
log_err("Different 'max_open_zones' values\n");
return 1;
}
* global max open zones limit. (As the tracking of open zones
* is disabled when there is no global max open zones limit.)
*/
- if (td->o.job_max_open_zones && !zbd->max_open_zones) {
+ if (td->o.job_max_open_zones && !zbd->max_write_zones) {
log_err("'job_max_open_zones' cannot be used without a global open zones limit\n");
return 1;
}
/*
- * zbd->max_open_zones is the global limit shared for all jobs
+ * zbd->max_write_zones is the global limit shared for all jobs
* that target the same zoned block device. Force sync the per
* thread global limit with the actual global limit. (The real
* per thread/job limit is stored in td->o.job_max_open_zones).
*/
- td->o.max_open_zones = zbd->max_open_zones;
+ td->o.max_open_zones = zbd->max_write_zones;
for (zi = f->min_zone; zi < f->max_zone; zi++) {
z = &zbd->zone_info[zi];
if (z->cond != ZBD_ZONE_COND_IMP_OPEN &&
z->cond != ZBD_ZONE_COND_EXP_OPEN)
continue;
- if (zbd_open_zone(td, f, z))
+ if (zbd_write_zone_get(td, f, z))
continue;
/*
* If the number of open zones exceeds specified limits,
zbd_reset_write_cnt(td, f);
}
-/* Return random zone index for one of the open zones. */
+/* Return random zone index for one of the write target zones. */
static uint32_t pick_random_zone_idx(const struct fio_file *f,
const struct io_u *io_u)
{
return (io_u->offset - f->file_offset) *
- f->zbd_info->num_open_zones / f->io_size;
+ f->zbd_info->num_write_zones / f->io_size;
}
static bool any_io_in_flight(void)
}
/*
- * Modify the offset of an I/O unit that does not refer to an open zone such
- * that it refers to an open zone. Close an open zone and open a new zone if
- * necessary. The open zone is searched across sequential zones.
+ * Modify the offset of an I/O unit that does not refer to a zone such that
+ * in write target zones array. Add a zone to or remove a zone from the lsit if
+ * necessary. The write target zone is searched across sequential zones.
* This algorithm can only work correctly if all write pointers are
* a multiple of the fio block size. The caller must neither hold z->mutex
* nor f->zbd_info->mutex. Returns with z->mutex held upon success.
*/
-static struct fio_zone_info *zbd_convert_to_open_zone(struct thread_data *td,
- struct io_u *io_u)
+static struct fio_zone_info *zbd_convert_to_write_zone(struct thread_data *td,
+ struct io_u *io_u)
{
const uint64_t min_bs = td->o.min_bs[io_u->ddir];
struct fio_file *f = io_u->file;
struct zoned_block_device_info *zbdi = f->zbd_info;
struct fio_zone_info *z;
- unsigned int open_zone_idx = -1;
+ unsigned int write_zone_idx = -1;
uint32_t zone_idx, new_zone_idx;
int i;
- bool wait_zone_close;
+ bool wait_zone_write;
bool in_flight;
bool should_retry = true;
assert(is_valid_offset(f, io_u->offset));
- if (zbdi->max_open_zones || td->o.job_max_open_zones) {
+ if (zbdi->max_write_zones || td->o.job_max_open_zones) {
/*
- * This statement accesses zbdi->open_zones[] on purpose
+ * This statement accesses zbdi->write_zones[] on purpose
* without locking.
*/
- zone_idx = zbdi->open_zones[pick_random_zone_idx(f, io_u)];
+ zone_idx = zbdi->write_zones[pick_random_zone_idx(f, io_u)];
} else {
zone_idx = zbd_offset_to_zone_idx(f, io_u->offset);
}
if (z->has_wp) {
if (z->cond != ZBD_ZONE_COND_OFFLINE &&
- zbdi->max_open_zones == 0 &&
+ zbdi->max_write_zones == 0 &&
td->o.job_max_open_zones == 0)
goto examine_zone;
- if (zbdi->num_open_zones == 0) {
- dprint(FD_ZBD, "%s(%s): no zones are open\n",
+ if (zbdi->num_write_zones == 0) {
+ dprint(FD_ZBD, "%s(%s): no zone is write target\n",
__func__, f->file_name);
- goto open_other_zone;
+ goto choose_other_zone;
}
}
/*
- * List of opened zones is per-device, shared across all
+ * Array of write target zones is per-device, shared across all
* threads. Start with quasi-random candidate zone. Ignore
* zones which don't belong to thread's offset/size area.
*/
- open_zone_idx = pick_random_zone_idx(f, io_u);
- assert(!open_zone_idx ||
- open_zone_idx < zbdi->num_open_zones);
- tmp_idx = open_zone_idx;
+ write_zone_idx = pick_random_zone_idx(f, io_u);
+ assert(!write_zone_idx ||
+ write_zone_idx < zbdi->num_write_zones);
+ tmp_idx = write_zone_idx;
- for (i = 0; i < zbdi->num_open_zones; i++) {
+ for (i = 0; i < zbdi->num_write_zones; i++) {
uint32_t tmpz;
- if (tmp_idx >= zbdi->num_open_zones)
+ if (tmp_idx >= zbdi->num_write_zones)
tmp_idx = 0;
- tmpz = zbdi->open_zones[tmp_idx];
+ tmpz = zbdi->write_zones[tmp_idx];
if (f->min_zone <= tmpz && tmpz < f->max_zone) {
- open_zone_idx = tmp_idx;
+ write_zone_idx = tmp_idx;
goto found_candidate_zone;
}
return NULL;
found_candidate_zone:
- new_zone_idx = zbdi->open_zones[open_zone_idx];
+ new_zone_idx = zbdi->write_zones[write_zone_idx];
if (new_zone_idx == zone_idx)
break;
zone_idx = new_zone_idx;
goto out;
}
-open_other_zone:
- /* Check if number of open zones reaches one of limits. */
- wait_zone_close =
- zbdi->num_open_zones == f->max_zone - f->min_zone ||
- (zbdi->max_open_zones &&
- zbdi->num_open_zones == zbdi->max_open_zones) ||
+choose_other_zone:
+ /* Check if number of write target zones reaches one of limits. */
+ wait_zone_write =
+ zbdi->num_write_zones == f->max_zone - f->min_zone ||
+ (zbdi->max_write_zones &&
+ zbdi->num_write_zones == zbdi->max_write_zones) ||
(td->o.job_max_open_zones &&
- td->num_open_zones == td->o.job_max_open_zones);
+ td->num_write_zones == td->o.job_max_open_zones);
pthread_mutex_unlock(&zbdi->mutex);
/* Only z->mutex is held. */
/*
- * When number of open zones reaches to one of limits, wait for
- * zone close before opening a new zone.
+ * When number of write target zones reaches to one of limits, wait for
+ * zone write completion to one of them before trying a new zone.
*/
- if (wait_zone_close) {
+ if (wait_zone_write) {
dprint(FD_ZBD,
- "%s(%s): quiesce to allow open zones to close\n",
+ "%s(%s): quiesce to remove a zone from write target zones array\n",
__func__, f->file_name);
io_u_quiesce(td);
}
retry:
- /* Zone 'z' is full, so try to open a new zone. */
+ /* Zone 'z' is full, so try to choose a new zone. */
for (i = f->io_size / zbdi->zone_size; i > 0; i--) {
zone_idx++;
if (z->has_wp)
if (!z->has_wp)
continue;
zone_lock(td, f, z);
- if (z->open)
+ if (z->write)
continue;
- if (zbd_open_zone(td, f, z))
+ if (zbd_write_zone_get(td, f, z))
goto out;
}
/* Only z->mutex is held. */
- /* Check whether the write fits in any of the already opened zones. */
+ /* Check whether the write fits in any of the write target zones. */
pthread_mutex_lock(&zbdi->mutex);
- for (i = 0; i < zbdi->num_open_zones; i++) {
- zone_idx = zbdi->open_zones[i];
+ for (i = 0; i < zbdi->num_write_zones; i++) {
+ zone_idx = zbdi->write_zones[i];
if (zone_idx < f->min_zone || zone_idx >= f->max_zone)
continue;
pthread_mutex_unlock(&zbdi->mutex);
/*
* When any I/O is in-flight or when all I/Os in-flight get completed,
- * the I/Os might have closed zones then retry the steps to open a zone.
- * Before retry, call io_u_quiesce() to complete in-flight writes.
+ * the I/Os might have removed zones from the write target array then
+ * retry the steps to choose a zone. Before retry, call io_u_quiesce()
+ * to complete in-flight writes.
*/
in_flight = any_io_in_flight();
if (in_flight || should_retry) {
dprint(FD_ZBD,
- "%s(%s): wait zone close and retry open zones\n",
+ "%s(%s): wait zone write and retry write target zone selection\n",
__func__, f->file_name);
pthread_mutex_unlock(&zbdi->mutex);
zone_unlock(z);
zone_unlock(z);
- dprint(FD_ZBD, "%s(%s): did not open another zone\n",
+ dprint(FD_ZBD, "%s(%s): did not choose another write zone\n",
__func__, f->file_name);
return NULL;
* @io_u: I/O unit
* @z: zone info pointer
*
- * If the write command made the zone full, close it.
+ * If the write command made the zone full, remove it from the write target
+ * zones array.
*
* The caller must hold z->mutex.
*/
if (io_u->ddir == DDIR_WRITE &&
io_u->offset + io_u->buflen >= zbd_zone_capacity_end(z)) {
pthread_mutex_lock(&f->zbd_info->mutex);
- zbd_close_zone(td, f, z);
+ zbd_write_zone_put(td, f, z);
pthread_mutex_unlock(&f->zbd_info->mutex);
}
}
if (zbd_zone_remainder(zb) > 0 &&
zbd_zone_remainder(zb) < min_bs) {
pthread_mutex_lock(&f->zbd_info->mutex);
- zbd_close_zone(td, f, zb);
+ zbd_write_zone_put(td, f, zb);
pthread_mutex_unlock(&f->zbd_info->mutex);
dprint(FD_ZBD,
"%s: finish zone %d\n",
zone_lock(td, f, zb);
}
- if (!zbd_open_zone(td, f, zb)) {
+ if (!zbd_write_zone_get(td, f, zb)) {
zone_unlock(zb);
- zb = zbd_convert_to_open_zone(td, io_u);
+ zb = zbd_convert_to_write_zone(td, io_u);
if (!zb) {
- dprint(FD_IO, "%s: can't convert to open zone",
+ dprint(FD_IO, "%s: can't convert to write target zone",
f->file_name);
goto eof;
}