mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stanislav Kinsburskii <skinsburskii@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: fuse-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	 Robet Byrnes <byrnes@wildpumpkin.net>,
	 Stanislav Kinsburskii <skinsburskii@gmail.com>
Subject: [PATCH] fuse: Cache unsupported ioctl requests
Date: Mon, 14 Sep 2026 11:36:48 -0700	[thread overview]
Message-ID: <20260914-fuse-cache-no-ioctl-v1-1-70a05053ef0f@gmail.com> (raw)

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 <byrnes@wildpumpkin.net>
Signed-off-by: Stanislav Kinsburskii <skinsburskii@gmail.com>
---
 fs/fuse/fuse_i.h |  3 +++
 fs/fuse/ioctl.c  | 12 ++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 97d356588d00..e9d8b48069dd 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -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;
 
diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index dc3a188f5d72..3ae50a25064b 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -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,
-- 
Stanislav Kinsburskii <skinsburskii@gmail.com>


                 reply	other threads:[~2026-09-14 18:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260914-fuse-cache-no-ioctl-v1-1-70a05053ef0f@gmail.com \
    --to=skinsburskii@gmail.com \
    --cc=byrnes@wildpumpkin.net \
    --cc=fuse-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®