return ret;
}
+static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
+ uint32_t zone_idx);
+static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
+ struct fio_zone_info *z);
+
int zbd_setup_files(struct thread_data *td)
{
struct fio_file *f;
for_each_file(td, f, i) {
struct zoned_block_device_info *zbd = f->zbd_info;
+ struct fio_zone_info *z;
+ int zi;
if (!zbd)
continue;
log_err("'max_open_zones' value is limited by %u\n", ZBD_MAX_OPEN_ZONES);
return 1;
}
+
+ 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, zi))
+ continue;
+ /*
+ * If the number of open zones exceeds specified limits,
+ * reset all extra open zones.
+ */
+ if (zbd_reset_zone(td, f, z) < 0) {
+ log_err("Failed to reest zone %d\n", zi);
+ return 1;
+ }
+ }
}
return 0;
uint64_t length = (z+1)->start - offset;
int ret = 0;
+ if (z->wp == z->start)
+ return 0;
+
assert(is_valid_offset(f, offset + length - 1));
dprint(FD_ZBD, "%s: resetting wp of zone %u.\n", f->file_name,
* was not yet open and opening a new zone would cause the zone limit to be
* exceeded.
*/
-static bool zbd_open_zone(struct thread_data *td, const struct io_u *io_u,
+static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
uint32_t zone_idx)
{
const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
- const struct fio_file *f = io_u->file;
struct fio_zone_info *z = &f->zbd_info->zone_info[zone_idx];
bool res = true;
zone_lock(td, f, z);
if (z->open)
continue;
- if (zbd_open_zone(td, io_u, zone_idx))
+ if (zbd_open_zone(td, f, zone_idx))
goto out;
}
const struct fio_file *f = io_u->file;
const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
- if (!zbd_open_zone(td, io_u, z - f->zbd_info->zone_info)) {
+ if (!zbd_open_zone(td, f, z - f->zbd_info->zone_info)) {
pthread_mutex_unlock(&z->mutex);
z = zbd_convert_to_open_zone(td, io_u);
assert(z);
case DDIR_READ:
if (td->runstate == TD_VERIFYING && td_write(td)) {
zb = zbd_replay_write_order(td, io_u, zb);
+ pthread_mutex_unlock(&zb->mutex);
goto accept;
}
/*
case DDIR_WRITE:
if (io_u->buflen > f->zbd_info->zone_size)
goto eof;
- if (!zbd_open_zone(td, io_u, zone_idx_b)) {
+ if (!zbd_open_zone(td, f, zone_idx_b)) {
pthread_mutex_unlock(&zb->mutex);
zb = zbd_convert_to_open_zone(td, io_u);
if (!zb)