zbd: allow an unlimited global max open zones limit
authorNiklas Cassel <niklas.cassel@wdc.com>
Thu, 24 Jun 2021 17:23:07 +0000 (17:23 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 29 Jun 2021 13:43:29 +0000 (07:43 -0600)
Commit 219c662d3b12 ("zbd: introduce per job maximum open zones limit")
Introduced a global max open zones limit stored in zbd_info->max_open_zones.

This commit also removed the following check from zbd_open_zone():

if (!td->o.max_open_zones)
        return true;

Before the commit in question, if td->o.max_open_zones == 0, zbd_open_zone()
would not track the zone as open in the zbd_info->open_zones array.

After the commit in question, zbd_open_zone() would always track the zone
as open in the zbd_info->open_zones array, regardless if a --max_open_zones
limit was set or not.

Change the initialization of zbd_info->max_open_zones to yet again allow
unlimited max open zones. If zbd_info->max_open_zones is unlimited,
we do not track the open zones in the zbd_info->open zone array.

Not tracking open zones reduces fio overhead for testing the performance of
zoned block devices that do not have a limit on the maximum number of open
zones.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
zbd.c
zbd.h

diff --git a/zbd.c b/zbd.c
index f09b0ee6ce3883c1566a10f91319620dba05eac9..f19e3d473e390f541dfd95a988f499539f5f9539 100644 (file)
--- a/zbd.c
+++ b/zbd.c
@@ -636,8 +636,12 @@ static int zbd_set_max_open_zones(struct thread_data *td, struct fio_file *f)
 
 out:
        /* Ensure that the limit is not larger than FIO's internal limit */
-       zbd->max_open_zones = min_not_zero(zbd->max_open_zones,
-                                          (uint32_t) ZBD_MAX_OPEN_ZONES);
+       if (zbd->max_open_zones > ZBD_MAX_OPEN_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);
+               return -EINVAL;
+       }
+
        dprint(FD_ZBD, "%s: using max open zones limit: %"PRIu32"\n",
               f->file_name, zbd->max_open_zones);
 
@@ -827,8 +831,14 @@ int zbd_setup_files(struct thread_data *td)
                        log_err("Different 'max_open_zones' values\n");
                        return 1;
                }
-               if (zbd->max_open_zones > ZBD_MAX_OPEN_ZONES) {
-                       log_err("'max_open_zones' value is limited by %u\n", ZBD_MAX_OPEN_ZONES);
+
+               /*
+                * The per job max open zones limit cannot be used without a
+                * 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) {
+                       log_err("'job_max_open_zones' cannot be used without a global open zones limit\n");
                        return 1;
                }
 
@@ -1093,6 +1103,8 @@ static bool is_zone_open(const struct thread_data *td, const struct fio_file *f,
        struct zoned_block_device_info *zbdi = f->zbd_info;
        int i;
 
+       /* This function should never be called when zbdi->max_open_zones == 0 */
+       assert(zbdi->max_open_zones);
        assert(td->o.job_max_open_zones == 0 || td->num_open_zones <= td->o.job_max_open_zones);
        assert(td->o.job_max_open_zones <= zbdi->max_open_zones);
        assert(zbdi->num_open_zones <= zbdi->max_open_zones);
@@ -1128,6 +1140,14 @@ static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
        if (td->o.verify != VERIFY_NONE && zbd_zone_full(f, z, min_bs))
                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.
+        */
+       if (!zbdi->max_open_zones)
+               return true;
+
        pthread_mutex_lock(&zbdi->mutex);
        if (is_zone_open(td, f, zone_idx)) {
                /*
diff --git a/zbd.h b/zbd.h
index 6453439313f8de4d5c049c371237762f05d8b7d6..39dc45e3882a94edf7b085d69de7a1ea70c6a4c5 100644 (file)
--- a/zbd.h
+++ b/zbd.h
@@ -50,7 +50,8 @@ struct fio_zone_info {
  * zoned_block_device_info - zoned block device characteristics
  * @model: Device model.
  * @max_open_zones: global limit on the number of simultaneously opened
- *     sequential write zones.
+ *     sequential write zones. A zero value means unlimited open zones,
+ *     and that open zones will not be tracked in the open_zones array.
  * @mutex: Protects the modifiable members in this structure (refcount and
  *             num_open_zones).
  * @zone_size: size of a single zone in bytes.