linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fuse: Return EPERM rather than ENOSYS from link()
@ 2025-02-14  1:17 Matt Johnston
  2025-02-14 10:06 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Johnston @ 2025-02-14  1:17 UTC (permalink / raw)
  To: Miklos Szeredi; +Cc: linux-fsdevel, Matt Johnston

link() is documented to return EPERM when a filesystem doesn't support
the operation, return that instead.

Link: https://github.com/libfuse/libfuse/issues/925
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
 fs/fuse/dir.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 198862b086ff7bad4007ec2f3200377d12a78385..f07ccaefd1ecfe02b806c30fa9edc6f481260ee8 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1137,6 +1137,8 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
 	else if (err == -EINTR)
 		fuse_invalidate_attr(inode);
 
+	if (err == -ENOSYS)
+		err = -EPERM;
 	return err;
 }
 

---
base-commit: 68763b29e0a6441f57f9ee652bbf8e7bc59183e5
change-id: 20250214-fuse-link-eperm-544b081eac34

Best regards,
-- 
Matt Johnston <matt@codeconstruct.com.au>


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

* Re: [PATCH] fuse: Return EPERM rather than ENOSYS from link()
  2025-02-14  1:17 [PATCH] fuse: Return EPERM rather than ENOSYS from link() Matt Johnston
@ 2025-02-14 10:06 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2025-02-14 10:06 UTC (permalink / raw)
  To: Matt Johnston; +Cc: linux-fsdevel

On Fri, 14 Feb 2025 at 02:18, Matt Johnston <matt@codeconstruct.com.au> wrote:
>
> link() is documented to return EPERM when a filesystem doesn't support
> the operation, return that instead.

Applied, thanks.

Also added the following optimization patch if link is not supported.

Thanks,
Miklos

From 150b838b03e887f4e5ffdadcffafef698e34c619 Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <mszeredi@redhat.com>
Date: Fri, 14 Feb 2025 11:00:53 +0100
Subject: [PATCH] fuse: optmize missing FUSE_LINK support

If filesystem doesn't support FUSE_LINK (i.e. returns -ENOSYS), then
remember this and next time return immediately, without incurring the
overhead of a round trip to the server.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/fuse/dir.c    | 9 ++++++++-
 fs/fuse/fuse_i.h | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index f07ccaefd1ec..589e88822368 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1123,6 +1123,9 @@ static int fuse_link(struct dentry *entry,
struct inode *newdir,
        struct fuse_mount *fm = get_fuse_mount(inode);
        FUSE_ARGS(args);

+       if (fm->fc->no_link)
+               goto out;
+
        memset(&inarg, 0, sizeof(inarg));
        inarg.oldnodeid = get_node_id(inode);
        args.opcode = FUSE_LINK;
@@ -1138,7 +1141,11 @@ static int fuse_link(struct dentry *entry,
struct inode *newdir,
                fuse_invalidate_attr(inode);

        if (err == -ENOSYS)
-               err = -EPERM;
+               fm->fc->no_link = 1;
+out:
+       if (fm->fc->no_link)
+               return -EPERM;
+
        return err;
 }

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index fee96fe7887b..3ad5d4b8f7c5 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -867,6 +867,9 @@ struct fuse_conn {
        /* Use pages instead of pointer for kernel I/O */
        unsigned int use_pages_for_kvec_io:1;

+       /* Is link not implemented by fs? */
+       unsigned int no_link:1;
+
        /* Use io_uring for communication */
        unsigned int io_uring;

-- 
2.48.1

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

end of thread, other threads:[~2025-02-14 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14  1:17 [PATCH] fuse: Return EPERM rather than ENOSYS from link() Matt Johnston
2025-02-14 10:06 ` Miklos Szeredi

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).