fs/fuse/cuse.c | 4 ++-- fs/fuse/inode.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
Replace hardcoded 4096 values with PAGE_SIZE macro in FUSE
filesystem for better portability across different architectures.
This improves code maintainability and ensures proper alignment with
the system's page size, which may vary on different architectures
(e.g., 4KB on x86, 64KB on some ARM64 systems).
The functionality remains unchanged on systems with 4KB pages while
providing better compatibility for systems with different page sizes.
Signed-off-by: Chunsheng Luo <luochunsheng@ustc.edu>
---
fs/fuse/cuse.c | 4 ++--
fs/fuse/inode.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index b39844d75a80..f4770ad627a8 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -337,8 +337,8 @@ static void cuse_process_init_reply(struct fuse_mount *fm,
goto err;
fc->minor = arg->minor;
- fc->max_read = max_t(unsigned, arg->max_read, 4096);
- fc->max_write = max_t(unsigned, arg->max_write, 4096);
+ fc->max_read = max_t(unsigned int, arg->max_read, PAGE_SIZE);
+ fc->max_write = max_t(unsigned int, arg->max_write, PAGE_SIZE);
/* parse init reply */
cc->unrestricted_ioctl = arg->flags & CUSE_UNRESTRICTED_IOCTL;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index ecb869e895ab..8de2e969924e 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -1454,8 +1454,8 @@ static void process_init_reply(struct fuse_mount *fm, struct fuse_args *args,
fm->sb->s_bdi->ra_pages =
min(fm->sb->s_bdi->ra_pages, ra_pages);
fc->minor = arg->minor;
- fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
- fc->max_write = max_t(unsigned, 4096, fc->max_write);
+ fc->max_write = arg->minor < 5 ? PAGE_SIZE : arg->max_write;
+ fc->max_write = max_t(unsigned int, PAGE_SIZE, fc->max_write);
fc->conn_init = 1;
}
kfree(ia);
@@ -1847,7 +1847,7 @@ int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx)
fc->user_id = ctx->user_id;
fc->group_id = ctx->group_id;
fc->legacy_opts_show = ctx->legacy_opts_show;
- fc->max_read = max_t(unsigned int, 4096, ctx->max_read);
+ fc->max_read = max_t(unsigned int, PAGE_SIZE, ctx->max_read);
fc->destroy = ctx->destroy;
fc->no_control = ctx->no_control;
fc->no_force_umount = ctx->no_force_umount;
--
2.43.0
Hi everyone, I have a question about the historical use of hardcoded 4096 values for max_read and max_write defaults in FUSE code, rather than using PAGE_SIZE. fc->max_read = max_t(unsigned, arg->max_read, 4096); fc->max_write = max_t(unsigned, arg->max_write, 4096); Is there any historical reason or compatibility concern for keeping the hardcoded 4096? Would it make sense to use PAGE_SIZE? Any insights would be appreciated. Thanks Chunsheng Luo
© 2016 - 2025 Red Hat, Inc.