Don't enable adaptive readdirplus unless fs has readdir() handler.
authorNikolaus Rath <Nikolaus@rath.org>
Mon, 17 Sep 2018 13:53:30 +0000 (14:53 +0100)
committerNikolaus Rath <Nikolaus@rath.org>
Thu, 20 Sep 2018 08:07:45 +0000 (09:07 +0100)
ChangeLog.rst
include/fuse_common.h
lib/fuse_lowlevel.c

index af01d78990f9c43ff8184f4cb44de0e5af489ebd..3d5c05bf9e198eb0c947443de5059acfe2d3f2ee 100644 (file)
@@ -1,3 +1,13 @@
+Unreleased Changes
+=================
+
+* The FUSE_CAP_READDIRPLUS_AUTO capability is no longer enabled by
+  default unless the file system defines both a readdir() and a
+  readdirplus() handler.
+
+* The description of the FUSE_CAP_READDIRPLUS_AUTO flag has been
+  improved.
+
 libfuse 3.2.6 (2018-08-31)
 ==========================
 
index 29ad339bd8f1d0afc549473f25755e84ef9352c0..83c9deefe4c798ed01ceffab0795db6a9f9f072c 100644 (file)
@@ -219,7 +219,7 @@ struct fuse_loop_config {
 #define FUSE_CAP_AUTO_INVAL_DATA       (1 << 12)
 
 /**
- * Indicates that the filesystem supports readdirplus
+ * Indicates that the filesystem supports readdirplus.
  *
  * This feature is enabled by default when supported by the kernel and if the
  * filesystem implements a readdirplus() handler.
@@ -227,10 +227,21 @@ struct fuse_loop_config {
 #define FUSE_CAP_READDIRPLUS           (1 << 13)
 
 /**
- * Indicates that the filesystem supports adaptive readdirplus
+ * Indicates that the filesystem supports adaptive readdirplus
  *
- * This feature is enabled by default when supported by the kernel and if the
- * filesystem implements a readdirplus() handler.
+ * If FUSE_CAP_READDIRPLUS is not set, this flag has no effect.
+ *
+ * If FUSE_CAP_READDIRPLUS is set and this flag is not set, the kernel
+ * will always issue readdirplus() requests to retrieve directory
+ * contents.
+ *
+ * If FUSE_CAP_READDIRPLUS is set and this flag is set, the kernel
+ * will issue both readdir() and readdirplus() requests, depending on
+ * how much information is expected to be required.
+ *
+ * This feature is enabled by default when supported by the kernel and
+ * if the filesystem implements both a readdirplus() and a readdir()
+ * handler.
  */
 #define FUSE_CAP_READDIRPLUS_AUTO      (1 << 14)
 
index c426b7cbf9227f64444a0406424277246ce1152d..e6e3d8d5e13a12ec874942e353587c300b84b39c 100644 (file)
@@ -1918,7 +1918,8 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
                       FUSE_CAP_POSIX_LOCKS);
        LL_SET_DEFAULT(se->op.flock, FUSE_CAP_FLOCK_LOCKS);
        LL_SET_DEFAULT(se->op.readdirplus, FUSE_CAP_READDIRPLUS);
-       LL_SET_DEFAULT(se->op.readdirplus, FUSE_CAP_READDIRPLUS_AUTO);
+       LL_SET_DEFAULT(se->op.readdirplus && se->op.readdir,
+                      FUSE_CAP_READDIRPLUS_AUTO);
        se->conn.time_gran = 1;
        
        if (bufsize < FUSE_MIN_READ_BUFFER) {