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

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