Change FUSE_MAX_MAX_PAGES to FUSE_DEFAULT_MAX_PAGES_LIMIT
authorJoanne Koong <joannelkoong@gmail.com>
Fri, 27 Sep 2024 00:33:39 +0000 (17:33 -0700)
committerBernd Schubert <bernd.schubert@fastmail.fm>
Sat, 28 Sep 2024 10:24:25 +0000 (12:24 +0200)
A recent upstream patch [1] changed FUSE_MAX_MAX_PAGES to
FUSE_DEFAULT_MAX_PAGES_LIMIT.

Update libfuse to use FUSE_DEFAULT_MAX_PAGES_LIMIT as well
instead of FUSE_MAX_MAX_PAGES.

[1] https://lore.kernel.org/linux-fsdevel/20240923171311.1561917-1-joannelkoong@gmail.com/T/#t

lib/fuse_i.h
lib/fuse_lowlevel.c

index 1519ce06fdac3bf478300237ba198f5b120abae3..2815a8a28c426ab8750a1630445f7999c87dd928 100644 (file)
@@ -196,7 +196,13 @@ int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *c
 int fuse_loop_cfg_verify(struct fuse_loop_config *config);
 
 
-#define FUSE_MAX_MAX_PAGES 256
+/*
+ * This can be changed dynamically on recent kernels through the
+ * /proc/sys/fs/fuse/max_pages_limit interface.
+ *
+ * Older kernels will always use the default value.
+ */
+#define FUSE_DEFAULT_MAX_PAGES_LIMIT 256
 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
 
 /* room needed in buffer to accommodate header */
index 824dbab4f76cb681a3106cde1096ce62488d97b3..819e435bf5e0ac22cf5617567e3fb3e7600b08c0 100644 (file)
@@ -2915,19 +2915,19 @@ static unsigned int get_max_pages(void)
 
        fd = open("/proc/sys/fs/fuse/max_pages_limit", O_RDONLY);
        if (fd < 0)
-               return FUSE_MAX_MAX_PAGES;
+               return FUSE_DEFAULT_MAX_PAGES_LIMIT;
 
        res = read(fd, buf, sizeof(buf) - 1);
 
        close(fd);
 
        if (res < 0)
-               return FUSE_MAX_MAX_PAGES;
+               return FUSE_DEFAULT_MAX_PAGES_LIMIT;
 
        buf[res] = '\0';
 
        res = strtol(buf, NULL, 10);
-       return res < 0 ? FUSE_MAX_MAX_PAGES : res;
+       return res < 0 ? FUSE_DEFAULT_MAX_PAGES_LIMIT : res;
 }
 
 int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf)