From nobody Sun Feb 8 20:48:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1632317583; cv=none; d=zohomail.com; s=zohoarc; b=QRDgSqoyOTXYyZA7fxmCe5Wo8DuRlaTcu1dxMoZBDSknz6qICakM2fRIxE1Sy9/G8QW3OshPngnF94b3RLfMxqy9OhiEgOyv6CEKZlKm/vgqNf5neLL/FdDuiF72v1O2hfyQ38kH7h9DzrYiaAF6FeBZab+rymzpdtbswTAXOUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632317583; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=nRFZd+9Y+ow9XihPsigGJGZpaZq5I4Y5DG6fI12NQXI=; b=oK9mCjn+cTTuDCu92WVujkL1ETzAoYeQBzbLwfE7EyMZdlIM1L/WsmxqN5inYkJaSB29pUWrd05aNqdBOIIHovaHFRH53rtEco0ZEYiI45iHaoW8JIylyxodcUZRjRP4BcttJC4R2tT3poDBnWd3Rth/amuyYsKlJQ/9bA6chnY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163231758315495.37259650957151; Wed, 22 Sep 2021 06:33:03 -0700 (PDT) Received: from localhost ([::1]:52364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mT2Mv-0007Tb-PH for importer@patchew.org; Wed, 22 Sep 2021 09:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <65ea3c92bcdcf0f6c97b2751adc29eb85505ecc6@lizzy.crudebyte.com>) id 1mT2Kw-0006cl-KI for qemu-devel@nongnu.org; Wed, 22 Sep 2021 09:30:58 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <65ea3c92bcdcf0f6c97b2751adc29eb85505ecc6@lizzy.crudebyte.com>) id 1mT2Kt-0007vM-NE for qemu-devel@nongnu.org; Wed, 22 Sep 2021 09:30:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Message-Id:Cc:To:Subject:Date:From:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Content-ID: Content-Description; bh=nRFZd+9Y+ow9XihPsigGJGZpaZq5I4Y5DG6fI12NQXI=; b=PhmJU IYhMTyIhVhqeJld/mBh/Vab7WEBCkxC1Ru1FHcZ119wwaZzHVknUuCfAVIj5VuHrKYz8IVgQ7ZROi XoBW4ETwsThSPMiBS02Pbm0ORBE8FiksNEugOhn0YKapR7O44mAp9Z0RvxFQczxB1GmWI16VHklUX Afjz1sncREqICbZ28WeTh3i7mAQ1qxKKy0VYVTIXPzdM+GC91ylzuZU0tylikGy9ymsgN14Bc4Ef1 eWSBQ3po7kv4buXIQFbUd297iZHrGR74G5hX5Mi4ciDoo712fBLSCzUeuBmD0/wP62SECaFVLJKvS LGEcY2eA2X45rSDY9ZhjWA9wHcpEQ==; From: Christian Schoenebeck Date: Wed, 22 Sep 2021 15:13:31 +0200 Subject: [PATCH] 9pfs: fix wrong I/O block size in Rgetattr To: qemu-devel@nongnu.org Cc: Greg Kurz Message-Id: Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=65ea3c92bcdcf0f6c97b2751adc29eb85505ecc6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1632317584308100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When client sent a 9p Tgetattr request then the wrong I/O block size value was returned by 9p server; instead of host file system's I/O block size it should rather return an I/O block size according to 9p session's 'msize' value, because the value returned to client should be an "optimum" block size for I/O (i.e. to maximize performance), it should not reflect the actual physical block size of the underlying storage media. The I/O block size of a host filesystem is typically 4k, so the value returned was far too low for good 9p I/O performance. This patch adds stat_to_iounit() with a similar approach as the existing get_iounit() function. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- hw/9pfs/9p.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c857b31321..708b030474 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1262,6 +1262,25 @@ static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu,= V9fsPath *path, #define P9_STATS_ALL 0x00003fffULL /* Mask for All fields above = */ =20 =20 +static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf) +{ + int32_t iounit =3D 0; + V9fsState *s =3D pdu->s; + + /* + * iounit should be multiples of st_blksize (host filesystem block siz= e) + * as well as less than (client msize - P9_IOHDRSZ) + */ + if (stbuf->st_blksize) { + iounit =3D stbuf->st_blksize; + iounit *=3D (s->msize - P9_IOHDRSZ) / stbuf->st_blksize; + } + if (!iounit) { + iounit =3D s->msize - P9_IOHDRSZ; + } + return iounit; +} + static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf, V9fsStatDotl *v9lstat) { @@ -1273,7 +1292,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, const st= ruct stat *stbuf, v9lstat->st_gid =3D stbuf->st_gid; v9lstat->st_rdev =3D stbuf->st_rdev; v9lstat->st_size =3D stbuf->st_size; - v9lstat->st_blksize =3D stbuf->st_blksize; + v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); v9lstat->st_blocks =3D stbuf->st_blocks; v9lstat->st_atime_sec =3D stbuf->st_atime; v9lstat->st_atime_nsec =3D stbuf->st_atim.tv_nsec; --=20 2.20.1