From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11023102.outbound.protection.outlook.com [40.107.159.102]) by lore.virtuozzo.com (Postfix) with ESMTPS id 12D1480067 for ; Thu, 26 Nov 2026 09:35:51 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PPG6ROm1h17CMmbXjpcTe9Itu4UNRw7f1lhpetWYZ71gQKUT7Jnp7IxSCW5OeUoo9aFDP1uR2XKks5bb2qocjVsQ0s12UVgrShT3zYGQVDqboW/BmerJocq+pRBhgCdYkQQWHo+eFZo7Hl9rkvstRz2qREVEtMg+lhtMwoc5RdymKZM/H0/X3brs6HqQmow0eoTZ19yrHlvPDj5vuG3iw1IXYNHJfTO5/ixIP+X9N8ANMkpMltedNOC/XPMcFSqG59Tw5XXn8PriuChqwA+vrT0K9IlzrKP3KIhBcMzHAZqGzXa6NJURmK5863shlB/R/QD4HJNfMWICUtc/J4ykoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0S943FkZl8hNq9yyjSF/3GJ8wNFbtVd6arRheT3Z94Q=; b=qvk6ZA/sE0iF5cIW6f5mOYK1NDKZtG0UOldBGVh1QNMTcib5wg67GGG+/iVYUJ14a1dqEST6xP4YHKS85i6qgNm4bGS+y4NxefK6patxBiifX/LVmkoS2QYsqT2Y5Zt9vqqnEZ1NhcxvVXXuu94iuWYYt9OTIgjYZTAm7mNr7g6rMQEjCKkCp/rWhDh+yWKyi7pGcSFNBgjvMrrw2G+htC0Qea2UwjLryzaS5lbubysMreuXO6KWwiCwSmhHqtEesg4rqiXxvd1REM7+FxP1zmiJqQPqO68GL9Mw0SSu78Izw7UXaRtXr4R3CuHaKYIKnos9jlpEEOPxoq6j2hFSRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0S943FkZl8hNq9yyjSF/3GJ8wNFbtVd6arRheT3Z94Q=; b=FR8KpJw7ZJBeZS61ZsuHYnrYaHPcPLlhLJ/OsNzA5YBm2Jh4Mb2xa8WzOBpSGnDVUT488xT39eJ2cHRAFk8P2iaDmNbgHVQj1XuZeQuYx+56LoNKrrzzsxxE52S/qJe3wiE30p1w3t0kKd2l9qhgX/IPOTauEWmEDlr98L5t80DhqUiKGA64oIPzy0UOBxh6zjUDyH/htH00nvjc8jMutWhebN6fYcOEYYz++uQwuo5wMTmdnIj21gzCxCD2V7ogFdrUdlqlFcIbV17VVy/3Yv0m6kN2iwiRsm0MXptO+hgS5/D9bHtsJzxoTBD1bck6TcEmizBaK3n0zerqx+ypdQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) by VE1PR08MB5759.eurprd08.prod.outlook.com (2603:10a6:800:1b3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.7; Thu, 26 Nov 2026 09:35:46 +0000 Received: from VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::7a7c:d078:f125:f16a]) by VI0PR08MB10743.eurprd08.prod.outlook.com ([fe80::7a7c:d078:f125:f16a%3]) with mapi id 15.21.0662.004; Thu, 26 Nov 2026 09:35:46 +0000 Message-ID: <110b54df-e191-495f-b234-032cb2681493@virtuozzo.com> Date: Thu, 26 Nov 2026 10:35:44 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH hci-8.2] vhost-blk: advertise discard limits in the config space To: Andrey Drobyshev Cc: andrey.zhadchenko@virtuozzo.com, svt-core@virtuozzo.com References: <20261123084134.177261-1-alexander.ivanov@virtuozzo.com> <20261123173550.104355-1-andrey.drobyshev@virtuozzo.com> Content-Language: en-US From: Alexander Ivanov In-Reply-To: <20261123173550.104355-1-andrey.drobyshev@virtuozzo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ZR0P278CA0182.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::15) To VI0PR08MB10743.eurprd08.prod.outlook.com (2603:10a6:800:205::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI0PR08MB10743:EE_|VE1PR08MB5759:EE_ X-MS-Office365-Filtering-Correlation-Id: f3fdf063-61e9-4825-680c-08df4ba0a5ed X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|23010399003|366016|376014|1800799024|4143699003|5113699003|6133799003|261009223027099003|22082099003|18002099003|10067099003|56012099006|5023799004|261102123227099003|261028144727099003|261026121527099003|261026140227099003|261022115727099003|261021123027099003|261021121427099003|261022075727099003|261022105027099003; X-Microsoft-Antispam-Message-Info: FBBnPEvezMxWKEoeLiYZhnBoGKd3j3MSN07bZMCiWIjRLGyAKVNmYdFmJztD9ZGuomjWHdG4Iwgmc8Sj2w6f2igxruufOl5fJdYRGxIPh/UDSGkA8+yfSy1ytvCUh/jph3TH4FDMWjAcjSVMDg7iopGAKH4Fh+gNxaRNIt+loUHYeG2CpWRQuI2fo3+EuRWJghw0YmA1Wo+gzMACyvAOS26n3sajA5rHcCRfRoPLy3ELQu1+8URt5XS5FOx1F2vIwOT1l1LEgmK8bmxo/+KqK5WrDfOz8ScX2has8m/xt5JhgNtlsl8JBEvNOR0mHOuyj3X+u8IOLqS/UbF1CwY+RJV50Kai7MW7+f7gzT1GaUBL04YvnBpvq9w7HRbiZrwdYYYRXxQO9ax56VWbn+/98GwtKTySGQz3olepWNJdho46Txf8n7IPtycqRNjWfblIE4Z4V6ohBkziwLX9IKEpvj6cR0idmppxloiXJUANdXdcCy3qljJFxIi4KduCQNg43Yfc494Hs1cLj3q8Ggak7ZJQxNXAtJn1Ak0qCwx9cgrgRTukRu6eewncEOBYCsp2L/k73t9l5qmFuiBEhbXN7DzoWLo2mAMfxjjGK2ZIag/KzDHR3rY/oIt1vTnEteMUxAelT986RDc/D1bI5KhQVjhll8+DOoQwYa+wgnLzr2I= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI0PR08MB10743.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(23010399003)(366016)(376014)(1800799024)(4143699003)(5113699003)(6133799003)(261009223027099003)(22082099003)(18002099003)(10067099003)(56012099006)(5023799004)(261102123227099003)(261028144727099003)(261026121527099003)(261026140227099003)(261022115727099003)(261021123027099003)(261021121427099003)(261022075727099003)(261022105027099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eVU4RDlROTRZazVFSTZnWjZFMU5SRldCSGhLT3lUc3pIbHRjTGxpZEVTQ2Ni?= =?utf-8?B?NTdMTmFBb1F0Y0FxRHVPSk9Ram5qQ1dHQUJJbkpTbEM3a2tIQUN5dXE2dVc5?= =?utf-8?B?aXU5M2p6WXhFN2RvaFgxQkRFamdvelQzdjl1UlJuNXQvcDl5Y1RFSlZqUWRQ?= =?utf-8?B?UUo0d09iS2w4Um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tmZy9sanlvR2ln?= =?utf-8?B?WkVTdThSN040MDFyRjI1dUMrWmdkZ1NYa296WUJkVmhRZWVTSjltNWJyZ0JD?= =?utf-8?B?VWtKZGNBaURWSFRlQzJEZ0pNcFdRZW5yTnRwRGdOYkQxYjYzWkRmcXlHenh1?= =?utf-8?B?KzJ5bFZ5dGFVZ3RjaUY3bG4zcW9wbXlQallYai9FUHJadjdyL3RwbENXMjZ1?= =?utf-8?B?ZVJzUngxZFBBM1VjM3JVTFNQOWcreEVqcm9NWTZrVG5JSVpoc0JtWlJGVG80?= =?utf-8?B?aTJ0S2RDeGpDRlJIdXJtMEZaOTlrOFBvVXVER0ZiREE4WXJESXFONlY3WEFl?= =?utf-8?B?Uk5NcDUxVEZ6eUY0TnlDOHlmamg0bDVaV0g1WUxVTmlpZjJSQjBIQUY3OXdi?= =?utf-8?Q?yB6ISFLhJWabM1dg=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3fdf063-61e9-4825-680c-08df4ba0a5ed X-MS-Exchange-CrossTenant-AuthSource: VI0PR08MB10743.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2026 09:35:46.3577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QkonUw/W7xbYWqHOZ4Q7Tij6ULSO2xqVws1tcznFp2beu42c7R/yZkVXSIoCpFanU4Ghsw6lpMAsKIldgMK9q1YwFeBIodzTS/rO/dfzShQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5759 On 11/23/26 18:35, Andrey Drobyshev wrote: > On Mon, Nov 23, 2026 at 09:41:34 +0100, Alexander Ivanov wrote: >> vhost-blk in the kernel now handles VIRTIO_BLK_T_DISCARD, but with the >> discard property on, the config space reports zero for max_discard_seg, >> max_discard_sectors and discard_sector_alignment. A Linux guest reads a >> zero max_discard_seg as seg_max and merges adjacent discards into one >> multi-segment request, which the kernel rejects with >> VIRTIO_BLK_S_UNSUPP. >> >> Advertise one segment per request, as virtio-blk does, a range that >> fits in the single bio the kernel issues, and the logical block size as >> the alignment. Unlike write zeroes, the backend discard limit is not >> read: the kernel splits the bio by it and completes a discard with >> VIRTIO_BLK_S_OK when the backend cannot do one. >> >> The property stays off by default. A kernel without discard support in >> vhost-blk does not offer the feature, so it is not negotiated there. > (3) [low] discard=on is dropped without any message on a kernel that > has no vhost-blk discard (masked by vhost_get_features()). Same > consequence as for write zeroes: a VM that negotiated the feature on an > upgraded node fails to migrate to a node that is not upgraded yet, and > only at virtio_load() with the generic "Features 0x... unsupported". > At least a warning at realize is needed; OnOffAuto with "on" failing > realize is the conventional fix. Added a warn_report() at realize when discard=on but the kernel does not offer VIRTIO_BLK_F_DISCARD, so the destination log explains the failed migration. >> https://virtuozzo.atlassian.net/browse/VSTOR-141683 >> >> Signed-off-by: Alexander Ivanov >> --- >> hw/block/vhost-blk.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/hw/block/vhost-blk.c b/hw/block/vhost-blk.c >> index 153cc7604d0..3f940e965ad 100644 >> --- a/hw/block/vhost-blk.c >> +++ b/hw/block/vhost-blk.c >> @@ -812,6 +812,13 @@ static void vhost_blk_update_config(VirtIODevice *vdev, uint8_t *config) >> blkcfg.physical_block_exp = get_physical_block_exp(conf); >> blkcfg.alignment_offset = 0; >> virtio_stw_p(vdev, &blkcfg.num_queues, s->conf.num_queues); >> + if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_DISCARD)) { > (4) [nit] Gated on the property, not on the offered feature. On a > kernel without vhost-blk discard the bit is masked by > vhost_get_features(), but the three fields are still filled in. > Harmless by the spec; single source of truth is: > > if (virtio_host_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) { Keeping it as is. virtio-blk gates the same fields on the property too (virtio_blk_update_config()), and write zeroes in the previous patch does likewise. The guest never reads these fields unless discard is negotiated, and realize already warns when the kernel lacks support. > (5) [nit] Discard is offered on a read-only backend, write zeroes is > not. The kernel fails such a discard with VIRTIO_BLK_S_IOERR. Linux > does not send discards to a read-only disk, but the two features should > behave the same. Fixed: Do not offer discard on a read-only backend > >> + virtio_stl_p(vdev, &blkcfg.max_discard_sectors, >> + UINT32_MAX >> BDRV_SECTOR_BITS); > (1) [medium, not measured] 4 GiB per request, while dm-qcow2 takes one > cluster per discard. > > qcow2_io_hints() sets max_hw_discard_sectors to the cluster size; a > dm-qcow2 device with 1M clusters reports discard_max_bytes=1048576 and > nr_requests=256. The kernel does not check a discard against the > backend limit, it issues one bio and lets the block layer split it. > The split is synchronous in the submitter: vhost_blk_bio_send() calls > submit_bio() from the request handler, and bio_split_discard() / > bio_submit_split() cut one piece at a time and resubmit the rest in the > same context. > > So one 4 GiB guest discard becomes about 4096 cluster discards issued > by the vhost worker, which sleeps on tag allocation once 256 of them > are queued. While it sleeps it does not serve the other virtqueues, > and with the default num-threads=1 that is every queue of the disk: > reads and writes wait behind the discard. The same backlog has to > drain in vhost_blk_stop() (VHOST_BLK_SET_BACKEND with fd -1 waits for > in-flight requests) under the BQL, which stretches pause, migration > downtime and qemu-update. How long a cluster discard takes on > dm-qcow2 was not measured, so the size of the stall is unknown; the > 4096:1 ratio is from the code. > > The commit message argues the limit need not be read because the > kernel splits by it. That makes the request correct, not cheap. > Advertising the backend limit lets the guest do the splitting, where > discards interleave with other I/O in its block layer: > > max_discard_sectors = MIN(discard_max_bytes >> BDRV_SECTOR_BITS, > UINT32_MAX >> BDRV_SECTOR_BITS); > > with queue/discard_max_bytes read the same way the write-zeroes patch > reads write_zeroes_max_bytes, and the current constant as the fallback > when the value is 0 or unreadable (the kernel completes a discard with > VIRTIO_BLK_S_OK when the backend has none). Unlike write zeroes, the > kernel does not enforce this limit, so a different value after > migration is harmless: a larger request is still split by the host. > Reading it from the host has no ABI cost here. Used the same constant as we used for write_zeroes. Measured performance with 1MB and 2GB limits: num-threads=4 - 2 GiB: discard 0.97 s, reads 3930 IOPS, max 0.8 ms. - 1 MiB: discard 3.24 s, reads 1446 IOPS, max 7 ms. So actually 2GB constant is much better then 1MB. > + virtio_stl_p(vdev, &blkcfg.discard_sector_alignment, > + blk_size >> BDRV_SECTOR_BITS); > (2) [low] 512 bytes, while the backend granularity is 4096. > > blk_size is hard-coded to BDRV_SECTOR_SIZE for vhost-blk, so this is > always 1 sector. dm-qcow2 reports discard_granularity=4096 (the block > size of the filesystem under the image). "As virtio-blk does" does not > hold for this field: virtio-blk reports conf->discard_granularity taken > from the backend and falls back to the logical block size only when it > is unknown or report-discard-granularity is off. A virtio-blk disk on > a qcow2 image shows 4096 in the guest's queue/discard_granularity. > > Consequences: > > a) A discard smaller than a filesystem block frees nothing on the > host. For a partial cluster dm-qcow2 calls qcow2_punch_hole() on > the byte range (issue_discard()), so each such request costs a > fallocate() and releases no space. > > b) The guest chunks large ranges at an odd size. Linux uses > round_down(UINT_MAX, discard_granularity) >> 9 per bio > (bio_discard_limit()), which is 8388607 sectors with a 512-byte > granularity. The kernel rejects a discard with > (sector | nr_sects) & bs_mask, so on a backend with a 4K logical > block size every full-size chunk, and every chunk after it since > the start is now odd, gets VIRTIO_BLK_S_IOERR: fstrim and > blkdiscard fail on any range of 4 GiB or more. With 4096 > advertised the guest chunks at 8388600 sectors and stays aligned. > dm-qcow2 takes its logical block size from the block device under > the image's filesystem, so this needs a 4Kn disk on the host. > > Read queue/discard_granularity and use it, with the logical block size > as the lower bound: > > virtio_stl_p(vdev, &blkcfg.discard_sector_alignment, > MAX(blk_size, granularity) >> BDRV_SECTOR_BITS); > > and round max_discard_sectors down to the same value. If no sysfs > read is wanted for this field, MAX(blk_size, 4096) already covers both > consequences. (b) is not reachable: vhost-blk always reports a 512-byte logical block size to the guest, so on a 4Kn backend regular 512-aligned reads and writes fail already. That configuration is unsupported regardless of discard. On 512n/512e backends odd lengths are fine. (a) is true but minor: guest filesystems discard in fs-block units, and a larger granularity does not stop the guest from sending sub-granule heads and tails anyway. Also, virtio-blk on qcow2 reports the cluster size (pdiscard_alignment), not 4096. Reporting the backend's discard_granularity is a reasonable hint, but not a fix for a bug. I'll leave it as is. >> + virtio_stl_p(vdev, &blkcfg.max_discard_seg, 1); >> + } >> if (s->max_write_zeroes_sectors) { >> virtio_stl_p(vdev, &blkcfg.max_write_zeroes_sectors, >> s->max_write_zeroes_sectors); >> @@ -832,7 +839,6 @@ static const Property vhost_blk_properties[] = { >> DEFINE_PROP_UINT16("num-threads", VHostBlk, conf.num_threads, 1), >> DEFINE_PROP_BIT64("flush", VHostBlk, host_features, >> VIRTIO_BLK_F_FLUSH, true), >> -/* Discard not yet implemented in kernel module */ >> DEFINE_PROP_BIT64("discard", VHostBlk, host_features, >> VIRTIO_BLK_F_DISCARD, false), >> DEFINE_PROP_BIT64("write-zeroes", VHostBlk, host_features, > Summary: (1) and (2) are the advertised values: the maximum is 4096 > times what dm-qcow2 takes per discard, and the alignment is finer than > its granularity. (3) affects migration. (4)-(5) are nits.