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 AF44080031 for ; Wed, 25 Nov 2026 11:58:32 +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 6APBvJ9D016189; Wed, 25 Nov 2026 14:57:20 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6APBvJ9D016189 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="S4iAaZPI" Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6APBv79K016142 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Wed, 25 Nov 2026 14:57:08 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6APBv79K016142 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-c50681426b9so551640966b.3 for ; Wed, 25 Nov 2026 03:57:08 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErHyIRe//o+6OLNBOXMvyGsS9XGYXhdraxkKou1f3oL2SvK4k5V8krOJfSYIgLVDQ0tbZnF0oA==@openvz.org X-Gm-Message-State: APuU4Z/BbOLQN3XAHUbk+K5zAGd3sDYBfDqYjCFZ/7a9FuGcP2a74RP0 MQd5+PaS2ezVvqZto00H8eAY4TlxADx9op2VnIFZyZjRJDub0lvUgbkfmltfFHIYo2qnoCN9Keb jXR064BCEQ7Dxca9/h39MKw+ndIuRPSc73mB1zgLUHCZp0m33t7BgDA== X-Gm-Gg: AZFdTZcOckWe4jpVqnTBlcc1VrCphpcQBIhISrekukEwwlSl9ZKR2v3DJM0bYVpAYO7 w2MkOCfJcxV8e1H/4+P/8DRrGLP9WGnx3i3AtjWsE6Ssph2kGULkdhpjqyx8cJVp5CQ4KdZfyVJ qPLPbBxUvKQVMMw5RG1G9A922sZLfLiDYe35gNHZsqsvjajJCOmI06eBnnOudeUE9RsqEhKlgvH RFRwK2LfcwQNF5qxxPAZpsDDCYw4Qh564mMmutKJ+w1JCesx9ajNuV7m4gzPz8Bq1nTiWiG0N4D jIP2N1ac7L2VHjfE1FxtnnT39gOF+zA8S89roWp/ElUesY/p+cAVj+gSnFH3N1SdhDQWO+e/Iaq SoNWTFvWN0q+gvdvBZxjMJ2sFYdM= X-Received: by 2002:a17:907:948a:b0:c49:9383:a28 with SMTP id a640c23a62f3a-c513ab42e45mr1458173166b.35.1795607827725; Wed, 25 Nov 2026 03:57:07 -0800 (PST) X-Received: by 2002:a17:907:948a:b0:c49:9383:a28 with SMTP id a640c23a62f3a-c513ab42e45mr1458170966b.35.1795607827232; Wed, 25 Nov 2026 03:57:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795607827; cv=none; d=google.com; s=arc-20260327; b=abbAM8zvwXNWM2/ZICUnalkLat85/bt8CF9ITHlW3GlDN7mfcu0V4mFx+NvpGsOIQm 7He0xZKsDuduiuJ7PnZif2pgVY5UL2Enm1SqE2v5GLgAM1OtarC2ie09+htVi2Ndkpo8 1Pg3Jd0LHDNPWIFgMJQQuPlBQRROB/cSvJflyXccINRDTdLXlzwgzL0MpftSwwkXUeGt V8STt/lKlL3GUg9JYghvlzXSGmoyU5ULHTD4OHPdAnXTcSDKk4NWafu7p8iGK0XAAlKk 3d1cGRW4qY8+bNv0M2C9p7h1nXmhsiWBe16GkH2hpsiwQRjHVFuE/EgCwmXigCurfP4g Wbqg== 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=PO9LZkWNq2shHQgN1zv+Qu20DUGZv/t7qYsl1xlTGAM=; fh=CMILZ+goaghq6B4UpCDhf0EQp6kYD0LAlmOkUiVCOvs=; b=XhrfeO/uLqCIW7pSRSWS/bBKlpCEZhwNTjSrizAVoBbFcY8xPdrYIKALnGwnf+guI6 by941998IRzvqOqDSihZxSaLU0isGaenNECID/FKDNtA6i67nTjMu90UGArxp5yjQnTN DCUo5ePLDpQDRGuF5aqnAGxnUYY5f9EW+kePN/+H5K+W9n/rIiHdBxp+TcFtAKc9V2Ns hYTppnlKserZ/5uuvz5Qxj4pDcCPW1y7WBFU3KhYDiIPbiE1Newm34eNn5MMgTv9Z/VC cDSlsctMfzw+IK/zMnfJGeFiVClMjaooj9wlIw+WIWm10S+wLOrSYUcc7u9bFfiMxcHB WmeA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=S4iAaZPI; 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-c513b0d441bsi1124567666b.339.2026.11.25.03.57.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2026 03:57:07 -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=S4iAaZPI; 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=PO9LZkWNq2shHQgN1zv+Qu20DUGZv/t7qYsl1xlTGAM=; b=S4iAaZPIGGX4 4ChruWqmaDngkV0ikjkWX2bPXvE5pc0KymeblVjFnKKJo4y3BZfp4Q+zGO7wJoyHw0wKoPHPgPvBJ sJFG7Ac+qN2BtYhqbX6nwS384fRXNRikV6jUCzHXT4W/NaaKe46IPzu1dmEdlPohwa7u9Fj//to+J PnRNZ3avwk26kC2nP8FDwjd5apAD8QdKcg5fwaXSvEEHomxaArfXO/vDAkFK0Jpwr5po75Cs6EWJM idPzT2LiAMh+m/m7HRDDEphFyakIdCEi4BSlIXweMBNqZtPRMyoN2pn1cCNBt/MdOjY2UnX0WYk7O RqRbpa+TDGhwIxz9BuaQ8w==; 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 1xWBcN-008VZ0-1t; Wed, 25 Nov 2026 12:57:06 +0100 From: Alexander Ivanov To: andrey.zhadchenko@virtuozzo.com Date: Wed, 25 Nov 2026 12:57:02 +0100 Message-ID: <20261125115703.741517-4-alexander.ivanov@virtuozzo.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261125115703.741517-1-alexander.ivanov@virtuozzo.com> References: <20261125115703.741517-1-alexander.ivanov@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2 v3 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c index 86b526c3f571..0aee05b3f524 100644 --- a/drivers/vhost/blk.c +++ b/drivers/vhost/blk.c @@ -149,9 +149,13 @@ 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 = I_BDEV(req->blk->backend->f_mapping->host); int err; err = blk_status_to_errno(bio->bi_status); + if (err && (req->bi_opf & REQ_OP_MASK) == REQ_OP_WRITE_ZEROES && + !bdev_write_zeroes_sectors(bdev)) + err = -EOPNOTSUPP; if (err) req->bio_err = err; @@ -730,7 +734,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