From 82ceb88998fccfdbe21d2e66cd8764adef7d55e5 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 22 Mar 2015 16:41:29 +0100 Subject: [PATCH] Remove "-o default_permissions" unless needed. It is only needed when "-o allow_other" is specified. "-o default_permissions" causes libfuse to check file access in userspace. This costs CPU cycles and causes additional stat() calls - libfuse has to walk up the whole path to check for "x" permissions on directories. This improves "make benchmark-reverse" performance by 30% when caching is disabled. It also gives a slight improvement with caches on. Before: tests/benchmark-reverse.pl /var/tmp * rsync 1 (initial copy)... 12179 ms * rsync 2 (no changes)... 1840 ms cleaning up... done tests/benchmark-reverse.pl /var/tmp --nocache * rsync 1 (initial copy)... 30696 ms * rsync 2 (no changes)... 10552 ms cleaning up... done After: tests/benchmark-reverse.pl /var/tmp * rsync 1 (initial copy)... 12095 ms * rsync 2 (no changes)... 1693 ms cleaning up... done tests/benchmark-reverse.pl /var/tmp --nocache * rsync 1 (initial copy)... 21266 ms * rsync 2 (no changes)... 6486 ms cleaning up... done --- encfs/main.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/encfs/main.cpp b/encfs/main.cpp index d5e98c4..9281e60 100644 --- a/encfs/main.cpp +++ b/encfs/main.cpp @@ -367,13 +367,6 @@ static bool processArgs(int argc, char *argv[], if (!out->isThreaded) PUSHARG("-s"); - if (useDefaultFlags) { - PUSHARG("-o"); - PUSHARG("use_ino"); - PUSHARG("-o"); - PUSHARG("default_permissions"); - } - // we should have at least 2 arguments left over - the source directory and // the mount point. if (optind + 2 <= argc) { @@ -396,6 +389,26 @@ static bool processArgs(int argc, char *argv[], } } + // Add default flags unless --no-default-flags was passed + if (useDefaultFlags) { + + // Expose the underlying stable inode number + PUSHARG("-o"); + PUSHARG("use_ino"); + + // "default_permissions" comes with a performance cost. Only enable + // it if makes sense. + for(int i=0; i < out->fuseArgc; i++) { + if ( out->fuseArgv[i] == NULL ) { + continue; + } else if (strcmp(out->fuseArgv[i], "allow_other") == 0) { + PUSHARG("-o"); + PUSHARG("default_permissions"); + break; + } + } + } + // sanity check if (out->isDaemon && (!isAbsolutePath(out->mountPoint.c_str()) || !isAbsolutePath(out->opts->rootDir.c_str()))) {