qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] 9pfs: iounit cleanup
@ 2021-09-27 15:44 Christian Schoenebeck
  2021-09-27 15:45 ` [PATCH 1/2] 9pfs: deduplicate iounit code Christian Schoenebeck
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Christian Schoenebeck @ 2021-09-27 15:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Philippe Mathieu-Daudé

Two pure refactoring code cleanup patches regarding iounit calculation, no
behaviour change.

Christian Schoenebeck (2):
  9pfs: deduplicate iounit code
  9pfs: simplify blksize_to_iounit()

 hw/9pfs/9p.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

-- 
2.20.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] 9pfs: deduplicate iounit code
  2021-09-27 15:44 [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
@ 2021-09-27 15:45 ` Christian Schoenebeck
  2021-09-27 16:27   ` Greg Kurz
  2021-09-27 15:50 ` [PATCH 2/2] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
  2021-09-28 11:53 ` [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
  2 siblings, 1 reply; 9+ messages in thread
From: Christian Schoenebeck @ 2021-09-27 15:45 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Philippe Mathieu-Daudé

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>
---
 hw/9pfs/9p.c | 42 ++++++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 22 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 708b030474..c65584173a 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1262,18 +1262,26 @@ 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)
+/**
+ * Convert host filesystem's block size into an appropriate block size for
+ * 9p client (guest OS side). The value returned suggests an "optimum" block
+ * size for 9p I/O, i.e. to maximize performance.
+ *
+ * @pdu: 9p client request
+ * @blksize: host filesystem's block size
+ */
+static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
 {
     int32_t iounit = 0;
     V9fsState *s = pdu->s;
 
     /*
-     * iounit should be multiples of st_blksize (host filesystem block size)
+     * iounit should be multiples of 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 (blksize) {
+        iounit = blksize;
+        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
     }
     if (!iounit) {
         iounit = s->msize - P9_IOHDRSZ;
@@ -1281,6 +1289,11 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf)
     return iounit;
 }
 
+static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf)
+{
+    return blksize_to_iounit(pdu, stbuf->st_blksize);
+}
+
 static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf,
                                 V9fsStatDotl *v9lstat)
 {
@@ -1899,23 +1912,8 @@ out_nofid:
 static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
 {
     struct statfs stbuf;
-    int32_t iounit = 0;
-    V9fsState *s = pdu->s;
-
-    /*
-     * iounit should be multiples of f_bsize (host filesystem block size
-     * and as well as less than (client msize - P9_IOHDRSZ))
-     */
-    if (!v9fs_co_statfs(pdu, path, &stbuf)) {
-        if (stbuf.f_bsize) {
-            iounit = stbuf.f_bsize;
-            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
-        }
-    }
-    if (!iounit) {
-        iounit = s->msize - P9_IOHDRSZ;
-    }
-    return iounit;
+    int err = v9fs_co_statfs(pdu, path, &stbuf);
+    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
 }
 
 static void coroutine_fn v9fs_open(void *opaque)
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/2] 9pfs: simplify blksize_to_iounit()
  2021-09-27 15:44 [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
  2021-09-27 15:45 ` [PATCH 1/2] 9pfs: deduplicate iounit code Christian Schoenebeck
@ 2021-09-27 15:50 ` Christian Schoenebeck
  2021-09-27 16:28   ` Greg Kurz
  2021-09-27 17:53   ` Philippe Mathieu-Daudé
  2021-09-28 11:53 ` [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
  2 siblings, 2 replies; 9+ messages in thread
From: Christian Schoenebeck @ 2021-09-27 15:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Philippe Mathieu-Daudé

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>
---
 hw/9pfs/9p.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index c65584173a..29cc19c90a 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1280,8 +1280,7 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
      * as well as less than (client msize - P9_IOHDRSZ)
      */
     if (blksize) {
-        iounit = blksize;
-        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
+        iounit = QEMU_ALIGN_DOWN(s->msize - P9_IOHDRSZ, blksize);
     }
     if (!iounit) {
         iounit = s->msize - P9_IOHDRSZ;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] 9pfs: deduplicate iounit code
  2021-09-27 15:45 ` [PATCH 1/2] 9pfs: deduplicate iounit code Christian Schoenebeck
@ 2021-09-27 16:27   ` Greg Kurz
  2021-09-27 16:50     ` Christian Schoenebeck
  0 siblings, 1 reply; 9+ messages in thread
From: Greg Kurz @ 2021-09-27 16:27 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: Philippe Mathieu-Daudé, qemu-devel

On Mon, 27 Sep 2021 17:45:00 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> 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>
> ---
>  hw/9pfs/9p.c | 42 ++++++++++++++++++++----------------------
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 708b030474..c65584173a 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -1262,18 +1262,26 @@ 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)
> +/**
> + * Convert host filesystem's block size into an appropriate block size for
> + * 9p client (guest OS side). The value returned suggests an "optimum" block
> + * size for 9p I/O, i.e. to maximize performance.
> + *
> + * @pdu: 9p client request
> + * @blksize: host filesystem's block size
> + */
> +static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
>  {
>      int32_t iounit = 0;
>      V9fsState *s = pdu->s;
>  
>      /*
> -     * iounit should be multiples of st_blksize (host filesystem block size)
> +     * iounit should be multiples of 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 (blksize) {
> +        iounit = blksize;
> +        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
>      }
>      if (!iounit) {
>          iounit = s->msize - P9_IOHDRSZ;
> @@ -1281,6 +1289,11 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf)
>      return iounit;
>  }
>  
> +static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat *stbuf)
> +{
> +    return blksize_to_iounit(pdu, stbuf->st_blksize);
> +}
> +
>  static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf,
>                                  V9fsStatDotl *v9lstat)
>  {
> @@ -1899,23 +1912,8 @@ out_nofid:
>  static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
>  {
>      struct statfs stbuf;
> -    int32_t iounit = 0;
> -    V9fsState *s = pdu->s;
> -
> -    /*
> -     * iounit should be multiples of f_bsize (host filesystem block size
> -     * and as well as less than (client msize - P9_IOHDRSZ))
> -     */
> -    if (!v9fs_co_statfs(pdu, path, &stbuf)) {
> -        if (stbuf.f_bsize) {
> -            iounit = stbuf.f_bsize;
> -            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
> -        }
> -    }
> -    if (!iounit) {
> -        iounit = s->msize - P9_IOHDRSZ;
> -    }
> -    return iounit;
> +    int err = v9fs_co_statfs(pdu, path, &stbuf);

It is usually preferred to leave a blank line between declarations
and statements for easier reading. It isn't mandated in the coding
style but Markus consistently asks for it :-) Maybe you can fix
that before pushing to 9p.next ?

Reviewed-by: Greg Kurz <groug@kaod.org>

> +    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
>  }
>  
>  static void coroutine_fn v9fs_open(void *opaque)



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] 9pfs: simplify blksize_to_iounit()
  2021-09-27 15:50 ` [PATCH 2/2] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
@ 2021-09-27 16:28   ` Greg Kurz
  2021-09-27 17:53   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 9+ messages in thread
From: Greg Kurz @ 2021-09-27 16:28 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: Philippe Mathieu-Daudé, qemu-devel

On Mon, 27 Sep 2021 17:50:36 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> 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>

>  hw/9pfs/9p.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index c65584173a..29cc19c90a 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -1280,8 +1280,7 @@ static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
>       * as well as less than (client msize - P9_IOHDRSZ)
>       */
>      if (blksize) {
> -        iounit = blksize;
> -        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
> +        iounit = QEMU_ALIGN_DOWN(s->msize - P9_IOHDRSZ, blksize);
>      }
>      if (!iounit) {
>          iounit = s->msize - P9_IOHDRSZ;



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] 9pfs: deduplicate iounit code
  2021-09-27 16:27   ` Greg Kurz
@ 2021-09-27 16:50     ` Christian Schoenebeck
  2021-09-27 17:30       ` Greg Kurz
  0 siblings, 1 reply; 9+ messages in thread
From: Christian Schoenebeck @ 2021-09-27 16:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Philippe Mathieu-Daudé

On Montag, 27. September 2021 18:27:59 CEST Greg Kurz wrote:
> On Mon, 27 Sep 2021 17:45:00 +0200
> 
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > 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>
> > ---
> > 
> >  hw/9pfs/9p.c | 42 ++++++++++++++++++++----------------------
> >  1 file changed, 20 insertions(+), 22 deletions(-)
> > 
> > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > index 708b030474..c65584173a 100644
> > --- a/hw/9pfs/9p.c
> > +++ b/hw/9pfs/9p.c
> > @@ -1262,18 +1262,26 @@ 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) +/**
> > + * Convert host filesystem's block size into an appropriate block size
> > for
> > + * 9p client (guest OS side). The value returned suggests an "optimum"
> > block + * size for 9p I/O, i.e. to maximize performance.
> > + *
> > + * @pdu: 9p client request
> > + * @blksize: host filesystem's block size
> > + */
> > +static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
> > 
> >  {
> >  
> >      int32_t iounit = 0;
> >      V9fsState *s = pdu->s;
> >      
> >      /*
> > 
> > -     * iounit should be multiples of st_blksize (host filesystem block
> > size) +     * iounit should be multiples of 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 (blksize) {
> > +        iounit = blksize;
> > +        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
> > 
> >      }
> >      if (!iounit) {
> >      
> >          iounit = s->msize - P9_IOHDRSZ;
> > 
> > @@ -1281,6 +1289,11 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu,
> > const struct stat *stbuf)> 
> >      return iounit;
> >  
> >  }
> > 
> > +static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat
> > *stbuf) +{
> > +    return blksize_to_iounit(pdu, stbuf->st_blksize);
> > +}
> > +
> > 
> >  static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf,
> >  
> >                                  V9fsStatDotl *v9lstat)
> >  
> >  {
> > 
> > @@ -1899,23 +1912,8 @@ out_nofid:
> >  static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
> >  {
> >  
> >      struct statfs stbuf;
> > 
> > -    int32_t iounit = 0;
> > -    V9fsState *s = pdu->s;
> > -
> > -    /*
> > -     * iounit should be multiples of f_bsize (host filesystem block size
> > -     * and as well as less than (client msize - P9_IOHDRSZ))
> > -     */
> > -    if (!v9fs_co_statfs(pdu, path, &stbuf)) {
> > -        if (stbuf.f_bsize) {
> > -            iounit = stbuf.f_bsize;
> > -            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
> > -        }
> > -    }
> > -    if (!iounit) {
> > -        iounit = s->msize - P9_IOHDRSZ;
> > -    }
> > -    return iounit;
> > +    int err = v9fs_co_statfs(pdu, path, &stbuf);
> 
> It is usually preferred to leave a blank line between declarations
> and statements for easier reading. It isn't mandated in the coding
> style but Markus consistently asks for it :-) Maybe you can fix
> that before pushing to 9p.next ?

In general: I adapt to whatever code style is preferred.

I actually did run (like usual) scripts/checkpatch.pl and it did not complain.

So you mean it is preferred to split up declaration and definition due to the 
function call involved? I.e. precisely:

static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
{
    struct statfs stbuf;
    int err;

    err = v9fs_co_statfs(pdu, path, &stbuf);
    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
}

or rather :) ...

static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
{
    struct statfs stbuf;
    int err = v9fs_co_statfs(pdu, path, &stbuf);

    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
}

We actually have mixed declaration/definition all over the place.

> 
> Reviewed-by: Greg Kurz <groug@kaod.org>
> 
> > +    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
> > 
> >  }
> >  
> >  static void coroutine_fn v9fs_open(void *opaque)




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] 9pfs: deduplicate iounit code
  2021-09-27 16:50     ` Christian Schoenebeck
@ 2021-09-27 17:30       ` Greg Kurz
  0 siblings, 0 replies; 9+ messages in thread
From: Greg Kurz @ 2021-09-27 17:30 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: Philippe Mathieu-Daudé, qemu-devel

On Mon, 27 Sep 2021 18:50:12 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Montag, 27. September 2021 18:27:59 CEST Greg Kurz wrote:
> > On Mon, 27 Sep 2021 17:45:00 +0200
> > 
> > Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > > 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>
> > > ---
> > > 
> > >  hw/9pfs/9p.c | 42 ++++++++++++++++++++----------------------
> > >  1 file changed, 20 insertions(+), 22 deletions(-)
> > > 
> > > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> > > index 708b030474..c65584173a 100644
> > > --- a/hw/9pfs/9p.c
> > > +++ b/hw/9pfs/9p.c
> > > @@ -1262,18 +1262,26 @@ 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) +/**
> > > + * Convert host filesystem's block size into an appropriate block size
> > > for
> > > + * 9p client (guest OS side). The value returned suggests an "optimum"
> > > block + * size for 9p I/O, i.e. to maximize performance.
> > > + *
> > > + * @pdu: 9p client request
> > > + * @blksize: host filesystem's block size
> > > + */
> > > +static int32_t blksize_to_iounit(const V9fsPDU *pdu, int32_t blksize)
> > > 
> > >  {
> > >  
> > >      int32_t iounit = 0;
> > >      V9fsState *s = pdu->s;
> > >      
> > >      /*
> > > 
> > > -     * iounit should be multiples of st_blksize (host filesystem block
> > > size) +     * iounit should be multiples of 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 (blksize) {
> > > +        iounit = blksize;
> > > +        iounit *= (s->msize - P9_IOHDRSZ) / blksize;
> > > 
> > >      }
> > >      if (!iounit) {
> > >      
> > >          iounit = s->msize - P9_IOHDRSZ;
> > > 
> > > @@ -1281,6 +1289,11 @@ static int32_t stat_to_iounit(const V9fsPDU *pdu,
> > > const struct stat *stbuf)> 
> > >      return iounit;
> > >  
> > >  }
> > > 
> > > +static int32_t stat_to_iounit(const V9fsPDU *pdu, const struct stat
> > > *stbuf) +{
> > > +    return blksize_to_iounit(pdu, stbuf->st_blksize);
> > > +}
> > > +
> > > 
> > >  static int stat_to_v9stat_dotl(V9fsPDU *pdu, const struct stat *stbuf,
> > >  
> > >                                  V9fsStatDotl *v9lstat)
> > >  
> > >  {
> > > 
> > > @@ -1899,23 +1912,8 @@ out_nofid:
> > >  static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
> > >  {
> > >  
> > >      struct statfs stbuf;
> > > 
> > > -    int32_t iounit = 0;
> > > -    V9fsState *s = pdu->s;
> > > -
> > > -    /*
> > > -     * iounit should be multiples of f_bsize (host filesystem block size
> > > -     * and as well as less than (client msize - P9_IOHDRSZ))
> > > -     */
> > > -    if (!v9fs_co_statfs(pdu, path, &stbuf)) {
> > > -        if (stbuf.f_bsize) {
> > > -            iounit = stbuf.f_bsize;
> > > -            iounit *= (s->msize - P9_IOHDRSZ) / stbuf.f_bsize;
> > > -        }
> > > -    }
> > > -    if (!iounit) {
> > > -        iounit = s->msize - P9_IOHDRSZ;
> > > -    }
> > > -    return iounit;
> > > +    int err = v9fs_co_statfs(pdu, path, &stbuf);
> > 
> > It is usually preferred to leave a blank line between declarations
> > and statements for easier reading. It isn't mandated in the coding
> > style but Markus consistently asks for it :-) Maybe you can fix
> > that before pushing to 9p.next ?
> 
> In general: I adapt to whatever code style is preferred.
> 
> I actually did run (like usual) scripts/checkpatch.pl and it did not complain.
> 

Yes, this isn't enforced nor checked.

> So you mean it is preferred to split up declaration and definition due to the 
> function call involved? I.e. precisely:
> 

Not splitting declaration and definitions but rather the declarations
from the actual code.

> static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
> {
>     struct statfs stbuf;
>     int err;
> 
>     err = v9fs_co_statfs(pdu, path, &stbuf);
>     return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
> }
> 
> or rather :) ...
> 
> static int32_t coroutine_fn get_iounit(V9fsPDU *pdu, V9fsPath *path)
> {
>     struct statfs stbuf;
>     int err = v9fs_co_statfs(pdu, path, &stbuf);
> 
>     return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
> }
> 
> We actually have mixed declaration/definition all over the place.
> 

It is okay to have mixed declarations/definitions. Second one is fine :)

> > 
> > Reviewed-by: Greg Kurz <groug@kaod.org>
> > 
> > > +    return blksize_to_iounit(pdu, (err >= 0) ? stbuf.f_bsize : 0);
> > > 
> > >  }
> > >  
> > >  static void coroutine_fn v9fs_open(void *opaque)
> 
> 



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/2] 9pfs: simplify blksize_to_iounit()
  2021-09-27 15:50 ` [PATCH 2/2] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
  2021-09-27 16:28   ` Greg Kurz
@ 2021-09-27 17:53   ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-27 17:53 UTC (permalink / raw)
  To: Christian Schoenebeck, qemu-devel; +Cc: Greg Kurz

On 9/27/21 17:50, Christian Schoenebeck wrote:
> 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>
> ---
>  hw/9pfs/9p.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] 9pfs: iounit cleanup
  2021-09-27 15:44 [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
  2021-09-27 15:45 ` [PATCH 1/2] 9pfs: deduplicate iounit code Christian Schoenebeck
  2021-09-27 15:50 ` [PATCH 2/2] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
@ 2021-09-28 11:53 ` Christian Schoenebeck
  2 siblings, 0 replies; 9+ messages in thread
From: Christian Schoenebeck @ 2021-09-28 11:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Greg Kurz, Philippe Mathieu-Daudé

On Montag, 27. September 2021 17:44:59 CEST Christian Schoenebeck wrote:
> Two pure refactoring code cleanup patches regarding iounit calculation, no
> behaviour change.
> 
> Christian Schoenebeck (2):
>   9pfs: deduplicate iounit code
>   9pfs: simplify blksize_to_iounit()
> 
>  hw/9pfs/9p.c | 41 +++++++++++++++++++----------------------
>  1 file changed, 19 insertions(+), 22 deletions(-)

Queued on 9p.next:
https://github.com/cschoenebeck/qemu/commits/9p.next

Thanks!

Best regards,
Christian Schoenebeck




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-09-28 11:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-27 15:44 [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck
2021-09-27 15:45 ` [PATCH 1/2] 9pfs: deduplicate iounit code Christian Schoenebeck
2021-09-27 16:27   ` Greg Kurz
2021-09-27 16:50     ` Christian Schoenebeck
2021-09-27 17:30       ` Greg Kurz
2021-09-27 15:50 ` [PATCH 2/2] 9pfs: simplify blksize_to_iounit() Christian Schoenebeck
2021-09-27 16:28   ` Greg Kurz
2021-09-27 17:53   ` Philippe Mathieu-Daudé
2021-09-28 11:53 ` [PATCH 0/2] 9pfs: iounit cleanup Christian Schoenebeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).