All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
@ 2020-04-11  6:19 Catherine Ho
  2020-04-11  8:35 ` [PATCH v2] " Catherine Ho
  0 siblings, 1 reply; 5+ messages in thread
From: Catherine Ho @ 2020-04-11  6:19 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Stefan Hajnoczi, qemu-devel; +Cc: Catherine Ho

cache=none means to bypass host cache. So we can't remove O_DIRECT flag in
unconditionally in update_open_flags();

Signed-off-by: Catherine Ho <catherine.hecx@gmail.com>
---
 tools/virtiofsd/passthrough_ll.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 4c35c95..889e144 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1677,7 +1677,8 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t ino,
     fuse_reply_err(req, 0);
 }
 
-static void update_open_flags(int writeback, struct fuse_file_info *fi)
+static void update_open_flags(int writeback, int cache_mode,
+                              struct fuse_file_info *fi)
 {
     /*
      * With writeback cache, kernel may send read requests even
@@ -1702,10 +1703,13 @@ static void update_open_flags(int writeback, struct fuse_file_info *fi)
 
     /*
      * O_DIRECT in guest should not necessarily mean bypassing page
-     * cache on host as well. If somebody needs that behavior, it
-     * probably should be a configuration knob in daemon.
+     * cache on host as well. If cache=none, set the flag to O_DIRECT
      */
-    fi->flags &= ~O_DIRECT;
+    if (cache_mode == CACHE_NONE) {
+        fi->flags |= O_DIRECT;
+    } else {
+        fi->flags &= ~O_DIRECT;
+    }
 }
 
 static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
@@ -1737,7 +1741,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
         goto out;
     }
 
-    update_open_flags(lo->writeback, fi);
+    update_open_flags(lo->writeback, lo->cache, fi);
 
     fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
                 mode);
@@ -1947,7 +1951,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
     fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
              fi->flags);
 
-    update_open_flags(lo->writeback, fi);
+    update_open_flags(lo->writeback, lo->cache, fi);
 
     sprintf(buf, "%i", lo_fd(req, ino));
     fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
-- 
1.7.1



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

* [PATCH v2] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
  2020-04-11  6:19 [PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none Catherine Ho
@ 2020-04-11  8:35 ` Catherine Ho
  2020-04-21  1:55   ` Catherine Ho
  2020-04-30  8:35     ` [Virtio-fs] " Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Catherine Ho @ 2020-04-11  8:35 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Stefan Hajnoczi, qemu-devel; +Cc: Catherine Ho

cache=none means to bypass host cache. So we can't remove O_DIRECT flag in
unconditionally in update_open_flags();

Signed-off-by: Catherine Ho <catherine.hecx@gmail.com>
---
v2: Fix to keep flags unchanged if cache=none, otherwise changed the file
    without O_DIRECT incorrectly.
 tools/virtiofsd/passthrough_ll.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 4c35c95..59e64dd 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1677,7 +1677,8 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t ino,
     fuse_reply_err(req, 0);
 }
 
-static void update_open_flags(int writeback, struct fuse_file_info *fi)
+static void update_open_flags(int writeback, int cache_mode,
+                              struct fuse_file_info *fi)
 {
     /*
      * With writeback cache, kernel may send read requests even
@@ -1702,10 +1703,11 @@ static void update_open_flags(int writeback, struct fuse_file_info *fi)
 
     /*
      * O_DIRECT in guest should not necessarily mean bypassing page
-     * cache on host as well. If somebody needs that behavior, it
-     * probably should be a configuration knob in daemon.
+     * cache on host as well. If cache=none, keep the flag unchanged
      */
-    fi->flags &= ~O_DIRECT;
+    if (cache_mode != CACHE_NONE) {
+        fi->flags &= ~O_DIRECT;
+    }
 }
 
 static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
@@ -1737,7 +1739,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
         goto out;
     }
 
-    update_open_flags(lo->writeback, fi);
+    update_open_flags(lo->writeback, lo->cache, fi);
 
     fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
                 mode);
@@ -1947,7 +1949,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
     fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
              fi->flags);
 
-    update_open_flags(lo->writeback, fi);
+    update_open_flags(lo->writeback, lo->cache, fi);
 
     sprintf(buf, "%i", lo_fd(req, ino));
     fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
-- 
1.7.1



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

* Re: [PATCH v2] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
  2020-04-11  8:35 ` [PATCH v2] " Catherine Ho
@ 2020-04-21  1:55   ` Catherine Ho
  2020-04-30  8:35     ` [Virtio-fs] " Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Catherine Ho @ 2020-04-21  1:55 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Stefan Hajnoczi, QEMU Developers

Ping :)

---
B.R.
Catherine

On Sat, 11 Apr 2020 at 16:41, Catherine Ho <catherine.hecx@gmail.com> wrote:
>
> cache=none means to bypass host cache. So we can't remove O_DIRECT flag in
> unconditionally in update_open_flags();
>
> Signed-off-by: Catherine Ho <catherine.hecx@gmail.com>
> ---
> v2: Fix to keep flags unchanged if cache=none, otherwise changed the file
>     without O_DIRECT incorrectly.
>  tools/virtiofsd/passthrough_ll.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
> index 4c35c95..59e64dd 100644
> --- a/tools/virtiofsd/passthrough_ll.c
> +++ b/tools/virtiofsd/passthrough_ll.c
> @@ -1677,7 +1677,8 @@ static void lo_releasedir(fuse_req_t req, fuse_ino_t ino,
>      fuse_reply_err(req, 0);
>  }
>
> -static void update_open_flags(int writeback, struct fuse_file_info *fi)
> +static void update_open_flags(int writeback, int cache_mode,
> +                              struct fuse_file_info *fi)
>  {
>      /*
>       * With writeback cache, kernel may send read requests even
> @@ -1702,10 +1703,11 @@ static void update_open_flags(int writeback, struct fuse_file_info *fi)
>
>      /*
>       * O_DIRECT in guest should not necessarily mean bypassing page
> -     * cache on host as well. If somebody needs that behavior, it
> -     * probably should be a configuration knob in daemon.
> +     * cache on host as well. If cache=none, keep the flag unchanged
>       */
> -    fi->flags &= ~O_DIRECT;
> +    if (cache_mode != CACHE_NONE) {
> +        fi->flags &= ~O_DIRECT;
> +    }
>  }
>
>  static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
> @@ -1737,7 +1739,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
>          goto out;
>      }
>
> -    update_open_flags(lo->writeback, fi);
> +    update_open_flags(lo->writeback, lo->cache, fi);
>
>      fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
>                  mode);
> @@ -1947,7 +1949,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
>      fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
>               fi->flags);
>
> -    update_open_flags(lo->writeback, fi);
> +    update_open_flags(lo->writeback, lo->cache, fi);
>
>      sprintf(buf, "%i", lo_fd(req, ino));
>      fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
> --
> 1.7.1
>


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

* Re: [PATCH v2] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
  2020-04-11  8:35 ` [PATCH v2] " Catherine Ho
@ 2020-04-30  8:35     ` Stefan Hajnoczi
  2020-04-30  8:35     ` [Virtio-fs] " Stefan Hajnoczi
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2020-04-30  8:35 UTC (permalink / raw)
  To: Catherine Ho; +Cc: virtio-fs, Dr. David Alan Gilbert, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]

On Sat, Apr 11, 2020 at 04:35:44AM -0400, Catherine Ho wrote:
> @@ -1702,10 +1703,11 @@ static void update_open_flags(int writeback, struct fuse_file_info *fi)
>  
>      /*
>       * O_DIRECT in guest should not necessarily mean bypassing page
> -     * cache on host as well. If somebody needs that behavior, it
> -     * probably should be a configuration knob in daemon.
> +     * cache on host as well. If cache=none, keep the flag unchanged
>       */
> -    fi->flags &= ~O_DIRECT;
> +    if (cache_mode != CACHE_NONE) {
> +        fi->flags &= ~O_DIRECT;
> +    }
>  }
>  

Thanks for the patch!  I have CCed the virtio-fs mailing list so more
people see it.

Please add a new command-line option to control O_DIRECT behavior.

There are two cases:

1. O_DIRECT bypasses the guest page cache but not the host page cache.
   This makes sense when the DAX feature is enabled.

2. O_DIRECT bypasses both the guest and host page cache.  This make
   sense for non-DAX and for I/O performance benchmarking.

Today only #1 is supported.

Your patch makes the behavior dependent on the cache mode option, but
the cache mode doesn't necessarily determine how O_DIRECT should be
handled.  For example, in the DAX case the guest page cache is bypassed
and cache=none can be used, but we do want to use the host page cache.

You can add a new option so that O_DIRECT handling is configurable for
all cases.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [Virtio-fs] [PATCH v2] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none
@ 2020-04-30  8:35     ` Stefan Hajnoczi
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2020-04-30  8:35 UTC (permalink / raw)
  To: Catherine Ho; +Cc: virtio-fs, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1452 bytes --]

On Sat, Apr 11, 2020 at 04:35:44AM -0400, Catherine Ho wrote:
> @@ -1702,10 +1703,11 @@ static void update_open_flags(int writeback, struct fuse_file_info *fi)
>  
>      /*
>       * O_DIRECT in guest should not necessarily mean bypassing page
> -     * cache on host as well. If somebody needs that behavior, it
> -     * probably should be a configuration knob in daemon.
> +     * cache on host as well. If cache=none, keep the flag unchanged
>       */
> -    fi->flags &= ~O_DIRECT;
> +    if (cache_mode != CACHE_NONE) {
> +        fi->flags &= ~O_DIRECT;
> +    }
>  }
>  

Thanks for the patch!  I have CCed the virtio-fs mailing list so more
people see it.

Please add a new command-line option to control O_DIRECT behavior.

There are two cases:

1. O_DIRECT bypasses the guest page cache but not the host page cache.
   This makes sense when the DAX feature is enabled.

2. O_DIRECT bypasses both the guest and host page cache.  This make
   sense for non-DAX and for I/O performance benchmarking.

Today only #1 is supported.

Your patch makes the behavior dependent on the cache mode option, but
the cache mode doesn't necessarily determine how O_DIRECT should be
handled.  For example, in the DAX case the guest page cache is bypassed
and cache=none can be used, but we do want to use the host page cache.

You can add a new option so that O_DIRECT handling is configurable for
all cases.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2020-04-30  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11  6:19 [PATCH] virtiofsd/passthrough_ll: don't remove O_DIRECT when cache=none Catherine Ho
2020-04-11  8:35 ` [PATCH v2] " Catherine Ho
2020-04-21  1:55   ` Catherine Ho
2020-04-30  8:35   ` Stefan Hajnoczi
2020-04-30  8:35     ` [Virtio-fs] " Stefan Hajnoczi

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.