render / rpms / qemu

Forked from rpms/qemu 8 months ago
Clone

Blame 0105-virtiofsd-Reset-O_DIRECT-flag-during-file-open.patch

1d442b
From: Vivek Goyal <vgoyal@redhat.com>
1d442b
Date: Mon, 27 Jan 2020 19:02:14 +0000
1d442b
Subject: [PATCH] virtiofsd: Reset O_DIRECT flag during file open
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
If an application wants to do direct IO and opens a file with O_DIRECT
1d442b
in guest, that does not necessarily mean that we need to bypass page
1d442b
cache on host as well. So reset this flag on host.
1d442b
1d442b
If somebody needs to bypass page cache on host as well (and it is safe to
1d442b
do so), we can add a knob in daemon later to control this behavior.
1d442b
1d442b
I check virtio-9p and they do reset O_DIRECT flag.
1d442b
1d442b
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
1d442b
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit 65da4539803373ec4eec97ffc49ee90083e56efd)
1d442b
---
1d442b
 tools/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
1d442b
 1 file changed, 14 insertions(+)
1d442b
1d442b
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
1d442b
index ccbbec18b0..948cb19c77 100644
1d442b
--- a/tools/virtiofsd/passthrough_ll.c
1d442b
+++ b/tools/virtiofsd/passthrough_ll.c
1d442b
@@ -1721,6 +1721,13 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
1d442b
         goto out;
1d442b
     }
1d442b
 
1d442b
+    /*
1d442b
+     * O_DIRECT in guest should not necessarily mean bypassing page
1d442b
+     * cache on host as well. If somebody needs that behavior, it
1d442b
+     * probably should be a configuration knob in daemon.
1d442b
+     */
1d442b
+    fi->flags &= ~O_DIRECT;
1d442b
+
1d442b
     fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
1d442b
                 mode);
1d442b
     err = fd == -1 ? errno : 0;
1d442b
@@ -1950,6 +1957,13 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
1d442b
         fi->flags &= ~O_APPEND;
1d442b
     }
1d442b
 
1d442b
+    /*
1d442b
+     * O_DIRECT in guest should not necessarily mean bypassing page
1d442b
+     * cache on host as well. If somebody needs that behavior, it
1d442b
+     * probably should be a configuration knob in daemon.
1d442b
+     */
1d442b
+    fi->flags &= ~O_DIRECT;
1d442b
+
1d442b
     sprintf(buf, "%i", lo_fd(req, ino));
1d442b
     fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
1d442b
     if (fd == -1) {