yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-Reset-O_DIRECT-flag-during-file-open.patch

ddf19c
From b8d62021f28114f054571b96ec0cd4dad4476923 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:02:14 +0100
ddf19c
Subject: [PATCH 103/116] virtiofsd: Reset O_DIRECT flag during file open
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-100-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93553
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 099/112] virtiofsd: Reset O_DIRECT flag during file open
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: Vivek Goyal <vgoyal@redhat.com>
ddf19c
ddf19c
If an application wants to do direct IO and opens a file with O_DIRECT
ddf19c
in guest, that does not necessarily mean that we need to bypass page
ddf19c
cache on host as well. So reset this flag on host.
ddf19c
ddf19c
If somebody needs to bypass page cache on host as well (and it is safe to
ddf19c
do so), we can add a knob in daemon later to control this behavior.
ddf19c
ddf19c
I check virtio-9p and they do reset O_DIRECT flag.
ddf19c
ddf19c
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
ddf19c
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit 65da4539803373ec4eec97ffc49ee90083e56efd)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
ddf19c
 1 file changed, 14 insertions(+)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
ddf19c
index ccbbec1..948cb19 100644
ddf19c
--- a/tools/virtiofsd/passthrough_ll.c
ddf19c
+++ b/tools/virtiofsd/passthrough_ll.c
ddf19c
@@ -1721,6 +1721,13 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
ddf19c
         goto out;
ddf19c
     }
ddf19c
 
ddf19c
+    /*
ddf19c
+     * O_DIRECT in guest should not necessarily mean bypassing page
ddf19c
+     * cache on host as well. If somebody needs that behavior, it
ddf19c
+     * probably should be a configuration knob in daemon.
ddf19c
+     */
ddf19c
+    fi->flags &= ~O_DIRECT;
ddf19c
+
ddf19c
     fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
ddf19c
                 mode);
ddf19c
     err = fd == -1 ? errno : 0;
ddf19c
@@ -1950,6 +1957,13 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
ddf19c
         fi->flags &= ~O_APPEND;
ddf19c
     }
ddf19c
 
ddf19c
+    /*
ddf19c
+     * O_DIRECT in guest should not necessarily mean bypassing page
ddf19c
+     * cache on host as well. If somebody needs that behavior, it
ddf19c
+     * probably should be a configuration knob in daemon.
ddf19c
+     */
ddf19c
+    fi->flags &= ~O_DIRECT;
ddf19c
+
ddf19c
     sprintf(buf, "%i", lo_fd(req, ino));
ddf19c
     fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
ddf19c
     if (fd == -1) {
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c