From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazon11023081.outbound.protection.outlook.com [52.101.83.81]) by lore.virtuozzo.com (Postfix) with ESMTPS id 465EF8002A for ; Tue, 24 Nov 2026 15:34:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DvYlNdYjfN97ToP9KR1f45xzNrYbkma9KtATWsoCF9b321PODNLi5RUOeIVidwR5z1Kcp05c7y2cOEcVrgVb6H/P/WYExL2kbw1XLPmLkO5BqABr4f5mmbf8PofXJs74JZMFBJk/PR25u8++WzQjPpILLdKH0BpoiyLGqWrAhh4jupFkfa38y0COfe4lCAySAqvifuudSU0dDgCyv8rqux0GDaHuF3bXKgOU0zxzkYcs3MEKWaUBWq5fo/ff3uDlO6Xg/CxdELl939KnV5RSKZvO/eBorj5w3I89Zbi2mETCLDR1BgciCRda793FDT45kOudqV6bN0rygykB6PF66A== 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=nqbiDaSIYQWfvzNsWTe9+qgj5W9UmSRkXjiff99Hxx0=; b=ZKRgZ6sQpGIMdVJ+Rckfj5PfpWDXMx5CbvmIdCwp5yTcTS0hAPue9d7GyK4KKAmvlS3FZ4lfZa7riBqKcJKqIsLE9NcTUhRNdBLBqihu5itXVzPV9ZnzgJyszwg8a1TFHmkQq4hrKhfXOkfwTuDBJ7Cr7xP74+/tevyNZpRDCWFdDfMZq23fsOzE23s4uFAgZLgDbHlFU7UOqrr+I0c8MFPovNYAbKnFOnLlI1dnr0x+K0ed+iOZKoydDJJ49yf0rT38hSS5vP6WLTGMY+5+QhWUo87fiOySTlLdh9y3j+BuYHT0sS5cLdaN/amKxBTxAg50TQ61d28/34/2HYC3cQ== 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=nqbiDaSIYQWfvzNsWTe9+qgj5W9UmSRkXjiff99Hxx0=; b=OxivuE8UcYiIm0MHipLaCVDWK3Qp3xZO6JR0i25nWWonogpcv5peOHhTArzMsNFw7BrbDE+fT0SlDHKBDmTrMB7Jj6fV07QH3LzXod0KhDNXCwFOz81pmQUNBhCyeuM3KU7qXBpR0qjJjNHAH8dod2UtGRb7hBBEcCrrND5mCY7cS8Mmg/wVeRS5sLk3CM14XdnVbVm2nMKNkF0lTp8tq3Tzk9DuOR8n7BtXqZLY65jYAP6o+K2/0SEN/I0+nHmrLAI6Z/UudC/IwLYYZQ3rm1gCQ2nJ2HnRhFFe4xv4eyF+Asmw4CsDLoVHo44NCbooa6eZdDwQk6U3WH+bly0vbQ== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from VI0PR08MB10656.eurprd08.prod.outlook.com (2603:10a6:800:20a::12) by MI7PR08MB763212.eurprd08.prod.outlook.com (2603:10a6:290:100::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.639.13; Tue, 24 Nov 2026 15:34:19 +0000 Received: from VI0PR08MB10656.eurprd08.prod.outlook.com ([fe80::4e37:b189:ddcd:3dd8]) by VI0PR08MB10656.eurprd08.prod.outlook.com ([fe80::4e37:b189:ddcd:3dd8%4]) with mapi id 15.21.0639.012; Tue, 24 Nov 2026 15:34:19 +0000 Message-ID: <7db31ef0-81d7-4128-b969-105a349b90ba@virtuozzo.com> Date: Tue, 24 Nov 2026 17:34:17 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH hci-8.2 v3] vhost-blk: implement the write-zeroes property To: Alexander Ivanov , andrey.zhadchenko@virtuozzo.com Cc: svt-core@virtuozzo.com References: <20261124134005.508103-1-alexander.ivanov@virtuozzo.com> Content-Language: en-US From: Andrey Drobyshev In-Reply-To: <20261124134005.508103-1-alexander.ivanov@virtuozzo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: GV0P278CA0058.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:2a::9) To VI0PR08MB10656.eurprd08.prod.outlook.com (2603:10a6:800:20a::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI0PR08MB10656:EE_|MI7PR08MB763212:EE_ X-MS-Office365-Filtering-Correlation-Id: b6d2a294-01a2-4e52-d68f-08df4a406805 X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr List-Id: svt-core@virtuozzo.com X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|23010399003|18002099003|22082099003|5113699003|56012099006|261026121527099003|261021121427099003|261102123227099003|261026140227099003|261028144727099003|261009223027099003|261022105027099003|5023799004|10067099003; X-Microsoft-Antispam-Message-Info: gBx2MKDz6AAPGFjr2vio1btNdK3zfvo0ufRtCwwkJjIDYi/qW+sZsgei1EzeeZW0UetY9Guu4FaTvRoVvqIP8aV7OY4mbRY8yNmGERBY90WH/re/4TCikBvM/6BGSdmbWbJALXGyGLgrm+Ja1vy3L4Eu+lIuw+PvMOLTsg8CX/KWgYnUWJqKOaFCo6jWM58g2WQpqzK0oGjxeeZOBElEITVKa1cgpV+0UWdiQVRvJL+DNw4h7JWHwOJa7YWPsyYA5VCP36JYw7UXFYfH79CZvO54eXzPRzWanwle/7jsZwK6RSqfN/zVjCpkAxzjlxHtM9Vlah1uk8zfAQF+CR/8cjF9ULpNOxeTyRe4SYUKaZv77s0FJwML+ETRyKdQpPKZ2iXsZIzrUFgdfwagMSeTRsGbQiw3Sn/rj+qF6zq69sK3YsSA5c9MDFPsB/oJT+tFcL/wMv4g3IHf9IUcY2JUSRwsAJ3fHsLq2W/I07VlMrkz4jW3EljTDz9R9eupJZkFcEE2RKMRiclsn6cYyMBlXFBvzZ8fNP2T/tjhzdTP+wyclOaJWoVBmH8VRBmvzJ7n9DUsK7yuz+/Kd9ZSfsYemDYMPT0vl0rd/FtWlVdMxKL2NoZ7jJjjLimCbVOs2ZcwT06/QUxzw3FBH8geV2zXVgUUZXDcW4qH1ixTntOguVI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI0PR08MB10656.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(23010399003)(18002099003)(22082099003)(5113699003)(56012099006)(261026121527099003)(261021121427099003)(261102123227099003)(261026140227099003)(261028144727099003)(261009223027099003)(261022105027099003)(5023799004)(10067099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WXFsdFJzMzZmbmw3eG1VM3owcnhFZGZpK0dFeXZFSi9XaWFnZSt3SHZzUURS?= =?utf-8?B?WFdyNkpTT0EwL0JUdGNYcTAwWU1WR1NnZEdXNGZlV2dBQ2pvMm1oOFdUS1I2?= =?utf-8?B?NUMyNE0rb09lZGJNakpCbHlJaGFBTm8xMTQ3SDluVjdqdFhPVFk4eGx1SThR?= =?utf-8?B?K0tQdWZML2Y0eXpJbE82bldnRDVBTXppQU9WMmRQVGdKSEUvc2hGNHBQbmhP?= =?utf-8?B?RVh4V0ZsT0oydHVIdHZRa0lNRTFQanhwSHNNVmFTK1JRVklFRUtmUmROeXVR?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Uk3L1kwTGQ0Qm9ZTnEvRXBQZGgw?= =?utf-8?B?OVY5c2ROemZUM1dOS21pem9RL0ZJT0RTcUNGM3B3MWdEQWwrdTBianN2TEM2?= =?utf-8?B?QlUvRkg1WUlsMkpOVDIyWnZlWU1uVkRLaW1BTEs0U2FXS0JwbmVOdXNma1VS?= =?utf-8?B?VTI3ZS93T3IzOG40ektmbTlQRTdZV2hrMVpIMTdRS0dnOEc4eWNmMXlPUGRS?= =?utf-8?B?Sy9neDJIaFBNbkdDank3YWJyQ0NMNllFUlM3ZHo5anc1cERUTmh4dlM5NUJV?= =?utf-8?Q?FKoxS3qH6cPjeSz8=3D?= X-Auto-Response-Suppress: DR, OOF, AutoReply X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6d2a294-01a2-4e52-d68f-08df4a406805 X-MS-Exchange-CrossTenant-AuthSource: VI0PR08MB10656.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2026 15:34:19.4924 (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: 2XsUD4Gpl1gKw1aQzh25XgqTc3sY2cK4DZiNDJOaRTSGR58VcNRbAnNlWf71oaeqhwqptv1ZG5HSLrTndW9b+PTh/PICnSR7m6vUb1Kht04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MI7PR08MB763212 On 11/24/26 3:40 PM, Alexander Ivanov wrote: > vhost-blk in the kernel now handles VIRTIO_BLK_T_WRITE_ZEROES. It sends > each request to the backend as a single WRITE ZEROES bio and answers > VIRTIO_BLK_S_UNSUPP when the backend does not support WRITE ZEROES at > the time of the request, so the guest falls back to writing zeroes. > > With the write-zeroes property on, offer VIRTIO_BLK_F_WRITE_ZEROES and > set max_write_zeroes_sectors to the largest range one bio can carry, > rounded down to 64 KiB. The kernel fails a range not aligned to the > logical block size of the backend, and a constant keeps the guest-visible > limit the same on every host. Do not offer the feature for a read-only > device. > > Do not derive the feature or the limit from the WRITE ZEROES limit of > the backend. It changes while QEMU has the device open, e.g. when a dm > table is reloaded with a target that does not pass WRITE ZEROES through, > while the guest reads the config only at probe and the destination of a > migration or qemu-update must offer the features the guest has > negotiated. > > Fail realize if the property is on and the kernel does not offer the > feature. Masking it silently would make the guest ABI depend on the > host: a migration to a node with an older kernel would start the > destination without the feature and fail only in virtio_load(), after > RAM has been transferred. > > The property stays off by default. The first kernel version with the > support answered VIRTIO_BLK_S_IOERR for a backend without WRITE ZEROES: > do not turn the property on with it. > > https://virtuozzo.atlassian.net/browse/VSTOR-141684 > > Signed-off-by: Alexander Ivanov > --- > [...] I think this version is not good enough as well. Here we unconditionally advertise the WRITE_ZEROES feature bit - without any check whether actual backend (dm-qcow2) support the operation. We just rely on the s->dev.features having this bit - and it's always set. Proposal: what if we keep the sysfs check from v2 patch, but only use it as confirmation that backend supports the op, not as the value to advertise? Smth like: > if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_WRITE_ZEROES)) { > uint64_t bytes; > > if (!vhost_blk_get_write_zeroes_max_bytes(s->backend_rdev, &bytes, errp)) { > goto fail; > } > if (!bytes) { > error_setg(errp, "vhost-blk: '%s' does not support write zeroes", > s->conf.devpath); > goto fail; > } > } I.e. read value from sysfs but treat it as zero/non-zero (yes/no) value, because IIUC if WRITE_ZEROES is unsupported by the backend (as it's now with dm-qcow2) we'll read 0 from there. And then in blkcfg.max_write_zeroes_sectors we write the constant value as we do here in v3. There's of course still the issue of value dropping to 0 in runtime. If this ever happens, qemu-update will be broken. So we have to guarantee somehow our backend doesn't change this value on the fly. What do you think? Andrey