cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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