* [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open
@ 2019-08-20 18:37 Vivek Goyal
2019-08-22 13:15 ` Stefan Hajnoczi
2019-08-22 18:54 ` Dr. David Alan Gilbert
0 siblings, 2 replies; 3+ messages in thread
From: Vivek Goyal @ 2019-08-20 18:37 UTC (permalink / raw)
To: virtio-fs-list, Dr. David Alan Gilbert
If an application wants to do direct IO and opens a file with O_DIRECT
in guest, that does not necessarily mean that we need to bypass page
cache on host as well. So reset this flag on host.
If somebody needs to bypass page cache on host as well (and it is safe to
do so), we can add a knob in daemon later to control this behavior.
I check virtio-9p and they do reset O_DIRECT flag.
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
contrib/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: qemu/contrib/virtiofsd/passthrough_ll.c
===================================================================
--- qemu.orig/contrib/virtiofsd/passthrough_ll.c 2019-08-20 09:33:07.900975145 -0400
+++ qemu/contrib/virtiofsd/passthrough_ll.c 2019-08-20 14:31:39.725781357 -0400
@@ -1752,6 +1752,13 @@ static void lo_create(fuse_req_t req, fu
if (err)
goto out;
+ /*
+ * 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.
+ */
+ fi->flags &= ~O_DIRECT;
+
fd = openat(parent_inode->fd, name,
(fi->flags | O_CREAT) & ~O_NOFOLLOW, mode);
err = fd == -1 ? errno : 0;
@@ -1967,6 +1974,13 @@ static void lo_open(fuse_req_t req, fuse
if (lo->writeback && (fi->flags & O_APPEND))
fi->flags &= ~O_APPEND;
+ /*
+ * 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.
+ */
+ fi->flags &= ~O_DIRECT;
+
sprintf(buf, "%i", lo_fd(req, ino));
fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
if (fd == -1)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open
2019-08-20 18:37 [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open Vivek Goyal
@ 2019-08-22 13:15 ` Stefan Hajnoczi
2019-08-22 18:54 ` Dr. David Alan Gilbert
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2019-08-22 13:15 UTC (permalink / raw)
To: Vivek Goyal; +Cc: virtio-fs-list
[-- Attachment #1: Type: text/plain, Size: 766 bytes --]
On Tue, Aug 20, 2019 at 02:37:46PM -0400, Vivek Goyal wrote:
> If an application wants to do direct IO and opens a file with O_DIRECT
> in guest, that does not necessarily mean that we need to bypass page
> cache on host as well. So reset this flag on host.
>
> If somebody needs to bypass page cache on host as well (and it is safe to
> do so), we can add a knob in daemon later to control this behavior.
>
> I check virtio-9p and they do reset O_DIRECT flag.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
> ---
> contrib/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
virtio-fs should work even if the host file system doesn't support
O_DIRECT:
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open
2019-08-20 18:37 [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open Vivek Goyal
2019-08-22 13:15 ` Stefan Hajnoczi
@ 2019-08-22 18:54 ` Dr. David Alan Gilbert
1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2019-08-22 18:54 UTC (permalink / raw)
To: Vivek Goyal; +Cc: virtio-fs-list
* Vivek Goyal (vgoyal@redhat.com) wrote:
> If an application wants to do direct IO and opens a file with O_DIRECT
> in guest, that does not necessarily mean that we need to bypass page
> cache on host as well. So reset this flag on host.
>
> If somebody needs to bypass page cache on host as well (and it is safe to
> do so), we can add a knob in daemon later to control this behavior.
>
> I check virtio-9p and they do reset O_DIRECT flag.
>
> Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Merged; thanks
> ---
> contrib/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> Index: qemu/contrib/virtiofsd/passthrough_ll.c
> ===================================================================
> --- qemu.orig/contrib/virtiofsd/passthrough_ll.c 2019-08-20 09:33:07.900975145 -0400
> +++ qemu/contrib/virtiofsd/passthrough_ll.c 2019-08-20 14:31:39.725781357 -0400
> @@ -1752,6 +1752,13 @@ static void lo_create(fuse_req_t req, fu
> if (err)
> goto out;
>
> + /*
> + * 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.
> + */
> + fi->flags &= ~O_DIRECT;
> +
> fd = openat(parent_inode->fd, name,
> (fi->flags | O_CREAT) & ~O_NOFOLLOW, mode);
> err = fd == -1 ? errno : 0;
> @@ -1967,6 +1974,13 @@ static void lo_open(fuse_req_t req, fuse
> if (lo->writeback && (fi->flags & O_APPEND))
> fi->flags &= ~O_APPEND;
>
> + /*
> + * 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.
> + */
> + fi->flags &= ~O_DIRECT;
> +
> sprintf(buf, "%i", lo_fd(req, ino));
> fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
> if (fd == -1)
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-22 18:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-20 18:37 [Virtio-fs] [PATCH V2] virtiofsd: Reset O_DIRECT flag during file open Vivek Goyal
2019-08-22 13:15 ` Stefan Hajnoczi
2019-08-22 18:54 ` Dr. David Alan Gilbert
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.