From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32837C61DB9 for ; Tue, 25 Aug 2026 20:59:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wyyE0-0001GL-RT; Tue, 25 Aug 2026 16:58:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wyyDw-0001DX-KO; Tue, 25 Aug 2026 16:58:24 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wyyDt-0003EF-5K; Tue, 25 Aug 2026 16:58:22 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 6C1614199B; Tue, 25 Aug 2026 20:58:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EC121F000E9; Tue, 25 Aug 2026 20:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1787691500; bh=elBDym+odsFk7BBWDv9UsTDx8JlrqI3ofGnXzRMCW5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=M+vUtakZ+ToseNb8BWQFoVxktN7GccaOuJUp1X5xbvK22rP02Vb497+FdV0eEmYlm POYb/yr+SAe1LJYLfrxdnknIpEKPmvRBonB22Owcmg5+iSq2f77AlCpALFBWjjL8D+ /ofycqujMAJGLce8p57eZvZy1nQVeJCqOZg3sY3U4tdLCDdFSMfAt8rYQtP9WXr8Nt 48DIAbMkuqDkl+G5qGR5lIbd8KVepZJegT4jlvDQJ+NiSWNXUwiv2je8xpfJVUA+TT XqZx4gIWDUQdmo1OBg66uJxpYfbDyNKCVFMNoFxdbajpMzdTigOf0DR0w/wcm9Jpt7 ByPoJUCfKQHeg== From: Niklas Cassel To: Stefan Hajnoczi , Kevin Wolf , Hanna Reitz Cc: Sam Li , Damien Le Moal , Niklas Cassel , qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 09/12] file-posix: base the zone append limit on the transfer limit Date: Tue, 25 Aug 2026 22:57:44 +0200 Message-ID: <20260825205748.679968-10-cassel@kernel.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825205748.679968-1-cassel@kernel.org> References: <20260825205748.679968-1-cassel@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=172.234.252.31; envelope-from=cassel@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The zone_append_max_bytes queue attribute is the largest REQ_OP_ZONE_APPEND that the device accepts, and Linux has no interface for issuing one from userspace: include/uapi has no such operation, and every submitter of REQ_OP_ZONE_APPEND is in the kernel. Userspace writes to a sequential zone with an ordinary write at the write pointer. That is what this driver does. raw_co_zone_append() substitutes the write pointer of the zone for the offset and hands the request to raw_co_prw(), which reaches handle_aiocb_rw_vector() and issues a plain pwritev(). The kernel never sees a zone append, so the attribute describes a limit on an operation that is never issued. Nor is it a limit that this driver runs into. The kernel splits a write that exceeds the transfer limit rather than refusing it, so a larger append succeeds: on a null_blk device whose zone_append_max_bytes is 130560, a 16 MiB append completes and advances the write pointer by 16 MiB. Reporting the attribute only understates what the driver can do, because Linux derives it as a minimum that already includes max_sectors and chunk_sectors. Report max_hw_transfer instead, the limit that governs the write the driver actually issues. There is no use in telling a guest that it may append more than the device carries in one command, and a frontend then does not have to reason about how this driver implements an append in order to bound the value it advertises. On a null_blk device with max_hw_sectors_kb of 127 and zone_append_max_bytes of 130560, virtio-blk reports 255 sectors before and after. Signed-off-by: Niklas Cassel --- block/file-posix.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index f267513a4e..e019cc3cd8 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1488,10 +1488,15 @@ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st, } bs->bl.nr_zones = ret; - ret = get_sysfs_long_val(st, "zone_append_max_bytes"); - if (ret > 0) { - bs->bl.max_append_sectors = ret >> BDRV_SECTOR_BITS; - } + /* + * raw_co_zone_append() carries out an append as an ordinary write at the + * write pointer, so the zone_append_max_bytes attribute, which bounds an + * operation that this driver never issues, does not apply. The kernel + * splits a write that is larger than the transfer limit rather than + * refusing it, but there is no use in telling a guest that it may append + * more than the device carries in one command. + */ + bs->bl.max_append_sectors = bs->bl.max_hw_transfer >> BDRV_SECTOR_BITS; ret = get_sysfs_long_val(st, "zone_write_granularity"); if (ret >= 0) { -- 2.55.0