[PATCH v6 2/2] fuse: deduplicate the oversized-request error selection
From: Xiang Mei
Date: Sat Sep 05 2026 - 21:30:07 EST
fuse_dev_do_read() and fuse_uring_args_to_ring() both pick the error for
a request that does not fit the server's buffer, and both special-case
FUSE_SETXATTR. Move that choice into a helper so the two transports
cannot drift apart.
No functional change.
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Xiang Mei <xmei5@xxxxxxx>
---
v4: introduce fuse_req_too_large_error as a helper
v5: add the explaining comment Joanne suggested; add her Reviewed-by
v6: rebase on fuse.git#for-next; no functional change. Dropped the
Reviewed-by tag.
fs/fuse/dev.c | 5 +----
fs/fuse/dev_uring.c | 2 +-
fs/fuse/fuse_dev_i.h | 12 ++++++++++++
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 4fec31fc0b84..9fa90a48357a 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1613,10 +1613,7 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
/* If request is too large, reply with an error and restart the read */
if (nbytes < reqsize) {
- req->out.h.error = -EIO;
- /* SETXATTR is special, since it may contain too large data */
- if (args->opcode == FUSE_SETXATTR)
- req->out.h.error = -E2BIG;
+ req->out.h.error = fuse_req_too_large_error(args);
fuse_request_end(req);
goto restart;
}
diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index 981b7c295e5e..197d277023a5 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -898,7 +898,7 @@ static int fuse_uring_args_to_ring(struct fuse_req *req,
if (copy_size > ent->payload.iov_len) {
fuse_copy_finish(&cs);
- return args->opcode == FUSE_SETXATTR ? -E2BIG : -EIO;
+ return fuse_req_too_large_error(args);
}
/* copy the payload */
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 4b412a76225f..5435ee069b4c 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -13,6 +13,8 @@
#include <linux/workqueue.h>
#include <linux/fs.h>
+#include "args.h"
+
/* Ordinary requests have even IDs, while interrupts IDs are odd */
#define FUSE_INT_REQ_BIT (1ULL << 0)
#define FUSE_REQ_ID_STEP (1ULL << 1)
@@ -367,6 +369,16 @@ static inline struct fuse_dev *__fuse_get_dev(struct file *file)
return fud;
}
+/*
+ * A request that does not fit the server's buffer is rejected with -EIO.
+ * SETXATTR is special, since it may contain too large data, and is
+ * rejected with -E2BIG like the VFS setxattr path.
+ */
+static inline int fuse_req_too_large_error(struct fuse_args *args)
+{
+ return args->opcode == FUSE_SETXATTR ? -E2BIG : -EIO;
+}
+
void fuse_iqueue_init(struct fuse_iqueue *fiq, const struct fuse_iqueue_ops *ops, void *priv);
struct fuse_dev *fuse_get_dev(struct file *file);
--
2.43.0