zbd_rest_zones() currently scans over device zones and try to reset as much
zones as possible at a time. However, this routine takes all the lock on
the range and causes a lot of lock contentions with other threads.
This commit change the behavior to hold the lock and examine one zone at a
time. While it will increase the number of ioctl() call when it need to
reset contiguous, the overhead of increased number of ioctl()s are anyway
amortized by device side's reset performance.
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Tested-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
struct fio_zone_info *const zb,
struct fio_zone_info *const ze, bool all_zones)
{
struct fio_zone_info *const zb,
struct fio_zone_info *const ze, bool all_zones)
{
- struct fio_zone_info *z, *start_z = ze;
+ struct fio_zone_info *z;
const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
bool reset_wp;
int res = 0;
const uint32_t min_bs = td->o.min_bs[DDIR_WRITE];
bool reset_wp;
int res = 0;
assert(f->fd != -1);
for (z = zb; z < ze; z++) {
pthread_mutex_lock(&z->mutex);
assert(f->fd != -1);
for (z = zb; z < ze; z++) {
pthread_mutex_lock(&z->mutex);
- switch (z->type) {
- case BLK_ZONE_TYPE_SEQWRITE_REQ:
+ if (z->type == BLK_ZONE_TYPE_SEQWRITE_REQ) {
reset_wp = all_zones ? z->wp != z->start :
(td->o.td_ddir & TD_DDIR_WRITE) &&
z->wp % min_bs != 0;
reset_wp = all_zones ? z->wp != z->start :
(td->o.td_ddir & TD_DDIR_WRITE) &&
z->wp % min_bs != 0;
- if (start_z == ze && reset_wp) {
- start_z = z;
- } else if (start_z < ze && !reset_wp) {
- dprint(FD_ZBD,
- "%s: resetting zones %u .. %u\n",
+ if (reset_wp) {
+ dprint(FD_ZBD, "%s: resetting zone %u\n",
- zbd_zone_nr(f->zbd_info, start_z),
- zbd_zone_nr(f->zbd_info, z));
- if (zbd_reset_range(td, f, start_z->start,
- z->start - start_z->start) < 0)
+ zbd_zone_nr(f->zbd_info, z));
+ if (zbd_reset_zone(td, f, z) < 0)
- break;
- default:
- if (start_z == ze)
- break;
- dprint(FD_ZBD, "%s: resetting zones %u .. %u\n",
- f->file_name, zbd_zone_nr(f->zbd_info, start_z),
- zbd_zone_nr(f->zbd_info, z));
- if (zbd_reset_range(td, f, start_z->start,
- z->start - start_z->start) < 0)
- res = 1;
- start_z = ze;
- break;
- }
- if (start_z < ze) {
- dprint(FD_ZBD, "%s: resetting zones %u .. %u\n", f->file_name,
- zbd_zone_nr(f->zbd_info, start_z),
- zbd_zone_nr(f->zbd_info, z));
- if (zbd_reset_range(td, f, start_z->start,
- z->start - start_z->start) < 0)
- res = 1;
- }
- for (z = zb; z < ze; z++)
pthread_mutex_unlock(&z->mutex);
pthread_mutex_unlock(&z->mutex);