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 X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8808C433FE for ; Thu, 23 Sep 2021 12:42:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B3AD61038 for ; Thu, 23 Sep 2021 12:42:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4B3AD61038 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54026 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTO37-0003WF-3u for qemu-devel@archiver.kernel.org; Thu, 23 Sep 2021 08:42:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTNzS-0001i4-O7 for qemu-devel@nongnu.org; Thu, 23 Sep 2021 08:38:15 -0400 Received: from kylie.crudebyte.com ([5.189.157.229]:39119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTNzK-0003Yc-BV for qemu-devel@nongnu.org; Thu, 23 Sep 2021 08:38:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=TH4iQRR0u8Oa6z7DwnnKpz/2YJ6JevzBianeSDfHqPo=; b=AFO+xCgSlqSIlv9+lvznT1gBAQ WfGPm427K881OU4vVIj6yPIxPhfFgW+G78X6x7+eF7bU/gQqn8THE5WCn/vovrPUUEAa8MlNWe28S KpUO0OGIUONRoDStxh2vM0mVkjmyFGR0mhidkOovPhJG8dRGW7Pg0XS7S3YilwnodqbO63EdXT3ky SzYVyY7FQZ7IhVBgohf90YaFDmEhV+mo9yiaXuZpUW2Vx4hdKtAgaBeOgOZ3dkJ+y+HreQ9Aw71eu 72VKMNAvXUiIdKfW4BOKqRK1g1dTE4yfhVj31BBPl2WcBcfHczk73axHNKzoHuT45tgh9TEDprJ40 HynMrko35q18Md2hyTIVJLTMMhpC2wBgKfW914SwBkrXmGuY5Ee5ikj0c4aow4bcXMoKkVkZNeq8B csQX8+S2KAMTjHCA5XsMiyfgiXlHG0YK7UQj28uwpNso/bMuNCn981ooYGTMLzoYAC7Itt1xO+x6f pMHOOV2htnc+EFW7b+ucdSLNQ8l+CgIezr8ABX3cWqDun1pczhRIOTLVQJ7penlN1P9Jg/bFgpSmo 0dFoMy3SQ76eljxP7shjq9vB6pF9GZbTqtr4lptI/8lEe0x2rum9RPQkFO2t6bdkIGOCeo0UVqHov fjozPdhn0E3mCVyjmFuV7ktsmV75pEO8vim/vKee8=; From: Christian Schoenebeck To: qemu-devel@nongnu.org Cc: Greg Kurz , Philippe =?ISO-8859-1?Q?Mathieu=2DDaud=E9?= Subject: Re: [PATCH] 9pfs: fix wrong I/O block size in Rgetattr Date: Thu, 23 Sep 2021 14:38:02 +0200 Message-ID: <3381432.ND75bl0XlW@silver> In-Reply-To: <20210923104058.0c159390@bahia.huguette> References: <5479323.DnaQ8grZgu@silver> <20210923104058.0c159390@bahia.huguette> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" Received-SPF: pass client-ip=5.189.157.229; envelope-from=qemu_oss@crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Donnerstag, 23. September 2021 10:40:58 CEST Greg Kurz wrote: > On Wed, 22 Sep 2021 17:55:02 +0200 >=20 > Christian Schoenebeck wrote: > > On Mittwoch, 22. September 2021 17:42:08 CEST Philippe Mathieu-Daud=E9= =20 wrote: > > > On 9/22/21 15:13, Christian Schoenebeck wrote: > > > > 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. > > > >=20 > > > > 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. > > > >=20 > > > > This patch adds stat_to_iounit() with a similar approach as the > > > > existing get_iounit() function. > > > >=20 > > > > Signed-off-by: Christian Schoenebeck > > > > --- > > > >=20 > > > > hw/9pfs/9p.c | 21 ++++++++++++++++++++- > > > > 1 file changed, 20 insertions(+), 1 deletion(-) > > > >=20 > > > > 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(V9fsP= DU > > > > *pdu, V9fsPath *path,> > > > >=20 > > > > #define P9_STATS_ALL 0x00003fffULL /* Mask for All fiel= ds > > > > above */> > > > >=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 > > > > size) + * 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; > > >=20 > > > Is that: > > > iounit =3D QEMU_ALIGN_DOWN(s->msize - P9_IOHDRSZ, stbuf->st_blksiz= e); > > >=20 > > > ? > >=20 > > Yes it is, thanks for the hint! :) > >=20 > > I actually just took the equivalent, already existing code from > > get_iounit(): > > https://github.com/qemu/qemu/blob/2c3e83f92d93fbab071b8a96b8ab769b01902= 47 > > 5/hw/9pfs/9p.c#L1880 > >=20 > > Would it be OK to do that subsequently with cleanup patches? My plan was > > to > > first address this with one patch, and addressing the cleanup issues > > separately later on, because this patch is required for testing the > > following kernel patches: > > https://lore.kernel.org/netdev/cover.1632156835.git.linux_oss@crudebyte= =2Eco > > m/ > >=20 > > And I wanted to keep things simple by only requiring one patch on QEMU > > side > > for now. >=20 > Fair enough and you're the maintainer anyway so this is your > call. :-) >=20 > Subsequent cleanup would be to switch to QEMU_ALIGN_DOWN() like > Philippe suggested but also to consolidate the logic in a common > helper in order to avoid the code duplication. It will include code deduplication as well, yes. > The patch is correct and simple enough to be merged as is : >=20 > Reviewed-by: Greg Kurz Queued on 9p.next: https://github.com/cschoenebeck/qemu/commits/9p.next Thanks! > > > > + } > > > > + if (!iounit) { > > > > + iounit =3D s->msize - P9_IOHDRSZ; > > > > + } > > > > + return iounit; > > > > +} > > > > + > > > >=20 > > > > static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat > > > > *stbuf, > > > > =20 > > > > V9fsStatDotl *v9lstat) > > > > =20 > > > > { > > > >=20 > > > > @@ -1273,7 +1292,7 @@ static int stat_to_v9stat_dotl(V9fsPDU *pdu, > > > > const > > > > struct stat *stbuf,> > > > >=20 > > > > v9lstat->st_gid =3D stbuf->st_gid; > > > > v9lstat->st_rdev =3D stbuf->st_rdev; > > > > v9lstat->st_size =3D stbuf->st_size; > > > >=20 > > > > - v9lstat->st_blksize =3D stbuf->st_blksize; > > > > + v9lstat->st_blksize =3D stat_to_iounit(pdu, stbuf); > > > >=20 > > > > 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;