public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] Fuse: Add backing file support for uring_cmd
@ 2025-02-21 15:19 Moinak Bhattacharyya
  2025-02-21 15:24 ` Bernd Schubert
  0 siblings, 1 reply; 22+ messages in thread
From: Moinak Bhattacharyya @ 2025-02-21 15:19 UTC (permalink / raw)
  To: Miklos Szeredi, linux-fsdevel, linux-kernel, io-uring

Add support for opening and closing backing files in the
fuse_uring_cmd callback. Store backing_map (for open) and backing_id
(for close) in the uring_cmd data.
---
 fs/fuse/dev_uring.c       | 50 +++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/fuse.h |  6 +++++
 2 files changed, 56 insertions(+)

diff --git a/fs/fuse/dev_uring.c b/fs/fuse/dev_uring.c
index ebd2931b4f2a..df73d9d7e686 100644
--- a/fs/fuse/dev_uring.c
+++ b/fs/fuse/dev_uring.c
@@ -1033,6 +1033,40 @@ fuse_uring_create_ring_ent(struct io_uring_cmd *cmd,
  return ent;
 }

+/*
+ * Register new backing file for passthrough, getting backing map
from URING_CMD data
+ */
+static int fuse_uring_backing_open(struct io_uring_cmd *cmd,
+ unsigned int issue_flags, struct fuse_conn *fc)
+{
+ const struct fuse_backing_map *map = io_uring_sqe_cmd(cmd->sqe);
+ int ret = fuse_backing_open(fc, map);
+
+ if (ret < 0) {
+ return ret;
+ }
+
+ io_uring_cmd_done(cmd, ret, 0, issue_flags);
+ return 0;
+}
+
+/*
+ * Remove file from passthrough tracking, getting backing_id from
URING_CMD data
+ */
+static int fuse_uring_backing_close(struct io_uring_cmd *cmd,
+ unsigned int issue_flags, struct fuse_conn *fc)
+{
+ const int *backing_id = io_uring_sqe_cmd(cmd->sqe);
+ int ret = fuse_backing_close(fc, *backing_id);
+
+ if (ret < 0) {
+ return ret;
+ }
+
+ io_uring_cmd_done(cmd, ret, 0, issue_flags);
+ return 0;
+}
+
 /*
  * Register header and payload buffer with the kernel and puts the
  * entry as "ready to get fuse requests" on the queue
@@ -1144,6 +1178,22 @@ int fuse_uring_cmd(struct io_uring_cmd *cmd,
unsigned int issue_flags)
  return err;
  }
  break;
+ case FUSE_IO_URING_CMD_BACKING_OPEN:
+ err = fuse_uring_backing_open(cmd, issue_flags, fc);
+ if (err) {
+ pr_info_once("FUSE_IO_URING_CMD_BACKING_OPEN failed err=%d\n",
+     err);
+ return err;
+ }
+ break;
+ case FUSE_IO_URING_CMD_BACKING_CLOSE:
+ err = fuse_uring_backing_close(cmd, issue_flags, fc);
+ if (err) {
+ pr_info_once("FUSE_IO_URING_CMD_BACKING_CLOSE failed err=%d\n",
+     err);
+ return err;
+ }
+ break;
  default:
  return -EINVAL;
  }
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h
index 5e0eb41d967e..634265da1328 100644
--- a/include/uapi/linux/fuse.h
+++ b/include/uapi/linux/fuse.h
@@ -1264,6 +1264,12 @@ enum fuse_uring_cmd {

  /* commit fuse request result and fetch next request */
  FUSE_IO_URING_CMD_COMMIT_AND_FETCH = 2,
+
+ /* add new backing file for passthrough */
+ FUSE_IO_URING_CMD_BACKING_OPEN = 3,
+
+ /* remove passthrough file by backing_id */
+ FUSE_IO_URING_CMD_BACKING_CLOSE = 4,
 };

 /**
--
2.39.5 (Apple Git-154)

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

end of thread, other threads:[~2025-02-24 16:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21 15:19 [PATCH] Fuse: Add backing file support for uring_cmd Moinak Bhattacharyya
2025-02-21 15:24 ` Bernd Schubert
2025-02-21 15:36   ` Moinak Bhattacharyya
2025-02-21 16:14     ` Bernd Schubert
2025-02-21 16:17       ` Bernd Schubert
2025-02-21 16:35         ` Amir Goldstein
2025-02-21 17:24           ` Bernd Schubert
2025-02-22 22:33           ` Moinak Bhattacharyya
2025-02-21 16:24     ` Amir Goldstein
2025-02-21 17:13       ` Bernd Schubert
2025-02-21 17:25         ` Amir Goldstein
2025-02-21 17:44           ` Bernd Schubert
2025-02-21 18:13             ` Moinak Bhattacharyya
2025-02-21 18:14               ` Moinak Bhattacharyya
2025-02-21 18:21               ` Amir Goldstein
2025-02-22 22:13                 ` Moinak Bhattacharyya
2025-02-21 18:23               ` Bernd Schubert
2025-02-21 18:31             ` Amir Goldstein
2025-02-24 12:08               ` Miklos Szeredi
2025-02-24 16:06                 ` Moinak Bhattacharyya
2025-02-24 16:24                   ` Miklos Szeredi
2025-02-24 12:27         ` Pavel Begunkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox