Add support for in-kernel readdir caching.
authorNikolaus Rath <Nikolaus@rath.org>
Sat, 6 Apr 2019 17:34:57 +0000 (18:34 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Sat, 6 Apr 2019 17:34:57 +0000 (18:34 +0100)
Fixes: #394.
ChangeLog.rst
include/fuse_common.h
lib/fuse_lowlevel.c

index 7407ceaafa081ed2bb94d793421609f057a11816..1abb66c5c46d828199b7ae06e27b171d8dac617d 100644 (file)
@@ -1,8 +1,13 @@
+Unreleased Changes
+==================
+
 * Changed ioctl commands to "unsigned int" in order to support commands
   which do not fit into a signed int. Commands issued by applications
   are still truncated to 32 bits.
 * Added SMB2 to whitelist (so users can now mount FUSE filesystems
   on mountpoints within SMB 2.0 filesystems).
+* Added a new `cache_readdir` flag to `fuse_file_info` to enable
+  caching of readdir results. Supported by kernels 4.20 and newer.  
 
 libfuse 3.4.2 (2019-03-09)
 ==========================
index 5cf9feea9d764f53da3df3f2ffec0fd538feba2d..823a37db50ac2f612d5cbe20305f3530ea9e2672 100644 (file)
@@ -55,9 +55,11 @@ struct fuse_file_info {
        /** Can be filled in by open, to use direct I/O on this file. */
        unsigned int direct_io : 1;
 
-       /** Can be filled in by open, to indicate that currently
-           cached file data (that the filesystem provided the last
-           time the file was open) need not be invalidated. */
+       /** Can be filled in by open. It signals the kernel that any
+           currently cached file data (ie., data that the filesystem
+           provided the last time the file was open) need not be
+           invalidated. Has no effect when set in other contexts (in
+           particular it does nothing when set by opendir()). */
        unsigned int keep_cache : 1;
 
        /** Indicates a flush operation.  Set in flush operation, also
@@ -74,8 +76,14 @@ struct fuse_file_info {
           May only be set in ->release(). */
        unsigned int flock_release : 1;
 
-       /** Padding.  Do not use*/
-       unsigned int padding : 27;
+       /** Can be filled in by opendir. It signals the kernel to
+           enable caching of entries returned by readdir().  Has no
+           effect when set in other contexts (in particular it does
+           nothing when set by open()). */
+       unsigned int cache_readdir : 1;
+
+       /** Padding.  Reserved for future use*/
+       unsigned int padding : 26;
 
        /** File handle id.  May be filled in by filesystem in create,
         * open, and opendir().  Available in most other file operations on the
index 78ee63bc874b907bc7d7336ae036ae8acab0f1c9..50fff4d1e1ff0474e05bad248ae36493638a0466 100644 (file)
@@ -392,6 +392,8 @@ static void fill_open(struct fuse_open_out *arg,
                arg->open_flags |= FOPEN_DIRECT_IO;
        if (f->keep_cache)
                arg->open_flags |= FOPEN_KEEP_CACHE;
+       if (f->cache_readdir)
+               arg->open_flags |= FOPEN_CACHE_DIR;
        if (f->nonseekable)
                arg->open_flags |= FOPEN_NONSEEKABLE;
 }