ddf19c
From 0f1d456fad4ba6a696eff8976b9fe8a0f251e1b5 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:01:47 +0100
ddf19c
Subject: [PATCH 076/116] virtiofsd: passthrough_ll: control readdirplus
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-73-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93524
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 072/112] virtiofsd: passthrough_ll: control readdirplus
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: Miklos Szeredi <mszeredi@redhat.com>
ddf19c
ddf19c
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
ddf19c
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit 59aef494be2d8d91055ff3f3a8eb13d9f32873d8)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/helper.c         | 4 ++++
ddf19c
 tools/virtiofsd/passthrough_ll.c | 7 ++++++-
ddf19c
 2 files changed, 10 insertions(+), 1 deletion(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
ddf19c
index 6d50a46..14f5d70 100644
ddf19c
--- a/tools/virtiofsd/helper.c
ddf19c
+++ b/tools/virtiofsd/helper.c
ddf19c
@@ -153,6 +153,10 @@ void fuse_cmdline_help(void)
ddf19c
            "                               allowed (default: 10)\n"
ddf19c
            "    -o norace                  disable racy fallback\n"
ddf19c
            "                               default: false\n"
ddf19c
+           "    -o readdirplus|no_readdirplus\n"
ddf19c
+           "                               enable/disable readirplus\n"
ddf19c
+           "                               default: readdirplus except with "
ddf19c
+           "cache=never\n"
ddf19c
           );
ddf19c
 }
ddf19c
 
ddf19c
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
ddf19c
index 6480c51..8b1784f 100644
ddf19c
--- a/tools/virtiofsd/passthrough_ll.c
ddf19c
+++ b/tools/virtiofsd/passthrough_ll.c
ddf19c
@@ -117,6 +117,8 @@ struct lo_data {
ddf19c
     double timeout;
ddf19c
     int cache;
ddf19c
     int timeout_set;
ddf19c
+    int readdirplus_set;
ddf19c
+    int readdirplus_clear;
ddf19c
     struct lo_inode root; /* protected by lo->mutex */
ddf19c
     struct lo_map ino_map; /* protected by lo->mutex */
ddf19c
     struct lo_map dirp_map; /* protected by lo->mutex */
ddf19c
@@ -140,6 +142,8 @@ static const struct fuse_opt lo_opts[] = {
ddf19c
     { "cache=auto", offsetof(struct lo_data, cache), CACHE_NORMAL },
ddf19c
     { "cache=always", offsetof(struct lo_data, cache), CACHE_ALWAYS },
ddf19c
     { "norace", offsetof(struct lo_data, norace), 1 },
ddf19c
+    { "readdirplus", offsetof(struct lo_data, readdirplus_set), 1 },
ddf19c
+    { "no_readdirplus", offsetof(struct lo_data, readdirplus_clear), 1 },
ddf19c
     FUSE_OPT_END
ddf19c
 };
ddf19c
 static bool use_syslog = false;
ddf19c
@@ -478,7 +482,8 @@ static void lo_init(void *userdata, struct fuse_conn_info *conn)
ddf19c
         fuse_log(FUSE_LOG_DEBUG, "lo_init: activating flock locks\n");
ddf19c
         conn->want |= FUSE_CAP_FLOCK_LOCKS;
ddf19c
     }
ddf19c
-    if (lo->cache == CACHE_NEVER) {
ddf19c
+    if ((lo->cache == CACHE_NEVER && !lo->readdirplus_set) ||
ddf19c
+        lo->readdirplus_clear) {
ddf19c
         fuse_log(FUSE_LOG_DEBUG, "lo_init: disabling readdirplus\n");
ddf19c
         conn->want &= ~FUSE_CAP_READDIRPLUS;
ddf19c
     }
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c