diff mbox series

fuse: return -EOPNOTSUPP directly from backing_open and backing_close when PASSTHROUGH not supported

Message ID 2cd2a86e-587e-41f8-a3a7-883dd02ac5fe@gmail.com (mailing list archive)
State New
Headers show
Series fuse: return -EOPNOTSUPP directly from backing_open and backing_close when PASSTHROUGH not supported | expand

Commit Message

Moinak Bhattacharyya Feb. 22, 2025, 10:28 p.m. UTC
Instead of having individual early returns in the ioctl functions, 
create static inline functions that return -EOPNOTSUPP when passthrough 
is not enabled. This will help potentially adding uring_cmd support to 
opening backing files.
---
  fs/fuse/dev.c    |  6 ------
  fs/fuse/fuse_i.h | 13 +++++++++++--
  2 files changed, 11 insertions(+), 8 deletions(-)

  static inline struct fuse_backing *fuse_backing_get(struct 
fuse_backing *fb)
@@ -1495,12 +1497,19 @@ static inline struct fuse_backing 
*fuse_backing_get(struct fuse_backing *fb)
  static inline void fuse_backing_put(struct fuse_backing *fb)
  {
  }
+
+static inline int fuse_backing_open(struct fuse_conn *fc, struct 
fuse_backing_map *map)
+{
+       return -EOPNOTSUPP;
+}
+static inline int fuse_backing_close(struct fuse_conn *fc, int backing_id)
+{
+       return -EOPNOTSUPP;
+}
  #endif

  void fuse_backing_files_init(struct fuse_conn *fc);
  void fuse_backing_files_free(struct fuse_conn *fc);
-int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map);
-int fuse_backing_close(struct fuse_conn *fc, int backing_id);

  struct fuse_backing *fuse_passthrough_open(struct file *file,
                                            struct inode *inode,
--
2.39.5 (Apple Git-154)
diff mbox series

Patch

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 5b5f789b37eb..da1f4e8ed3ea 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2435,9 +2435,6 @@  static long fuse_dev_ioctl_backing_open(struct 
file *file,
         if (!fud)
                 return -EPERM;

-       if (!IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))
-               return -EOPNOTSUPP;
-
         if (copy_from_user(&map, argp, sizeof(map)))
                 return -EFAULT;

@@ -2452,9 +2449,6 @@  static long fuse_dev_ioctl_backing_close(struct 
file *file, __u32 __user *argp)
         if (!fud)
                 return -EPERM;

-       if (!IS_ENABLED(CONFIG_FUSE_PASSTHROUGH))
-               return -EOPNOTSUPP;
-
         if (get_user(backing_id, argp))
                 return -EFAULT;

diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index fee96fe7887b..5cb7ab17ad17 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1485,6 +1485,8 @@  static inline struct fuse_backing 
*fuse_inode_backing_set(struct fuse_inode *fi,
  #ifdef CONFIG_FUSE_PASSTHROUGH
  struct fuse_backing *fuse_backing_get(struct fuse_backing *fb);
  void fuse_backing_put(struct fuse_backing *fb);
+int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map);
+int fuse_backing_close(struct fuse_conn *fc, int backing_id);
  #else