Skip to contentSkip to conversation

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

PATCH New Moinak Bhattacharyya 1 participant 1 message Feb 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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(-)
fs/fuse/dev.c +0 -6
index 5b5f789b37eb..da1f4e8ed3ea 100644
@@ -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;
 
fs/fuse/fuse_i.h +2 -0
index fee96fe7887b..5cb7ab17ad17 100644
@@ -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
 
 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)