linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: Replace hardcoded 4096 with PAGE_SIZE
@ 2025-08-19 13:08 Chunsheng Luo
  2025-08-19 13:22 ` Chunsheng Luo
  0 siblings, 1 reply; 2+ messages in thread
From: Chunsheng Luo @ 2025-08-19 13:08 UTC (permalink / raw)
  To: miklos; +Cc: linux-fsdevel, linux-kernel, Chunsheng Luo

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re:[PATCH] fuse: Replace hardcoded 4096 with PAGE_SIZE
  2025-08-19 13:08 [PATCH] fuse: Replace hardcoded 4096 with PAGE_SIZE Chunsheng Luo
@ 2025-08-19 13:22 ` Chunsheng Luo
  0 siblings, 0 replies; 2+ messages in thread
From: Chunsheng Luo @ 2025-08-19 13:22 UTC (permalink / raw)
  To: luochunsheng; +Cc: linux-fsdevel, linux-kernel, miklos

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-19 13:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19 13:08 [PATCH] fuse: Replace hardcoded 4096 with PAGE_SIZE Chunsheng Luo
2025-08-19 13:22 ` Chunsheng Luo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).