Re: [PATCH v9 10/17] cifs: Implement fileattr_get for case sensitivity

Steve French
2026-04-23T00:59:58Z

Acked-by: Steve French <stfrench@microsoft.com>

Do you know which xfstests this would enable? IIRC a few of them
depend on the fs supporting fileattr_get

On Wed, Apr 22, 2026 at 6:34 PM Chuck Lever <cel@kernel.org> wrote:
>
> From: Chuck Lever <chuck.lever@oracle.com>
>
> Upper layers such as NFSD need a way to query whether a filesystem
> handles filenames in a case-sensitive manner. Report CIFS/SMB case
> handling behavior via the FS_XFLAG_CASEFOLD flag.
>
> CIFS servers (typically Windows or Samba) are usually case-insensitive
> but case-preserving, meaning they ignore case during lookups but store
> filenames exactly as provided.
>
> The implementation reports case sensitivity based on the nocase mount
> option, which reflects whether the client expects the server to perform
> case-insensitive comparisons. When nocase is set, the mount is reported
> as case-insensitive.
>
> The callback is registered in all three inode_operations structures
> (directory, file, and symlink) to ensure consistent reporting across
> all inode types.
>
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
> fs/smb/client/cifsfs.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
> index 2025739f070a..9b70ffa3e01d 100644
> --- a/fs/smb/client/cifsfs.c
> +++ b/fs/smb/client/cifsfs.c
> @@ -30,6 +30,7 @@
> #include <linux/xattr.h>
> #include <linux/mm.h>
> #include <linux/key-type.h>
> +#include <linux/fileattr.h>
> #include <uapi/linux/magic.h>
> #include <net/ipv6.h>
> #include "cifsfs.h"
> @@ -1199,6 +1200,22 @@ struct file_system_type smb3_fs_type = {
> MODULE_ALIAS_FS("smb3");
> MODULE_ALIAS("smb3");
>
> +static int cifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> +{
> + struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb);
> + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
> +
> + /*
> + * The nocase mount option installs case-insensitive dentry
> + * operations on this superblock. SMB preserves case on the
> + * wire and at rest, so the mount matches FS_XFLAG_CASEFOLD
> + * semantics: case-folded lookup, verbatim storage.
> + */
> + if (tcon->nocase)
> + fa->fsx_xflags |= FS_XFLAG_CASEFOLD;
> + return 0;
> +}
> +
> const struct inode_operations cifs_dir_inode_ops = {
> .create = cifs_create,
> .atomic_open = cifs_atomic_open,
> @@ -1217,6 +1234,7 @@ const struct inode_operations cifs_dir_inode_ops = {
> .listxattr = cifs_listxattr,
> .get_acl = cifs_get_acl,
> .set_acl = cifs_set_acl,
> + .fileattr_get = cifs_fileattr_get,
> };
>
> const struct inode_operations cifs_file_inode_ops = {
> @@ -1227,6 +1245,7 @@ const struct inode_operations cifs_file_inode_ops = {
> .fiemap = cifs_fiemap,
> .get_acl = cifs_get_acl,
> .set_acl = cifs_set_acl,
> + .fileattr_get = cifs_fileattr_get,
> };
>
> const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
> @@ -1261,6 +1280,7 @@ const struct inode_operations cifs_symlink_inode_ops = {
> .setattr = cifs_setattr,
> .permission = cifs_permission,
> .listxattr = cifs_listxattr,
> + .fileattr_get = cifs_fileattr_get,
> };
>
> /*
>
> --
> 2.53.0
>
>

--
Thanks,

Steve