All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: fio@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: Niklas Cassel <niklas.cassel@wdc.com>,
	Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [PATCH v2 04/12] zbd: remove is_zone_open() helper
Date: Tue, 14 Dec 2021 10:24:05 +0900	[thread overview]
Message-ID: <20211214012413.464798-5-damien.lemoal@opensource.wdc.com> (raw)
In-Reply-To: <20211214012413.464798-1-damien.lemoal@opensource.wdc.com>

The helper function is_zone_open() is useless as a each zone has an open
flag indicating if it is part of the array of open zones. Remove this
function code and use the zone open flag in zbd_open_zone().

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 zbd.c | 38 +++++---------------------------------
 1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/zbd.c b/zbd.c
index 20d53b15..70afdd82 100644
--- a/zbd.c
+++ b/zbd.c
@@ -377,36 +377,6 @@ static int zbd_get_max_open_zones(struct thread_data *td, struct fio_file *f,
 	return ret;
 }
 
-/**
- * is_zone_open - Test if a zone is already in the array of open zones.
- * @td: fio thread data.
- * @f: fio file for which to test zones.
- * @zone_idx: Index of the zone to check.
- *
- * The caller must hold f->zbd_info->mutex.
- */
-static bool is_zone_open(const struct thread_data *td, const struct fio_file *f,
-			 unsigned int zone_idx)
-{
-	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);
-
-	for (i = 0; i < zbdi->num_open_zones; i++)
-		if (zbdi->open_zones[i] == zone_idx)
-			return true;
-
-	return false;
-}
-
 /**
  * zbd_open_zone - Add a zone to the array of open zones.
  * @td: fio thread data.
@@ -446,10 +416,12 @@ static bool zbd_open_zone(struct thread_data *td, const struct fio_file *f,
 		return true;
 
 	pthread_mutex_lock(&zbdi->mutex);
-	if (is_zone_open(td, f, zone_idx)) {
+
+	if (z->open) {
 		/*
-		 * If the zone is already open and going to be full by writes
-		 * in-flight, handle it as a full zone instead of an open zone.
+		 * If the zone is going to be completely filled by writes
+		 * already in-flight, handle it as a full zone instead of an
+		 * open zone.
 		 */
 		if (z->wp >= zbd_zone_capacity_end(z))
 			res = false;
-- 
2.31.1


  parent reply	other threads:[~2021-12-14  1:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14  1:24 [PATCH v2 00/12] Cleanup zbd code Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 01/12] fio: Improve documentation of ignore_zone_limits option Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 02/12] zbd: define local functions as static Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 03/12] zbd: move and cleanup code Damien Le Moal
2021-12-14  1:24 ` Damien Le Moal [this message]
2021-12-14  1:24 ` [PATCH v2 05/12] zbd: introduce zbd_zone_align_file_sizes() helper Damien Le Moal
2021-12-14  8:33   ` Niklas Cassel
2021-12-14  1:24 ` [PATCH v2 06/12] zbd: fix code style issues Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 07/12] zbd: simplify zbd_close_zone() Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 08/12] zbd: simplify zbd_open_zone() Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 09/12] zbd: rename zbd_zone_idx() and zbd_zone_nr() Damien Le Moal
2021-12-14  8:33   ` Niklas Cassel
2021-12-14  1:24 ` [PATCH v2 10/12] zbd: rename get_zone() Damien Le Moal
2021-12-14  1:24 ` [PATCH v2 11/12] zbd: introduce zbd_offset_to_zone() helper Damien Le Moal
2021-12-14  8:34   ` Niklas Cassel
2021-12-14  1:24 ` [PATCH v2 12/12] t/zbd: Avoid inappropriate blkzone command call in zone_cap_bs Damien Le Moal
2021-12-14  8:34   ` Niklas Cassel
2021-12-14 13:48 ` [PATCH v2 00/12] Cleanup zbd code Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211214012413.464798-5-damien.lemoal@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=axboe@kernel.dk \
    --cc=fio@vger.kernel.org \
    --cc=niklas.cassel@wdc.com \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.