qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 669ced: 9pfs: fix wrong I/O block size in Rge


From: Richard Henderson
Subject: [Qemu-commits] [qemu/qemu] 669ced: 9pfs: fix wrong I/O block size in Rgetattr
Date: Wed, 27 Oct 2021 14:03:10 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 669ced09b3b6070d478acce51810591b78ab0ccd
      
https://github.com/qemu/qemu/commit/669ced09b3b6070d478acce51810591b78ab0ccd
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: fix wrong I/O block size in Rgetattr

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>


  Commit: b565bccb00afe8b73d529bbc3a38682996dac5c7
      
https://github.com/qemu/qemu/commit/b565bccb00afe8b73d529bbc3a38682996dac5c7
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: deduplicate iounit code

Remove redundant code that translates host fileystem's block
size into 9p client (guest side) block size.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: 
<129bb71d5119e61d335f1e3107e472e4beea223a.1632758315.git.qemu_oss@crudebyte.com>


  Commit: 04a7f9e55e0930b87805f7c97851eea4610e78fc
      
https://github.com/qemu/qemu/commit/04a7f9e55e0930b87805f7c97851eea4610e78fc
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: simplify blksize_to_iounit()

Use QEMU_ALIGN_DOWN() macro to reduce code and to make it
more human readable.

Suggested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: 
<b84eb324d2ebdcc6f9c442c97b5b4d01eecb4f43.1632758315.git.qemu_oss@crudebyte.com>


  Commit: 30e702abf6fa8a7f1e6ad11a75d6f3ab6fcb2155
      
https://github.com/qemu/qemu/commit/30e702abf6fa8a7f1e6ad11a75d6f3ab6fcb2155
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    A fsdev/p9array.h

  Log Message:
  -----------
  9pfs: introduce P9Array

Implements deep auto free of arrays while retaining common C-style
squared bracket access. Main purpose of this API is to get rid of
error prone individual array deallocation pathes in user code, i.e.
turning something like this:

  void doSomething(size_t n) {
      Foo *foos = malloc(n * sizeof(Foo));
      for (...) {
          foos[i].s = malloc(...);
          if (...) {
              goto out;
          }
      }
  out:
      if (...) {
          for (...) {
              /* deep deallocation */
              free(foos[i].s);
          }
          /* array deallocation */
          free(foos);
      }
  }

into something more simple and safer like:

  void doSomething(size_t n) {
      P9ARRAY_REF(Foo) foos = NULL;
      P9ARRAY_NEW(Foo, foos, n);
      for (...) {
          foos[i].s = malloc(...);
          if (...) {
              return; /* array auto freed here */
          }
      }
      /* array auto freed here */
  }

Unlike GArray, P9Array does not require special macros, function
calls or struct member dereferencing to access the individual array
elements:

  C-array = P9Array:   vs.  GArray:

  for (...) {           |   for (...) {
      ... = arr[i].m;   |       ... = g_array_index(arr, Foo, i).m;
      arr[i].m = ... ;  |       g_array_index(arr, Foo, i).m = ... ;
  }                     |   }

So existing C-style array code can be retained with only very little
changes; basically limited to replacing array allocation call and of
course removing individual array deallocation pathes.

In this initial version P9Array only supports the concept of unique
pointers, i.e. it does not support reference counting. The array (and
all dynamically allocated memory of individual array elements) is auto
freed once execution leaves the scope of the reference variable (unique
pointer) associated with the array.

Internally a flex array struct is used in combination with macros
spanned over a continuous memory space for both the array's meta data
(private) and the actual C-array user data (public):

  struct P9Array##scalar_type {
    size_t len;            /* private, hidden from user code */
    scalar_type first[];   /* public, directly exposed to user code */
  };

Which has the advantage that the compiler automatically takes care
about correct padding, alignment and overall size for all scalar data
types on all systems and that the user space exposed pointer can
directly be translated back and forth between user space C-array
pointer and internal P9Array struct whenever needed, in a type-safe
manner.

This header file is released under MIT license, to allow this file
being used in other C-projects as well. The common QEMU license
GPL2+ might have construed a conflict for other projects.

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: 
<a954ef47b5ac26085a16c5c2aec8695374e0424d.1633097129.git.qemu_oss@crudebyte.com>


  Commit: c0451f0bc4210d262268ff51c053a9277f20f862
      
https://github.com/qemu/qemu/commit/c0451f0bc4210d262268ff51c053a9277f20f862
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M fsdev/p9array.h

  Log Message:
  -----------
  fsdev/p9array.h: check scalar type in P9ARRAY_NEW()

Make sure at compile time that the scalar type of the array
requested to be created via P9ARRAY_NEW() matches the scalar
type of the passed auto reference variable (unique pointer).

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: 
<c1965e2a096835dc9e1d4d659dfb15d96755cbe0.1633097129.git.qemu_oss@crudebyte.com>


  Commit: 42bdeb04b6a4bf3e54f4d7f87193803268ba8255
      
https://github.com/qemu/qemu/commit/42bdeb04b6a4bf3e54f4d7f87193803268ba8255
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M fsdev/9p-marshal.c
    M fsdev/9p-marshal.h

  Log Message:
  -----------
  9pfs: make V9fsString usable via P9Array API

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: 
<ce9f7a0a63585dc27f4545c485109efbec1251da.1633097129.git.qemu_oss@crudebyte.com>


  Commit: cc82fde9c7b4b598907914896ee6942fa866258c
      
https://github.com/qemu/qemu/commit/cc82fde9c7b4b598907914896ee6942fa866258c
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M fsdev/file-op-9p.h
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: make V9fsPath usable via P9Array API

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: 
<79a0ddf8375f6c95f0565ef155a1bf1e9387664f.1633097129.git.qemu_oss@crudebyte.com>


  Commit: 7e985780aaab93d2c5be9b62d8d386568dfb071e
      
https://github.com/qemu/qemu/commit/7e985780aaab93d2c5be9b62d8d386568dfb071e
  Author: Christian Schoenebeck <qemu_oss@crudebyte.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M hw/9pfs/9p.c

  Log Message:
  -----------
  9pfs: use P9Array in v9fs_walk()

Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: 
<90c65d1c1ca11c1b434bb981b1fc7966f7711c8f.1633097129.git.qemu_oss@crudebyte.com>


  Commit: c52d69e7dbaaed0ffdef8125e79218672c30161d
      
https://github.com/qemu/qemu/commit/c52d69e7dbaaed0ffdef8125e79218672c30161d
  Author: Richard Henderson <richard.henderson@linaro.org>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M fsdev/9p-marshal.c
    M fsdev/9p-marshal.h
    M fsdev/file-op-9p.h
    A fsdev/p9array.h
    M hw/9pfs/9p.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/cschoenebeck/tags/pull-9p-20211027' 
into staging

9pfs: performance fix and cleanup

* First patch fixes suboptimal I/O performance on guest due to previously
  incorrect block size being transmitted to 9p client.

* Subsequent patches are cleanup ones intended to reduce code complexity.

* remotes/cschoenebeck/tags/pull-9p-20211027:
  9pfs: use P9Array in v9fs_walk()
  9pfs: make V9fsPath usable via P9Array API
  9pfs: make V9fsString usable via P9Array API
  fsdev/p9array.h: check scalar type in P9ARRAY_NEW()
  9pfs: introduce P9Array
  9pfs: simplify blksize_to_iounit()
  9pfs: deduplicate iounit code
  9pfs: fix wrong I/O block size in Rgetattr

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Compare: https://github.com/qemu/qemu/compare/5c49c6c241e5...c52d69e7dbaa



reply via email to

[Prev in Thread] Current Thread [Next in Thread]