From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: [PATCH v9 06/13] zloop: keep zone write pointer and condition consistent
Date: Sun, 15 Nov 2026 23:50:08 +0900 [thread overview]
Message-ID: <20261115145015.938426-7-dlemoal@kernel.org> (raw)
In-Reply-To: <20261115145015.938426-1-dlemoal@kernel.org>
For oredered zone append commands, the function
zloop_set_zone_append_sector() increments a zone write pointer without
checking if the zone is already open (implicitly or explicitly). This
check is done only when the command is later executed using a work item,
and the zone is implicitly open if needed. This creates a short time
window where a report zone can show an empty zone with a write pointer
that is not equal to the zone start sector, which is incorrect.
Fix this by calling zloop_do_open_zone() in zloop_set_zone_append_sector()
to make sure that a zone is always first implicitly open if needed. This
requires changing zloop_set_zone_append_sector() to return a blk_status_t
so that potential zone resource errors can also be returned correctly.
Fixes: fcc6eaa3a03a ("zloop: introduce the ordered_zone_append configuration parameter")
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/block/zloop.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 96666742523b..7d98be66a3a8 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -885,20 +885,26 @@ static void zloop_complete_rq(struct request *rq)
blk_mq_end_request(rq, sts);
}
-static bool zloop_set_zone_append_sector(struct request *rq)
+static blk_status_t zloop_set_zone_append_sector(struct request *rq)
{
struct zloop_device *zlo = rq->q->queuedata;
unsigned int zone_no = rq_zone_no(rq);
struct zloop_zone *zone = &zlo->zones[zone_no];
sector_t zone_end = zone->start + zlo->zone_capacity;
sector_t nr_sectors = blk_rq_sectors(rq);
+ static blk_status_t ret = BLK_STS_OK;
spin_lock(&zone->wp_lock);
if (zone->cond == BLK_ZONE_COND_FULL ||
zone->wp + nr_sectors > zone_end) {
- spin_unlock(&zone->wp_lock);
- return false;
+ ret = BLK_STS_IOERR;
+ goto unlock;
+ }
+
+ if (!zloop_do_open_zone(zlo, zone, false)) {
+ ret = BLK_STS_ZONE_OPEN_RESOURCE;
+ goto unlock;
}
rq->__sector = zone->wp;
@@ -906,9 +912,10 @@ static bool zloop_set_zone_append_sector(struct request *rq)
if (zone->wp >= zone_end)
zloop_mark_full(zlo, zone);
+ unlock:
spin_unlock(&zone->wp_lock);
- return true;
+ return ret;
}
static blk_status_t zloop_queue_rq(struct blk_mq_hw_ctx *hctx,
@@ -917,6 +924,7 @@ static blk_status_t zloop_queue_rq(struct blk_mq_hw_ctx *hctx,
struct request *rq = bd->rq;
struct zloop_cmd *cmd = blk_mq_rq_to_pdu(rq);
struct zloop_device *zlo = rq->q->queuedata;
+ blk_status_t ret;
if (data_race(READ_ONCE(zlo->state)) == Zlo_deleting) {
rq->rq_flags |= RQF_QUIET;
@@ -929,8 +937,9 @@ static blk_status_t zloop_queue_rq(struct blk_mq_hw_ctx *hctx,
* command work runs.
*/
if (zlo->ordered_zone_append && req_op(rq) == REQ_OP_ZONE_APPEND) {
- if (!zloop_set_zone_append_sector(rq))
- return BLK_STS_IOERR;
+ ret = zloop_set_zone_append_sector(rq);
+ if (ret != BLK_STS_OK)
+ return ret;
}
blk_mq_start_request(rq);
--
2.56.0
next prev parent reply other threads:[~2026-11-15 14:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 14:50 [PATCH v9 00/13] Add support for storage element depopulation Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 01/13] block: introduce disk_zone_is_offline() Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 02/13] block: refactor blk_revalidate_disk_zones() Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 03/13] block: allow dropping all zone write plugs on revalidation Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 04/13] block: introduce storage element management Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 05/13] block: add storage element management ioctls Damien Le Moal
2026-11-15 14:50 ` Damien Le Moal [this message]
2026-11-15 14:50 ` [PATCH v9 07/13] zloop: fix zone reporting consistency Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 08/13] zloop: add storage element emulation Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 09/13] zloop: add degrade_element control command Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 10/13] scsi: scsi_proto: refine the definition of storage element health Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 11/13] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 12/13] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-11-15 14:50 ` [PATCH v9 13/13] scsi: sd: fail read commands to offline zones early Damien Le Moal
2026-11-15 15:42 ` [PATCH v9 00/13] Add support for storage element depopulation Damien Le Moal
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=20261115145015.938426-7-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox