From: Damien Le Moal <dlemoal@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Cc: Suwan Kim <suwan.kim027@gmail.com>, Sam Li <faithilikerun@gmail.com>
Subject: [PATCH] block: virtio-blk: Fix handling of zone append command completion
Date: Tue, 20 Jun 2023 17:38:57 +0900 [thread overview]
Message-ID: <20230620083857.611153-1-dlemoal@kernel.org> (raw)
The introduction of completion batching with commit 07b679f70d73
("virtio-blk: support completion batching for the IRQ path") overlloked
handling correctly the completion of zone append operations, which
require an update of the request __sector field, as is done in
virtblk_request_done(): the function virtblk_complete_batch() only
executes virtblk_unmap_data() and virtblk_cleanup_cmd() without doing
this update. This causes problems with zone append operations, e.g.
zonefs complains about invalid zone append locations.
Fix this by introducing the function virtblk_end_request(), which is
almost identicatl to virtblk_request_done() but without the call to
blk_mq_end_request(). Use this new function to rewrite
virtblk_request_done() and call it in virtblk_complete_batch() to end
all request of a batch.
Reported-by: Sam Li <faithilikerun@gmail.com>
Fixes: 07b679f70d73 ("virtio-blk: support completion batching for the IRQ path")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/block/virtio_blk.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 2b918e28acaa..513d8b582aec 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -332,10 +332,9 @@ static inline u8 virtblk_vbr_status(struct virtblk_req *vbr)
return *((u8 *)&vbr->in_hdr + vbr->in_hdr_len - 1);
}
-static inline void virtblk_request_done(struct request *req)
+static inline blk_status_t virtblk_end_request(struct request *req)
{
struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
- blk_status_t status = virtblk_result(virtblk_vbr_status(vbr));
struct virtio_blk *vblk = req->mq_hctx->queue->queuedata;
virtblk_unmap_data(req, vbr);
@@ -345,17 +344,21 @@ static inline void virtblk_request_done(struct request *req)
req->__sector = virtio64_to_cpu(vblk->vdev,
vbr->in_hdr.zone_append.sector);
- blk_mq_end_request(req, status);
+ return virtblk_result(virtblk_vbr_status(vbr));
+}
+
+static inline void virtblk_request_done(struct request *req)
+{
+ blk_mq_end_request(req, virtblk_end_request(req));
}
static void virtblk_complete_batch(struct io_comp_batch *iob)
{
struct request *req;
- rq_list_for_each(&iob->req_list, req) {
- virtblk_unmap_data(req, blk_mq_rq_to_pdu(req));
- virtblk_cleanup_cmd(req);
- }
+ rq_list_for_each(&iob->req_list, req)
+ virtblk_end_request(req);
+
blk_mq_end_request_batch(iob);
}
--
2.40.1
next reply other threads:[~2023-06-20 8:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-20 8:38 Damien Le Moal [this message]
2023-06-22 14:32 ` [PATCH] block: virtio-blk: Fix handling of zone append command completion Suwan Kim
2023-06-22 21:55 ` Damien Le Moal
2023-06-22 22:19 ` Michael S. Tsirkin
2023-06-22 23:33 ` 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=20230620083857.611153-1-dlemoal@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=faithilikerun@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=suwan.kim027@gmail.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