On Tue, Oct 6, 2026 at 8:01 PM Miklos Szeredi <[email protected]> wrote:
>
> Add support for server allocated 64-bit backing IDs alongside the
> existing kernel allocated 32-bit IDs.
>
> Opened with FUSE_DEV_IOC_BACKING_CREATE, the backing ID sent via
> fuse_backing_create_in.backing_id.
>
> Closed with FUSE_NOTIFY_BACKING_REMOVE. Since close only provides the
> backing ID, not the file descriptor, it doesn't have to be done with an
> ioctl.
>
> Backing ID can take any 64 bit value other than zero.
>
> Signed-off-by: Miklos Szeredi <[email protected]>
> ---
> fs/fuse/backing.c | 179 ++++++++++++++++++++++++++++----------
> fs/fuse/dev.c | 24 +++++
> fs/fuse/dev.h | 3 +
> fs/fuse/fuse_i.h | 24 ++++-
> fs/fuse/inode.c | 15 +++-
> fs/fuse/notify.c | 28 ++++++
> fs/fuse/passthrough.c | 3 +
> include/uapi/linux/fuse.h | 22 ++++-
[...]
> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index cbb10e19e7e8..b5b51865d59f 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -1408,13 +1408,24 @@ static void process_init_reply(struct fuse_args
> *args, int error)
> * them together.
> */
> if (IS_ENABLED(CONFIG_FUSE_PASSTHROUGH) &&
> - (flags & FUSE_PASSTHROUGH) &&
> + (flags & (FUSE_PASSTHROUGH |
> FUSE_PASSTHROUGH_V2)) &&
> arg->max_stack_depth > 0 &&
> arg->max_stack_depth <=
> FILESYSTEM_MAX_STACK_DEPTH &&
> !(flags & FUSE_WRITEBACK_CACHE)) {
> fc->passthrough = 1;
> fc->max_stack_depth = arg->max_stack_depth;
> fm->sb->s_stack_depth = arg->max_stack_depth;
> + if (flags & FUSE_PASSTHROUGH_V2) {
Since I was contemplating myself on whether I should also add an init flag
FUSE_PASSTHROUGH_INO, it occured to me that arg->max_stack_depth
has plenty of spare bits to host FUSE_PASSTHROUGH_* feature flags.
So if we rebrand it as arg->passthrough_params
#define FUSE_PASSTROUGH_PARAMS(max_backing_stack_depth, flags) \
((max_backing_stack_depth & 0xff) + 1) | ((flags & 0xff) << 8)
We could use a feature flag FUSE_PASSTROUGH_SERVER_ID_64
instead of wasting another init flag
It also avoid the unneeded questions/documentation/awkwardness
regarding FUSE_PASSTHROUGH_V2 with/out FUSE_PASSTHROUGH
But mostly, it leaves room for more extensions.
> + /* Prevent race with
> fuse_backing_open() */
> + scoped_guard(spinlock, &fc->lock) {
> + if (fc->backing_id_32)
> + ok = false;
> + else
> + fc->backing_id_64 =
> true;
> + }
> + if (ok)
> +
> fuse_backing_files_init_64(fc);
> + }
See my comments on backing_id_32 gating on the v2 patch.
Thanks,
Amir.