X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=zbd.c;h=8cf8f81213ebfcd8083a2f3602932deec9c276cc;hb=refs%2Fheads%2Fmaster;hp=d45652157c021f17d043872d2265ad829b6152cd;hpb=2091760e59615146d7cce41afc8d38e6d74eda97;p=fio.git diff --git a/zbd.c b/zbd.c index d4565215..8a092cbe 100644 --- a/zbd.c +++ b/zbd.c @@ -104,8 +104,7 @@ static void zone_lock(struct thread_data *td, const struct fio_file *f, struct fio_zone_info *z) { #ifndef NDEBUG - struct zoned_block_device_info *zbd = f->zbd_info; - uint32_t const nz = z - zbd->zone_info; + unsigned int const nz = zbd_zone_idx(f, z); /* A thread should never lock zones outside its working area. */ assert(f->min_zone <= nz && nz < f->max_zone); assert(z->has_wp); @@ -471,6 +470,34 @@ static int zbd_get_max_open_zones(struct thread_data *td, struct fio_file *f, return ret; } +/** + * zbd_get_max_active_zones - Get the maximum number of active zones + * @td: FIO thread data + * @f: FIO file for which to get max active zones + * + * Returns max_active_zones limit value of the target file if it is available. + * Otherwise return zero, which means no limit. + */ +static unsigned int zbd_get_max_active_zones(struct thread_data *td, + struct fio_file *f) +{ + unsigned int max_active_zones; + int ret; + + if (td->io_ops && td->io_ops->get_max_active_zones) + ret = td->io_ops->get_max_active_zones(td, f, + &max_active_zones); + else + ret = blkzoned_get_max_active_zones(td, f, &max_active_zones); + if (ret < 0) { + dprint(FD_ZBD, "%s: max_active_zones is not available\n", + f->file_name); + return 0; + } + + return max_active_zones; +} + /** * __zbd_write_zone_get - Add a zone to the array of write zones. * @td: fio thread data. @@ -646,9 +673,20 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td, return false; } + if (td->o.td_ddir == TD_DDIR_READ) { + z = zbd_offset_to_zone(f, f->file_offset + f->io_size); + new_end = z->start; + if (f->file_offset + f->io_size > new_end) { + log_info("%s: rounded io_size from %"PRIu64" to %"PRIu64"\n", + f->file_name, f->io_size, + new_end - f->file_offset); + f->io_size = new_end - f->file_offset; + } + return true; + } + z = zbd_offset_to_zone(f, f->file_offset); - if ((f->file_offset != z->start) && - (td->o.td_ddir != TD_DDIR_READ)) { + if (f->file_offset != z->start) { new_offset = zbd_zone_end(z); if (new_offset >= f->file_offset + f->io_size) { log_info("%s: io_size must be at least one zone\n", @@ -664,8 +702,7 @@ static bool zbd_zone_align_file_sizes(struct thread_data *td, z = zbd_offset_to_zone(f, f->file_offset + f->io_size); new_end = z->start; - if ((td->o.td_ddir != TD_DDIR_READ) && - (f->file_offset + f->io_size != new_end)) { + if (f->file_offset + f->io_size != new_end) { if (new_end <= f->file_offset) { log_info("%s: io_size must be at least one zone\n", f->file_name); @@ -927,6 +964,7 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f) f->zbd_info->zone_size_log2 = is_power_of_2(zone_size) ? ilog2(zone_size) : 0; f->zbd_info->nr_zones = nr_zones; + f->zbd_info->max_active_zones = zbd_get_max_active_zones(td, f); if (same_zone_cap) dprint(FD_ZBD, "Zone capacity = %"PRIu64" KB\n", @@ -1247,7 +1285,11 @@ int zbd_setup_files(struct thread_data *td) 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) + z->cond != ZBD_ZONE_COND_EXP_OPEN && + z->cond != ZBD_ZONE_COND_CLOSED) + continue; + if (!zbd->max_active_zones && + z->cond == ZBD_ZONE_COND_CLOSED) continue; if (__zbd_write_zone_get(td, f, z)) continue; @@ -1319,9 +1361,6 @@ void zbd_file_reset(struct thread_data *td, struct fio_file *f) if (td->o.verify != VERIFY_NONE) { verify_data_left = td->runstate == TD_VERIFYING || td->io_hist_len || td->verify_batch; - if (td->io_hist_len && td->o.verify_backlog) - verify_data_left = - td->io_hist_len % td->o.verify_backlog; if (!verify_data_left) zbd_reset_zones(td, f, zb, ze); } @@ -1843,7 +1882,8 @@ enum fio_ddir zbd_adjust_ddir(struct thread_data *td, struct io_u *io_u, if (ddir != DDIR_READ || !td_rw(td)) return ddir; - if (io_u->file->last_start[DDIR_WRITE] != -1ULL || td->o.read_beyond_wp) + if (io_u->file->last_start[DDIR_WRITE] != -1ULL || + td->o.read_beyond_wp || td->o.rwmix[DDIR_WRITE] == 0) return DDIR_READ; return DDIR_WRITE; @@ -2138,6 +2178,7 @@ retry: case DDIR_WAIT: case DDIR_LAST: case DDIR_INVAL: + case DDIR_TIMEOUT: goto accept; } @@ -2210,3 +2251,15 @@ int zbd_do_io_u_trim(struct thread_data *td, struct io_u *io_u) return io_u_completed; } + +void zbd_log_err(const struct thread_data *td, const struct io_u *io_u) +{ + const struct fio_file *f = io_u->file; + + if (td->o.zone_mode != ZONE_MODE_ZBD) + return; + + if (io_u->error == EOVERFLOW) + log_err("%s: Exceeded max_active_zones limit. Check conditions of zones out of I/O ranges.\n", + f->file_name); +}