From eca63dab456a10c3491c367711ab18cbcb34816e Mon Sep 17 00:00:00 2001 From: Amir Goldstein Date: Mon, 13 May 2024 16:30:25 +0300 Subject: Enable passthrough mode for read/write operations (#919) Add support for filesystem passthrough read/write of files. When the FUSE_PASSTHROUGH capability is enabled, the FUSE server may decide, while handling the "open" or "create" requests, if the given file can be accessed by that process in "passthrough" mode, meaning that all the further read and write operations would be forwarded by the kernel directly to the backing file rather than to the FUSE server. All requests other than read or write are still handled by the server. This allows for an improved performance on reads and writes, especially in the case of reads at random offsets, for which no (readahead) caching mechanism would help, reducing the performance gap between FUSE and native filesystem access. Extend also the passthrough_hp example with the new passthrough feature. This example opens a kernel backing file per FUSE inode on the first FUSE file open of that inode and closes the backing file on the release of the last FUSE file on that inode. All opens of the same inode passthrough to the same backing file. A combination of fi->direct_io and fi->passthrough is allowed. It means that read/write operations go directly to the server, but mmap is done on the backing file. This allows to open some fds of the inode in passthrough mode and some fd of the same inode in direct_io/passthrough_mmap mode. Signed-off-by: Alessio Balsini Signed-off-by: Amir Goldstein --- include/fuse_lowlevel.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/fuse_lowlevel.h') diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index 2ada62b..cb38115 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -1396,6 +1396,19 @@ int fuse_reply_attr(fuse_req_t req, const struct stat *attr, */ int fuse_reply_readlink(fuse_req_t req, const char *link); +/** + * Setup passthrough backing file for open reply + * + * Possible requests: + * open, opendir, create + * + * @param req request handle + * @param fd backing file descriptor + * @return positive backing id for success, 0 for failure + */ +int fuse_passthrough_open(fuse_req_t req, int fd); +int fuse_passthrough_close(fuse_req_t req, int backing_id); + /** * Reply with open parameters * -- cgit v1.2.3