If a filesystem returns ENOSYS from opendir and thus opts out of
opendir and releasedir requests, it almost certainly would also like
readdir results cached. Default open_flags to FOPEN_KEEP_CACHE and
FOPEN_CACHE_DIR in that case.
With this patch, I've measured recursive directory enumeration across
large FUSE mounts to be faster than native mounts.
Signed-off-by: Chad Austin <chadaustin@fb.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
                return -ENOMEM;
 
        ff->fh = 0;
-       ff->open_flags = FOPEN_KEEP_CACHE; /* Default for no-open */
+       /* Default for no-open */
+       ff->open_flags = FOPEN_KEEP_CACHE | (isdir ? FOPEN_CACHE_DIR : 0);
        if (isdir ? !fc->no_opendir : !fc->no_open) {
                struct fuse_open_out outarg;
                int err;