From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 88C0B80031 for ; Wed, 25 Nov 2026 14:23:14 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6APELu3F028370; Wed, 25 Nov 2026 17:21:57 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6APELu3F028370 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="xOTXCFhP" Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6APELn7Z028336 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 25 Nov 2026 17:21:49 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6APELn7Z028336 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-c50713860c0so501175566b.0 for ; Wed, 25 Nov 2026 06:21:49 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGFOmVxJiaHcbz+iFcIBQkpNmbwz5e+nsI9o42mYbZIfvjXN1VJOVWr2T9wPBRimNY5XsMonA==@openvz.org X-Gm-Message-State: APuU4Z/Ifo9YDyR1NZfAI7oCEOHIO5DiLOOG/L2HQ41rN7eSLvu0ssd6 Wrn6TkF0NpzjHm4by+uKpU+48q/4DMs3auciJ8qkU7vS/Z1n9LC4nvRhrT+KUWfILFHjTYXPeso qo9mo5AZlLXcKpmYUhPRdrrMmWpSpMsYQvIn37jZ8/yt8ld5dseN96w== X-Gm-Gg: AZFdTZd65BucH8+SEYjuffzWaaTsIRRQVovs9EFiJVgTdorfvQJQPDArVNjSJbn4ONG OVJLW2dfO3Qlhh789IKAsGfJX4FVXYszxbX5N8FKqS9QSngqqh1VICzRXaucfSssByqHnjUNUvz LfxBrl34nm+X07JG8MF7onKfjwpgA2jf73nPqAGTxA9wzEr7Diz6OabzutPEo+zArQB4hS+LGFM wk+TT7TZFSnvUsund280wF+53xz/2iZ+u4CAGFfmh7pfVpOPjrT3MjYs3PUxb6kITXrLQ6mnO5Z M826cOEifxQfOIF1nK6vugkRlRgDcJ1TKUAd6EPbCrzS685FaTYdFpdvHe79qYrazNrgw+9bb8a WGQkKlsGAFR73EJFp9B2KE4v9JPrX X-Received: by 2002:a17:906:5ac5:b0:c46:b9b0:8e8f with SMTP id a640c23a62f3a-c513ab1303fmr1066504566b.41.1795616509314; Wed, 25 Nov 2026 06:21:49 -0800 (PST) X-Received: by 2002:a17:906:5ac5:b0:c46:b9b0:8e8f with SMTP id a640c23a62f3a-c513ab1303fmr1066503266b.41.1795616508876; Wed, 25 Nov 2026 06:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795616508; cv=none; d=google.com; s=arc-20260327; b=qes+HPqBOws9xbbTFXjmBommzWmfDF8eo1pBdt2gKCJlTvK1nT+/BrMVvD7ul0PUXl PvCnEUt9dmc6faCom9IqfmerRVpYSYcc5W50VgAfgSD8IEuUbdUcxqrtI4EYPXVwCBGn c/VavzcTbbcYkqtz8wpyWNUrK95p4/WuJlwSgKQ3CUaRLMvG8/xfBBfMsne/2eVLZB7K aa//KBAkgPh8JhDQ+VeCq9szsz3Ny+t9oY+k32Q9++7RfUw5bQZL5GU2j9BYRB5NTh92 M5Xb0EZeU2QvtdT6ePFUrtG/vHEn8OXwAbHDCx9ztijZjfNn5kFxKxlqKf/agKvr6i5j XsYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IcmYZ/7bEHXUc0GaPiu0E0XvB3te3xspq8/mjDB12G0=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=dKWBe46MiVYZ09WDP2KdY2Poyfe6wv7HtFtpu+LAkmuQuR3v45/Pj0Ic2nwe0WPS+S +zNlHah45r703MGzFlDwAmlvRYHerU1j8Stpbx25K0FvgwcJflVGsiYXtGXRkmM95GCu Gp0moYHvuL49wOPT+GUPrTCQ1jMw6yg9LWBjBxfqhIvtNkmnxmKOrnANpMqgnN3JBRE7 5cDj3TLX4x2S1cBvMsB898640jFM0j9ZrrSiDu1cfWpTi6LkjLLz1LyMxdb4jnmLCF1j sqLmpv/LAgd2qDaN5YilqlywrEo9jAqDQOXaX7nqCNSSoTKcf7yMg1aOLq/hTLEYl+eQ uz0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=xOTXCFhP; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id a640c23a62f3a-c513afe3ad5si1254435666b.63.2026.11.25.06.21.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 06:21:48 -0800 (PST) Received-SPF: pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=xOTXCFhP; spf=pass (google.com: domain of alexander.ivanov@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=alexander.ivanov@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=IcmYZ/7bEHXUc0GaPiu0E0XvB3te3xspq8/mjDB12G0=; b=xOTXCFhP3aYE K0ZCzGUIFQi22i04Se4XY1CJS1U9YI/W9oHDSPZ31JwOte4xsZ4WNfB2EaCtmWNH1AOF5GCdgPO2f dH0o21LAMaHiBnW0eWivg1EQ6/0HsiTPlvvEnDcrRfxKYIUPCH4O6K6/DUDD6xZH/YH3RetxpWSCV +udh11mqWgtqBSsbMu3e9PLooLk1JrbMUbHFATq5e9UZ6cVcjV7JACcIz4KuBmG8T+YmIipLhRbJs xemmR25rjyztEh/3c1M4Z+b36jENRuTpR5jglVKC51UiJnD1cm+VW7aYO12ZcA0XLy/S/n5ZfykY3 fLaE8d1J7RgXFoIIuuCCLA==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=sky) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xWDsP-009Fgm-0W; Wed, 25 Nov 2026 15:21:47 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Wed, 25 Nov 2026 15:21:44 +0100 Message-ID: <20261125142145.786278-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261125142145.786278-1-alexander.ivanov@virtuozzo.com> References: <20261125142145.786278-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v4 3/4] drivers/vhost/blk: return UNSUPP for write zeroes on a backend without it X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The guest reads max_write_zeroes_sectors once at probe, but the WRITE ZEROES limit of the backend can change while it runs: a dm table reload with a target that does not pass WRITE ZEROES through drops it to 0. vhost-blk then fails every WRITE ZEROES with VIRTIO_BLK_S_IOERR, and a Linux guest since v6.11 returns -EIO to the caller instead of writing zeroes itself. The VMM cannot work around it: the limit it samples may already be stale, and the destination of a migration must offer the features the guest has negotiated whatever the limit there is. Answer VIRTIO_BLK_S_UNSUPP when a WRITE ZEROES bio fails with BLK_STS_NOTSUPP, whatever the limit of the backend: submit_bio_noacct() fails a WRITE ZEROES bio with BLK_STS_NOTSUPP once the limit is 0, and a backend that rejects the command while advertising it gets UNSUPP instead of IOERR as well. A request in flight while support is lost may fail with BLK_STS_TARGET instead, when dm or sd drop the limit on a target error. As blkdev_issue_write_zeroes() does, treat any failure of a WRITE ZEROES bio as unsupported once the limit of the backend is 0. The guest gets -EOPNOTSUPP instead of -EIO, and blkdev_issue_zeroout() falls back to writing zeroes unless called with BLKDEV_ZERO_NOFALLBACK. dm-kcopyd submits WRITE ZEROES without such a fallback and still fails, now with -EOPNOTSUPP. This replaces the contract of 3b2e28a4f6b7, which answered VIRTIO_BLK_S_IOERR for a backend without WRITE ZEROES. The VMM must still offer VIRTIO_BLK_F_WRITE_ZEROES only for a backend that supports it at setup: the guest never learns that the limit is 0, and dm-kcopyd would fail dm-thin zeroing of new blocks and dm-snapshot. Fixes: 3b2e28a4f6b7 ("drivers/vhost/blk: support VIRTIO_BLK_F_WRITE_ZEROES") https://virtuozzo.atlassian.net/browse/VSTOR-141684 Feature: vhost-blk: in-kernel accelerator for virtio-blk guests Signed-off-by: Alexander Ivanov --- drivers/vhost/blk.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c index 86b526c3f571..5b8522729d18 100644 --- a/drivers/vhost/blk.c +++ b/drivers/vhost/blk.c @@ -149,11 +149,17 @@ static inline int vhost_blk_set_status(struct vhost_blk_req *req, u8 status) static void vhost_blk_req_done(struct bio *bio) { struct vhost_blk_req *req = bio->bi_private; + struct block_device *bdev; int err; err = blk_status_to_errno(bio->bi_status); - if (err) + if (err) { + bdev = I_BDEV(req->blk->backend->f_mapping->host); + if ((req->bi_opf & REQ_OP_MASK) == REQ_OP_WRITE_ZEROES && + !bdev_write_zeroes_sectors(bdev)) + err = -EOPNOTSUPP; req->bio_err = err; + } /* * Bounce buffer adds kvec to bio (instead of user backed memory), @@ -730,7 +736,13 @@ static void vhost_blk_handle_host_kick(struct vhost_work *work) } vhost_blk_req_cleanup(req); - status = req->bio_err == 0 ? VIRTIO_BLK_S_OK : VIRTIO_BLK_S_IOERR; + if (!req->bio_err) + status = VIRTIO_BLK_S_OK; + else if (req->bio_err == -EOPNOTSUPP && + (req->bi_opf & REQ_OP_MASK) == REQ_OP_WRITE_ZEROES) + status = VIRTIO_BLK_S_UNSUPP; + else + status = VIRTIO_BLK_S_IOERR; if (vhost_blk_set_status(req, status)) { vhostblk_vq_err(blk, vq, "Failed to write status"); } else { -- 2.53.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel