All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>
Subject: [PULL 1/8] 9pfs: fix wrong I/O block size in Rgetattr
Date: Wed, 27 Oct 2021 15:18:33 +0200	[thread overview]
Message-ID: <669ced09b3b6070d478acce51810591b78ab0ccd.1635340713.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1635340713.git.qemu_oss@crudebyte.com>

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 <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <E1mT2Js-0000DW-OH@lizzy.crudebyte.com>
---
 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 */
 
 
+static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf)
+{
+    int32_t iounit = 0;
+    V9fsState *s = 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 = stbuf->st_blksize;
+        iounit *= (s->msize - P9_IOHDRSZ) / stbuf->st_blksize;
+    }
+    if (!iounit) {
+        iounit = 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 struct stat *stbuf,
     v9lstat->st_gid = stbuf->st_gid;
     v9lstat->st_rdev = stbuf->st_rdev;
     v9lstat->st_size = stbuf->st_size;
-    v9lstat->st_blksize = stbuf->st_blksize;
+    v9lstat->st_blksize = stat_to_iounit(pdu, stbuf);
     v9lstat->st_blocks = stbuf->st_blocks;
     v9lstat->st_atime_sec = stbuf->st_atime;
     v9lstat->st_atime_nsec = stbuf->st_atim.tv_nsec;
-- 
2.20.1



  parent reply	other threads:[~2021-10-27 14:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27 13:18 [PULL 0/8] 9p queue 2021-10-27 Christian Schoenebeck
2021-10-27 13:18 ` [PULL 4/8] 9pfs: introduce P9Array Christian Schoenebeck
2021-10-27 13:18 ` [PULL 2/8] 9pfs: deduplicate iounit code Christian Schoenebeck
2021-10-27 13:18 ` [PULL 5/8] fsdev/p9array.h: check scalar type in P9ARRAY_NEW() Christian Schoenebeck
2021-10-27 13:18 ` [PULL 7/8] 9pfs: make V9fsPath usable via P9Array API Christian Schoenebeck
2021-10-27 13:18 ` [PULL 3/8] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
2021-10-27 13:18 ` [PULL 6/8] 9pfs: make V9fsString usable via P9Array API Christian Schoenebeck
2021-10-27 13:18 ` Christian Schoenebeck [this message]
2021-10-27 13:18 ` [PULL 8/8] 9pfs: use P9Array in v9fs_walk() Christian Schoenebeck
2021-10-27 14:05 ` [PULL 0/8] 9p queue 2021-10-27 Christian Schoenebeck
2021-10-27 15:36   ` Philippe Mathieu-Daudé
2021-10-27 16:21     ` Christian Schoenebeck
2021-10-27 16:48       ` Philippe Mathieu-Daudé
2021-10-27 17:29         ` Christian Schoenebeck
2021-10-27 18:11           ` Philippe Mathieu-Daudé
2021-10-27 18:44           ` Richard Henderson
2021-10-28 12:03             ` Christian Schoenebeck
2021-10-27 16:01   ` Greg Kurz
2021-10-27 21:03 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=669ced09b3b6070d478acce51810591b78ab0ccd.1635340713.git.qemu_oss@crudebyte.com \
    --to=qemu_oss@crudebyte.com \
    --cc=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.