fs: name_to_handle_at() support for "explicit connectable" file handles
authorAmir Goldstein <amir73il@gmail.com>
Fri, 11 Oct 2024 09:00:22 +0000 (11:00 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 15 Nov 2024 10:34:57 +0000 (11:34 +0100)
commitc374196b2b9f4b803fccd59ed82f0712041e21e1
treef8ac07aa4e5f901cf554c6207447d514777d1fc0
parent4a530a7c751d27f9dbd70b7fc45670cd11713b13
fs: name_to_handle_at() support for "explicit connectable" file handles

nfsd encodes "connectable" file handles for the subtree_check feature,
which can be resolved to an open file with a connected path.
So far, userspace nfs server could not make use of this functionality.

Introduce a new flag AT_HANDLE_CONNECTABLE to name_to_handle_at(2).
When used, the encoded file handle is "explicitly connectable".

The "explicitly connectable" file handle sets bits in the high 16bit of
the handle_type field, so open_by_handle_at(2) will know that it needs
to open a file with a connected path.

old kernels will now recognize the handle_type with high bits set,
so "explicitly connectable" file handles cannot be decoded by
open_by_handle_at(2) on old kernels.

The flag AT_HANDLE_CONNECTABLE is not allowed together with either
AT_HANDLE_FID or AT_EMPTY_PATH.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20241011090023.655623-3-amir73il@gmail.com
Fixes: 570df4e9c23f ("ceph: snapshot nfs re-export")
Acked-by:
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/fhandle.c
include/linux/exportfs.h
include/uapi/linux/fcntl.h