fuse: Cache unsupported ioctl requests
PATCH 1/1 fuse: Cache unsupported ioctl requests
A server that does not implement FUSE_IOCTL returns -ENOSYS for each request. Cache this response on the connection and return -ENOTTY for subsequent ioctl requests without contacting the server.
Only cache request-level -ENOSYS. Errors in fuse_ioctl_out.result apply to individual commands and must not disable ioctl support for the connection.
Check the cached flag before preparing regular ioctl requests and before opening a file for file-attribute ioctls, avoiding unnecessary allocations and open/release requests.
Signed-off-by Robet Byrnes <[email protected]>
Signed-off-by Stanislav Kinsburskii <[email protected]>
--- fs/fuse/fuse_i.h | 3 +++ fs/fuse/ioctl.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
fs/fuse/fuse_i.h +3 -0
@@ -720,6 +720,9 @@ struct fuse_conn {/** @sync_init: Is synchronous FUSE_INIT allowed? */ unsigned int sync_init:1; +/** @no_ioctl: Is ioctl not implemented by fs? */ + unsigned no_ioctl:1; +/** @max_stack_depth: Maximum stack depth for passthrough backing files */ int max_stack_depth;
fs/fuse/ioctl.c +10 -2
@@ -23,9 +23,11 @@ static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args, ret =fuse_simple_request (fm, args); -/* Translate ENOSYS, which shouldn't be returned from fs */ -if (ret == -ENOSYS ) +/* Cache request-level ENOSYS only; outarg->result is per-command. */ +if (ret == -ENOSYS ) { + fm->fc->no_ioctl =1 ; ret = -ENOTTY ; + }if (ret >=0 && outarg->result == -ENOSYS ) outarg->result = -ENOTTY ;
@@ -233,6 +235,9 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,struct iov_iter ii;struct fuse_args_pages ap = {}; +if (fm->fc->no_ioctl) +return -ENOTTY ; +#if BITS_PER_LONG ==32 inarg.flags |=FUSE_IOCTL_32BIT ;#else
@@ -492,6 +497,9 @@ static struct fuse_file *fuse_priv_ioctl_prepare(struct inode *inode)if (!S_ISREG (inode->i_mode) && !isdir)return ERR_PTR (-ENOTTY ); +if (fm->fc->no_ioctl) +return ERR_PTR (-ENOTTY ); +return fuse_file_open (fm,get_node_id (inode),O_RDONLY , isdir); }
---
base-commit: 68142f986ff04b2b70b31db00f719bf690f64a9a
change-id: 20260911-fuse-cache-no-ioctl-1bb573a27597
Best regards,
Signature · 1 line
Stanislav Kinsburskii <[email protected]>