summaryrefslogtreecommitdiff
path: root/zbd.c
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>2021-12-14 10:24:08 +0900
committerJens Axboe <axboe@kernel.dk>2021-12-14 06:48:14 -0700
commita23411bb2e1c7de1e97c505ca2ec7270a35f7be1 (patch)
treea8697f4ce286715201a12a7929e7302d6c9c0bab /zbd.c
parent139d8dc666e5e4a05eaa9f5e603fc3453c5fe43f (diff)
downloadfio-a23411bb2e1c7de1e97c505ca2ec7270a35f7be1.tar.gz
fio-a23411bb2e1c7de1e97c505ca2ec7270a35f7be1.tar.bz2
zbd: simplify zbd_close_zone()
Change the interface of zbd_close_zone() to directly use a pointer to a zone information structure as all callers already have this information. Also do nothing for zones that are not marked as open instead of figuring out this fact by searching the array of open zones. No functional changes. Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com> Link: https://lore.kernel.org/r/20211214012413.464798-8-damien.lemoal@opensource.wdc.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'zbd.c')
-rw-r--r--zbd.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/zbd.c b/zbd.c
index b87fefc4..26387335 100644
--- a/zbd.c
+++ b/zbd.c
@@ -288,28 +288,31 @@ static int zbd_reset_zone(struct thread_data *td, struct fio_file *f,
* The caller must hold f->zbd_info->mutex.
*/
static void zbd_close_zone(struct thread_data *td, const struct fio_file *f,
- unsigned int zone_idx)
+ struct fio_zone_info *z)
{
- uint32_t open_zone_idx = 0;
+ uint32_t ozi;
- for (; open_zone_idx < f->zbd_info->num_open_zones; open_zone_idx++) {
- if (f->zbd_info->open_zones[open_zone_idx] == zone_idx)
+ if (!z->open)
+ return;
+
+ for (ozi = 0; ozi < f->zbd_info->num_open_zones; ozi++) {
+ if (get_zone(f, f->zbd_info->open_zones[ozi]) == z)
break;
}
- if (open_zone_idx == f->zbd_info->num_open_zones)
+ if (ozi == f->zbd_info->num_open_zones)
return;
- dprint(FD_ZBD, "%s: closing zone %d\n",
- f->file_name, zone_idx);
+ dprint(FD_ZBD, "%s: closing zone %u\n",
+ f->file_name, zbd_zone_nr(f, z));
- memmove(f->zbd_info->open_zones + open_zone_idx,
- f->zbd_info->open_zones + open_zone_idx + 1,
- (ZBD_MAX_OPEN_ZONES - (open_zone_idx + 1)) *
+ 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]));
f->zbd_info->num_open_zones--;
td->num_open_zones--;
- get_zone(f, zone_idx)->open = 0;
+ z->open = 0;
}
/**
@@ -335,14 +338,12 @@ static int zbd_reset_zones(struct thread_data *td, struct fio_file *f,
f->file_name, zbd_zone_nr(f, zb), zbd_zone_nr(f, ze));
for (z = zb; z < ze; z++) {
- uint32_t nz = zbd_zone_nr(f, z);
-
if (!z->has_wp)
continue;
zone_lock(td, f, z);
pthread_mutex_lock(&f->zbd_info->mutex);
- zbd_close_zone(td, f, nz);
+ zbd_close_zone(td, f, z);
pthread_mutex_unlock(&f->zbd_info->mutex);
if (z->wp != z->start) {
@@ -1571,7 +1572,7 @@ static void zbd_end_zone_io(struct thread_data *td, const struct io_u *io_u,
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, zbd_zone_nr(f, z));
+ zbd_close_zone(td, f, z);
pthread_mutex_unlock(&f->zbd_info->mutex);
}
}