Skip to content

RFC: Extend fuse-passthrough to directories

Paul Lawrence linux-fsdevel lkml oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2fuse: Add backing file option to lookupfs/fuse/Kconfig fs/fuse/Makefile fs/fuse/backing.c +5 more+273 -380 replies
1/2fuse: Allow backing file to be set at lookup (WIP)fs/fuse/dir.c fs/fuse/fuse_i.h fs/fuse/iomode.c +2 more+94 -171 reply
2/2fuse: open/close backing filefs/fuse/backing.c fs/fuse/dir.c fs/fuse/file.c +1 more+130 -270 replies
2/2fuse: Add passthrough for mkdir and rmdir (WIP)fs/fuse/dir.c fs/fuse/fuse_i.h fs/fuse/passthrough.c +1 more+56 -31 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/2] RFC: Extend fuse-passthrough to directories

This is the first part of a much larger patch set that would allow a directory to be marked ‘passthrough’. At a high level, the fuse daemon can return an optional extra argument to FUSE_LOOKUP that contains an fd. Extra fields are added to the fuse_dentry, fuse_inode and fuse_file structs to have a backing path, inode and file respectively. When fuse is performing an operation, it will check for the existence of a backing object and if it exists forward the operation to the backing object.

These two patches add the core infrastructure, handling of the extra argument response to lookup, and forwarding open, flush and close to the backing file. This is sufficient to validate the concept.

The questions I have:

* Is this something that interests the fuse maintainers and community?
* Is this approach the correct one?
* (if we agree yes to 1 & 2) Detailed analysis of the patches for errors.

A few observations:

I have matched backing objects to their fuse objects. Currently fuse passthrough puts a backing file into the fuse inode. I’m not quite sure why this was done - it seems to have been a very late change in the passthrough patch sets which happened without comment. It does not really make sense for full directory passthrough since unopened inodes still need to have backing inodes. The one advantage I can see is that it reduces the number of opens/closes of the backing file. However, this may also be a disadvantage - it moves closes, in particular, to an arbitrary point when the inode is flushed from cache.

Backing operations need to happen in the context of the daemon, not the caller. (I am a firm believer of this principle.) This is not yet implemented, and is not (currently, and unfortunately) the way Android uses passthough. It is not hard to do, and if these patches are otherwise acceptable, will be added.

There was a long discussion about the security issues of using an fd returned from the fuse daemon in the context of fuse passthrough, and the end solution was to use an ioctl to set the backing file. I have used the previously-rejected approach of passing the fd in a struct in the fuse_daemon response. My defense of this approach is

* The fd is simply used to pull out the path and inode
* All operations are revalidated
* Thus there is no risk even if a privileged process with a protected fd is tricked into passing that fd back in this structure.

I’m sure we will discuss this at length if this patch set is otherwise deemed valuable, and I am certainly not wedded to this approach.

I have written tests to validate this approach using tools/testing/selftests. I don’t want this patch set to get derailed by a discussion of the way I wrote the tests, so I have not included them. I am very open to any and every suggestion as to how (and where) tests should be written for these patches.

Paul Lawrence (2):
fuse: Add backing file option to lookup
fuse: open/close backing file

 fs/fuse/Kconfig           |  13 +++++
 fs/fuse/Makefile          |   1 +
 fs/fuse/backing.c         |  97 ++++++++++++++++++++++++++++++++
 fs/fuse/dev.c             |  14 +++++
 fs/fuse/dir.c             | 108 +++++++++++++++++++++++++-----------
 fs/fuse/file.c            |  34 ++++++++----
 fs/fuse/fuse_i.h          |  61 +++++++++++++++++++-
 fs/fuse/inode.c           | 114 ++++++++++++++++++++++++++++++++++----
 include/uapi/linux/fuse.h |   4 ++
 9 files changed, 392 insertions(+), 54 deletions(-)
 create mode 100644 fs/fuse/backing.c
Signature · 1 line
2.49.0.1112.g889b7c5bd8-goog