From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796384409; b=25ObTiNZbsV0ZMiCOPco1xTHI7U+D7loZGsnhNhYtVIV1b5bk9/5nKGgAhS6BMIokqi0 b11lZGxq25NhnIf4MMH6hiIIrc2+vliRMxwqYXHId0mOpcDbSfhYSF/JVybgzyqYJtF74 xDMO1V+RSuKNmX3KfUSSLSFEJJmGyxnH76LTa1dNpOdGEdI0Y1T6DLNpR9GC+/CdGCwMY VmyohEjcV7l0bpStUjoy17na7mTgP6xXG58lvYrZW90STHtHzUuqpmqWYYvgxkkmfQ6fg OhAyWmDNlGudomI9U5RtuwKhxVJUcAM2/hQiGCG9dNqTceCO+U+oDuSrrusjmCDmlew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384409; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=zCbElu2/dQDQOPp+hSxiRxTOgSPiwpt/URS0R+/HDvo=; b=j+CemOLpABfKc5AJKMVaZHGurDK0XcdrolTGg7lGOHkq1SZEGw7ytMUoeVt1teZK9HA7 yq+08zimtUcO6e8T9htQ64uezkRDWTmNAya3ehQJWk0I4LcaTionFUwtDYURBgyktWv4d GV5nq1QADq2V0Vt1roz6pVOsFSmz9Ac869scrO/8vLkMpEYrQt5RRxXvi0m9vYg0n89H2 xMtSX//qXQaKWai3vIBY4M6jlObt3fqqSne8932FOBArQQBVcj7IYeKhbK4bk/S8tKKPz fdLSsFMYLNr2CLfpxtHBe1CsQjRdUpKjIQ/g+VCBA4tBa6HhzA44bbfnw5IB/xU2g1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=W2x8yydR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35AF3606A32C; Fri, 4 Dec 2026 11:40:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=W2x8yydR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 631881F000C2; Fri, 4 Dec 2026 11:40:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384408; bh=zCbElu2/dQDQOPp+hSxiRxTOgSPiwpt/URS0R+/HDvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W2x8yydRkJqnh03dDpv0uIipS2xLlXMdC45XVi4n61/5jjP2Qs2linQYg0whyJgmZ hDQEhF1e0lbErHCJd5ZAODy5jTh6Dxe8qo1Cp1P/5oHlIyU43TS59Uxh7BiTQlK4bW Z2UGnb3IiuKv7X3JEutZ7ULd3AV4LbojXmMvntAw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shao Mingyin , "Michael S. Tsirkin" , Stefan Hajnoczi , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0136/1167] virtio-blk: Fix zone append sector reporting in batched completion Date: Fri, 4 Dec 2026 18:52:43 +0900 Message-ID: <20261204100705.630848804@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shao Mingyin [ Upstream commit 08a6572441a4e646c96c2b8d8ead9eea0e458332 ] For zone append, the block layer copies req->__sector back into the bio in blk_zone_append_update_request_bio(), so the driver must update req->__sector with the sector reported by the device. virtblk_request_done() does that, but the batched completion path used by virtblk_poll() only unmaps and cleans up the requests before calling blk_mq_end_request_batch(). A zone append completed through polling therefore keeps the sector that was assigned at submission time, and the file system or application sees the wrong LBA for the written data. Move the sector update into a helper and call it from both completion paths. Fixes: 95bfec41bd3d ("virtio-blk: add support for zoned block devices") Signed-off-by: Shao Mingyin Acked-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Reviewed-by: Christoph Hellwig Link: https://patch.msgid.link/202610261955196384aSLGuy3_0MiTvlYXVdiC@zte.com.cn Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/virtio_blk.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 49ce9ef8e8cfb..bf9fbe2f4efbc 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -332,18 +332,25 @@ static inline u8 virtblk_vbr_status(struct virtblk_req *vbr) return *((u8 *)&vbr->in_hdr + vbr->in_hdr_len - 1); } +static inline void virtblk_update_zone_append_sector(struct request *req, + struct virtblk_req *vbr) +{ + struct virtio_blk *vblk = req->mq_hctx->queue->queuedata; + + if (req_op(req) == REQ_OP_ZONE_APPEND) + req->__sector = virtio64_to_cpu(vblk->vdev, + vbr->in_hdr.zone_append.sector); +} + static inline void virtblk_request_done(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); virtblk_cleanup_cmd(req); - if (req_op(req) == REQ_OP_ZONE_APPEND) - req->__sector = virtio64_to_cpu(vblk->vdev, - vbr->in_hdr.zone_append.sector); + virtblk_update_zone_append_sector(req, vbr); blk_mq_end_request(req, status); } @@ -1250,8 +1257,11 @@ 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)); + struct virtblk_req *vbr = blk_mq_rq_to_pdu(req); + + virtblk_unmap_data(req, vbr); virtblk_cleanup_cmd(req); + virtblk_update_zone_append_sector(req, vbr); } blk_mq_end_request_batch(iob); } -- 2.53.0