a5bd087
From 079199c53f483f0051f994b195ebb595aec76a39 Mon Sep 17 00:00:00 2001
a5bd087
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
a5bd087
Date: Mon, 27 Jan 2020 19:01:51 +0100
a5bd087
Subject: [PATCH 080/116] virtiofsd: passthrough_ll: clean up cache related
a5bd087
 options
a5bd087
MIME-Version: 1.0
a5bd087
Content-Type: text/plain; charset=UTF-8
a5bd087
Content-Transfer-Encoding: 8bit
a5bd087
a5bd087
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
a5bd087
Message-id: <20200127190227.40942-77-dgilbert@redhat.com>
a5bd087
Patchwork-id: 93530
a5bd087
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 076/112] virtiofsd: passthrough_ll: clean up cache related options
a5bd087
Bugzilla: 1694164
a5bd087
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a5bd087
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
a5bd087
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
a5bd087
a5bd087
From: Miklos Szeredi <mszeredi@redhat.com>
a5bd087
a5bd087
 - Rename "cache=never" to "cache=none" to match 9p's similar option.
a5bd087
a5bd087
 - Rename CACHE_NORMAL constant to CACHE_AUTO to match the "cache=auto"
a5bd087
   option.
a5bd087
a5bd087
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
a5bd087
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a5bd087
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
a5bd087
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
a5bd087
(cherry picked from commit 230e777b5e250759ee0480fcc0e9ccfa2b082fba)
a5bd087
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a5bd087
---
a5bd087
 tools/virtiofsd/helper.c         |  5 ++++-
a5bd087
 tools/virtiofsd/passthrough_ll.c | 20 ++++++++++----------
a5bd087
 2 files changed, 14 insertions(+), 11 deletions(-)
a5bd087
a5bd087
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
a5bd087
index 14f5d70..5672024 100644
a5bd087
--- a/tools/virtiofsd/helper.c
a5bd087
+++ b/tools/virtiofsd/helper.c
a5bd087
@@ -145,6 +145,9 @@ void fuse_cmdline_help(void)
a5bd087
            "    --syslog                   log to syslog (default stderr)\n"
a5bd087
            "    -f                         foreground operation\n"
a5bd087
            "    --daemonize                run in background\n"
a5bd087
+           "    -o cache=<mode>            cache mode. could be one of \"auto, "
a5bd087
+           "always, none\"\n"
a5bd087
+           "                               default: auto\n"
a5bd087
            "    -o log_level=<level>       log level, default to \"info\"\n"
a5bd087
            "                               level could be one of \"debug, "
a5bd087
            "info, warn, err\"\n"
a5bd087
@@ -156,7 +159,7 @@ void fuse_cmdline_help(void)
a5bd087
            "    -o readdirplus|no_readdirplus\n"
a5bd087
            "                               enable/disable readirplus\n"
a5bd087
            "                               default: readdirplus except with "
a5bd087
-           "cache=never\n"
a5bd087
+           "cache=none\n"
a5bd087
           );
a5bd087
 }
a5bd087
 
a5bd087
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
a5bd087
index 9e7191e..b40f287 100644
a5bd087
--- a/tools/virtiofsd/passthrough_ll.c
a5bd087
+++ b/tools/virtiofsd/passthrough_ll.c
a5bd087
@@ -101,8 +101,8 @@ struct lo_cred {
a5bd087
 };
a5bd087
 
a5bd087
 enum {
a5bd087
-    CACHE_NEVER,
a5bd087
-    CACHE_NORMAL,
a5bd087
+    CACHE_NONE,
a5bd087
+    CACHE_AUTO,
a5bd087
     CACHE_ALWAYS,
a5bd087
 };
a5bd087
 
a5bd087
@@ -138,8 +138,8 @@ static const struct fuse_opt lo_opts[] = {
a5bd087
     { "no_xattr", offsetof(struct lo_data, xattr), 0 },
a5bd087
     { "timeout=%lf", offsetof(struct lo_data, timeout), 0 },
a5bd087
     { "timeout=", offsetof(struct lo_data, timeout_set), 1 },
a5bd087
-    { "cache=never", offsetof(struct lo_data, cache), CACHE_NEVER },
a5bd087
-    { "cache=auto", offsetof(struct lo_data, cache), CACHE_NORMAL },
a5bd087
+    { "cache=none", offsetof(struct lo_data, cache), CACHE_NONE },
a5bd087
+    { "cache=auto", offsetof(struct lo_data, cache), CACHE_AUTO },
a5bd087
     { "cache=always", offsetof(struct lo_data, cache), CACHE_ALWAYS },
a5bd087
     { "norace", offsetof(struct lo_data, norace), 1 },
a5bd087
     { "readdirplus", offsetof(struct lo_data, readdirplus_set), 1 },
a5bd087
@@ -482,7 +482,7 @@ static void lo_init(void *userdata, struct fuse_conn_info *conn)
a5bd087
         fuse_log(FUSE_LOG_DEBUG, "lo_init: activating flock locks\n");
a5bd087
         conn->want |= FUSE_CAP_FLOCK_LOCKS;
a5bd087
     }
a5bd087
-    if ((lo->cache == CACHE_NEVER && !lo->readdirplus_set) ||
a5bd087
+    if ((lo->cache == CACHE_NONE && !lo->readdirplus_set) ||
a5bd087
         lo->readdirplus_clear) {
a5bd087
         fuse_log(FUSE_LOG_DEBUG, "lo_init: disabling readdirplus\n");
a5bd087
         conn->want &= ~FUSE_CAP_READDIRPLUS;
a5bd087
@@ -1493,7 +1493,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
a5bd087
         fi->fh = fh;
a5bd087
         err = lo_do_lookup(req, parent, name, &e);
a5bd087
     }
a5bd087
-    if (lo->cache == CACHE_NEVER) {
a5bd087
+    if (lo->cache == CACHE_NONE) {
a5bd087
         fi->direct_io = 1;
a5bd087
     } else if (lo->cache == CACHE_ALWAYS) {
a5bd087
         fi->keep_cache = 1;
a5bd087
@@ -1578,7 +1578,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
a5bd087
     }
a5bd087
 
a5bd087
     fi->fh = fh;
a5bd087
-    if (lo->cache == CACHE_NEVER) {
a5bd087
+    if (lo->cache == CACHE_NONE) {
a5bd087
         fi->direct_io = 1;
a5bd087
     } else if (lo->cache == CACHE_ALWAYS) {
a5bd087
         fi->keep_cache = 1;
a5bd087
@@ -2395,7 +2395,7 @@ int main(int argc, char *argv[])
a5bd087
     lo.root.next = lo.root.prev = &lo.root;
a5bd087
     lo.root.fd = -1;
a5bd087
     lo.root.fuse_ino = FUSE_ROOT_ID;
a5bd087
-    lo.cache = CACHE_NORMAL;
a5bd087
+    lo.cache = CACHE_AUTO;
a5bd087
 
a5bd087
     /*
a5bd087
      * Set up the ino map like this:
a5bd087
@@ -2470,11 +2470,11 @@ int main(int argc, char *argv[])
a5bd087
     }
a5bd087
     if (!lo.timeout_set) {
a5bd087
         switch (lo.cache) {
a5bd087
-        case CACHE_NEVER:
a5bd087
+        case CACHE_NONE:
a5bd087
             lo.timeout = 0.0;
a5bd087
             break;
a5bd087
 
a5bd087
-        case CACHE_NORMAL:
a5bd087
+        case CACHE_AUTO:
a5bd087
             lo.timeout = 1.0;
a5bd087
             break;
a5bd087
 
a5bd087
-- 
a5bd087
1.8.3.1
a5bd087