Re: [PATCH v2 1/6] fs: Add case sensitivity info to file_kattr

Christian Brauner
2025-12-15T12:38:05Z

On Thu, Dec 11, 2025 at 10:21:11AM -0500, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
>
> Enable upper layers such as NFSD to retrieve case sensitivity
> information from file systems by adding a case_info field to struct
> file_kattr.
>
> Add vfs_get_case_info() as a convenience helper for kernel
> consumers. If a filesystem does not provide a fileattr_get hook, it
> returns the default POSIX behavior (case-sensitive,
> case-preserving), which is correct for the majority of Linux
> file systems implementations.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---

Thanks for listening and plumbing this into file_attr() that seems a
much better place than statx().

> fs/file_attr.c | 31 +++++++++++++++++++++++++++++++
> include/linux/fileattr.h | 23 +++++++++++++++++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/fs/file_attr.c b/fs/file_attr.c
> index 1dcec88c0680..609e890b5101 100644
> --- a/fs/file_attr.c
> +++ b/fs/file_attr.c
> @@ -94,6 +94,37 @@ int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> }
> EXPORT_SYMBOL(vfs_fileattr_get);
>
> +/**
> + * vfs_get_case_info - retrieve case sensitivity info for a filesystem
> + * @dentry: the object to retrieve from
> + * @case_info: pointer to store result
> + *
> + * Call i_op->fileattr_get() to retrieve case sensitivity information.
> + * If the filesystem does not provide a fileattr_get hook, return
> + * the default POSIX behavior (case-sensitive, case-preserving).
> + *
> + * Return: 0 on success, or a negative error on failure.
> + */
> +int vfs_get_case_info(struct dentry *dentry, u32 *case_info)

Hm, I would much prefer if we followed the statx() model where we have
vfs_getattr{_nosec}() that always returns a struct kstat. So we should
only have vfs_fileattr_get() instead of the special-purpose
vfs_get_case_info() thing.

I guess the main reason you did this is so that you can set the default
without having to touch each filesystem that doesn't do file_attr.

So just move the default setup of case_info into vfs_fileattr_get()?
This way it's also available to other callers of this function such as
overlayfs and ecryptfs. And then just call that in nfsd.

Otherwise I have no complaints about the VFS part.