linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>
Subject: [PATCH 3/6] zloop: simplify checks for writes to sequential zones
Date: Sat, 15 Nov 2025 21:15:53 +0900	[thread overview]
Message-ID: <20251115121556.196104-4-dlemoal@kernel.org> (raw)
In-Reply-To: <20251115121556.196104-1-dlemoal@kernel.org>

The function zloop_rw() already checks early that a request is fully
contained within the target zone. So this check does not need to be done
again for regular writes to sequential zones. Furthermore, since zone
append operations are always directed to the zone write pointer
location, we do not need to check for their alignment to that value
after setting it. So turn the "if" checking the write pointer alignment
into an "else if".

While at it, improve the comment describing the write pointer
modification and how this value is corrected in case of error.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 drivers/block/zloop.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 266d233776ad..0526277f6cd1 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -406,6 +406,11 @@ static void zloop_rw(struct zloop_cmd *cmd)
 	if (!test_bit(ZLOOP_ZONE_CONV, &zone->flags) && is_write) {
 		mutex_lock(&zone->lock);
 
+		/*
+		 * Zone append operations always go at the current write
+		 * pointer, but regular write operations must already be
+		 * aligned to the write pointer when submitted.
+		 */
 		if (is_append) {
 			if (zone->cond == BLK_ZONE_COND_FULL) {
 				ret = -EIO;
@@ -413,13 +418,7 @@ static void zloop_rw(struct zloop_cmd *cmd)
 			}
 			sector = zone->wp;
 			cmd->sector = sector;
-		}
-
-		/*
-		 * Write operations must be aligned to the write pointer and
-		 * fully contained within the zone capacity.
-		 */
-		if (sector != zone->wp || zone->wp + nr_sectors > zone_end) {
+		} else if (sector != zone->wp) {
 			pr_err("Zone %u: unaligned write: sect %llu, wp %llu\n",
 			       zone_no, sector, zone->wp);
 			ret = -EIO;
@@ -432,9 +431,9 @@ static void zloop_rw(struct zloop_cmd *cmd)
 			zone->cond = BLK_ZONE_COND_IMP_OPEN;
 
 		/*
-		 * Advance the write pointer of sequential zones. If the write
-		 * fails, the wp position will be corrected when the next I/O
-		 * copmpletes.
+		 * Advance the write pointer. If the write fails, the write
+		 * pointer position will be corrected when the next I/O starts
+		 * execution.
 		 */
 		zone->wp += nr_sectors;
 		if (zone->wp == zone_end) {
-- 
2.51.1


  parent reply	other threads:[~2025-11-15 12:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-15 12:15 [PATCH 0/6] zloop fixes and improvements Damien Le Moal
2025-11-15 12:15 ` [PATCH 1/6] zloop: make the write pointer of full zones invalid Damien Le Moal
2025-11-15 12:15 ` [PATCH 2/6] zloop: fail zone append operations that are targeting full zones Damien Le Moal
2025-11-15 12:15 ` Damien Le Moal [this message]
2025-11-15 12:15 ` [PATCH 4/6] zloop: introduce the zone_append configuration parameter Damien Le Moal
2025-11-15 12:15 ` [PATCH 5/6] zloop: introduce the ordered_zone_append " Damien Le Moal
2025-11-15 12:15 ` [PATCH 6/6] Documentation: admin-guide: blockdev: update zloop parameters Damien Le Moal
2025-11-17 16:42 ` [PATCH 0/6] zloop fixes and improvements 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=20251115121556.196104-4-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).