]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fuse: implement open in passthrough mode
authorAmir Goldstein <amir73il@gmail.com>
Fri, 9 Feb 2024 15:14:50 +0000 (17:14 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 5 Mar 2024 12:40:42 +0000 (13:40 +0100)
commit4a90451bbc7f7fde94041fbb9ca96dd915069943
treecc15dfbe11bae5fade8742be0732ca0a3e8bf7fa
parentfc8ff397b2a91590031ae08534de627f957005cb
fuse: implement open in passthrough mode

After getting a backing file id with FUSE_DEV_IOC_BACKING_OPEN ioctl,
a FUSE server can reply to an OPEN request with flag FOPEN_PASSTHROUGH
and the backing file id.

The FUSE server should reuse the same backing file id for all the open
replies of the same FUSE inode and open will fail (with -EIO) if a the
server attempts to open the same inode with conflicting io modes or to
setup passthrough to two different backing files for the same FUSE inode.
Using the same backing file id for several different inodes is allowed.

Opening a new file with FOPEN_DIRECT_IO for an inode that is already
open for passthrough is allowed, but only if the FOPEN_PASSTHROUGH flag
and correct backing file id are specified as well.

The read/write IO of such files will not use passthrough operations to
the backing file, but mmap, which does not support direct_io, will use
the backing file insead of using the page cache as it always did.

Even though all FUSE passthrough files of the same inode use the same
backing file as a backing inode reference, each FUSE file opens a unique
instance of a backing_file object to store the FUSE path that was used
to open the inode and the open flags of the specific open file.

The per-file, backing_file object is released along with the FUSE file.
The inode associated fuse_backing object is released when the last FUSE
passthrough file of that inode is released AND when the backing file id
is closed by the server using the FUSE_DEV_IOC_BACKING_CLOSE ioctl.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c
fs/fuse/fuse_i.h
fs/fuse/iomode.c
fs/fuse/passthrough.c