From: Chuck Lever <cel@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-xfs@vger.kernel.org, linux-cifs@vger.kernel.org,
linux-nfs@vger.kernel.org, linux-api@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
hirofumi@mail.parknet.co.jp, linkinjeon@kernel.org,
sj1557.seo@samsung.com, yuezhang.mo@sony.com,
almaz.alexandrovich@paragon-software.com, slava@dubeyko.com,
glaubitz@physik.fu-berlin.de, frank.li@vivo.com, tytso@mit.edu,
adilger.kernel@dilger.ca, cem@kernel.org, sfrench@samba.org,
pc@manguebit.org, ronniesahlberg@gmail.com,
sprasad@microsoft.com, trondmy@kernel.org, anna@kernel.org,
jaegeuk@kernel.org, chao@kernel.org, hansg@kernel.org,
senozhatsky@chromium.org, Chuck Lever <chuck.lever@oracle.com>,
Roland Mainz <roland.mainz@nrubsig.org>
Subject: [PATCH v11 14/15] nfsd: Implement NFSv4 FATTR4_CASE_INSENSITIVE and FATTR4_CASE_PRESERVING
Date: Fri, 24 Apr 2026 21:53:16 -0400 [thread overview]
Message-ID: <20260424-case-sensitivity-v11-14-de5619beddaf@oracle.com> (raw)
In-Reply-To: <20260424-case-sensitivity-v11-0-de5619beddaf@oracle.com>
From: Chuck Lever <chuck.lever@oracle.com>
NFSD currently provides NFSv4 clients with hard-coded responses
indicating all exported filesystems are case-sensitive and
case-preserving. This is incorrect for case-insensitive filesystems
and ext4 directories with casefold enabled.
Query the underlying filesystem's actual case sensitivity via
nfsd_get_case_info() and return accurate values to clients. This
supports per-directory settings for filesystems that allow mixing
case-sensitive and case-insensitive directories within an export.
Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
fs/nfsd/nfs4xdr.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 52 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 2a0946c630e1..68b23863dab1 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3158,6 +3158,8 @@ struct nfsd4_fattr_args {
u32 rdattr_err;
bool contextsupport;
bool ignore_crossmnt;
+ bool case_insensitive;
+ bool case_preserving;
};
typedef __be32(*nfsd4_enc_attr)(struct xdr_stream *xdr,
@@ -3356,6 +3358,33 @@ static __be32 nfsd4_encode_fattr4_acl(struct xdr_stream *xdr,
return nfs_ok;
}
+static __be32 nfsd4_encode_fattr4_case_insensitive(struct xdr_stream *xdr,
+ const struct nfsd4_fattr_args *args)
+{
+ return nfsd4_encode_bool(xdr, args->case_insensitive);
+}
+
+static __be32 nfsd4_encode_fattr4_case_preserving(struct xdr_stream *xdr,
+ const struct nfsd4_fattr_args *args)
+{
+ return nfsd4_encode_bool(xdr, args->case_preserving);
+}
+
+static __be32 nfsd4_encode_fattr4_homogeneous(struct xdr_stream *xdr,
+ const struct nfsd4_fattr_args *args)
+{
+ /*
+ * Filesystems with a Unicode encoding loaded (e.g. ext4, f2fs
+ * with the casefold feature) expose case folding as a
+ * per-directory attribute, so the per-file-system
+ * case_insensitive and case_preserving values can legitimately
+ * differ across objects that share the same fsid. Report
+ * FATTR4_HOMOGENEOUS = FALSE on such filesystems to keep that
+ * variation consistent with RFC 8881 Section 5.8.2.16.
+ */
+ return nfsd4_encode_bool(xdr, !sb_has_encoding(args->dentry->d_sb));
+}
+
static __be32 nfsd4_encode_fattr4_filehandle(struct xdr_stream *xdr,
const struct nfsd4_fattr_args *args)
{
@@ -3748,8 +3777,8 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = {
[FATTR4_ACLSUPPORT] = nfsd4_encode_fattr4_aclsupport,
[FATTR4_ARCHIVE] = nfsd4_encode_fattr4__noop,
[FATTR4_CANSETTIME] = nfsd4_encode_fattr4__true,
- [FATTR4_CASE_INSENSITIVE] = nfsd4_encode_fattr4__false,
- [FATTR4_CASE_PRESERVING] = nfsd4_encode_fattr4__true,
+ [FATTR4_CASE_INSENSITIVE] = nfsd4_encode_fattr4_case_insensitive,
+ [FATTR4_CASE_PRESERVING] = nfsd4_encode_fattr4_case_preserving,
[FATTR4_CHOWN_RESTRICTED] = nfsd4_encode_fattr4__true,
[FATTR4_FILEHANDLE] = nfsd4_encode_fattr4_filehandle,
[FATTR4_FILEID] = nfsd4_encode_fattr4_fileid,
@@ -3758,7 +3787,7 @@ static const nfsd4_enc_attr nfsd4_enc_fattr4_encode_ops[] = {
[FATTR4_FILES_TOTAL] = nfsd4_encode_fattr4_files_total,
[FATTR4_FS_LOCATIONS] = nfsd4_encode_fattr4_fs_locations,
[FATTR4_HIDDEN] = nfsd4_encode_fattr4__noop,
- [FATTR4_HOMOGENEOUS] = nfsd4_encode_fattr4__true,
+ [FATTR4_HOMOGENEOUS] = nfsd4_encode_fattr4_homogeneous,
[FATTR4_MAXFILESIZE] = nfsd4_encode_fattr4_maxfilesize,
[FATTR4_MAXLINK] = nfsd4_encode_fattr4_maxlink,
[FATTR4_MAXNAME] = nfsd4_encode_fattr4_maxname,
@@ -3968,6 +3997,26 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
args.fhp = tempfh;
} else
args.fhp = fhp;
+ if (attrmask[0] & (FATTR4_WORD0_CASE_INSENSITIVE |
+ FATTR4_WORD0_CASE_PRESERVING)) {
+ struct dentry *cd = dentry;
+
+ /*
+ * On casefold-capable file systems the flag lives
+ * on the directory, not on its entries. For a
+ * non-directory object, name-comparison semantics
+ * come from its parent. A directory (including the
+ * export root, whose parent is outside the export)
+ * is queried as-is so its own contents' lookup
+ * behaviour is reported.
+ */
+ if (!d_is_dir(dentry))
+ cd = dentry->d_parent;
+ status = nfsd_get_case_info(cd, &args.case_insensitive,
+ &args.case_preserving);
+ if (status != nfs_ok)
+ goto out;
+ }
if (attrmask[0] & FATTR4_WORD0_ACL) {
err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl);
--
2.53.0
next prev parent reply other threads:[~2026-04-25 1:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-25 1:53 [PATCH v11 00/15] Exposing case folding behavior Chuck Lever
2026-04-25 1:53 ` [PATCH v11 01/15] fs: Move file_kattr initialization to callers Chuck Lever
2026-04-25 1:53 ` [PATCH v11 02/15] fs: Add case sensitivity flags to file_kattr Chuck Lever
2026-04-25 1:53 ` [PATCH v11 03/15] fat: Implement fileattr_get for case sensitivity Chuck Lever
2026-04-25 1:53 ` [PATCH v11 04/15] exfat: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 05/15] ntfs3: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 06/15] hfs: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 07/15] hfsplus: Report case sensitivity in fileattr_get Chuck Lever
2026-04-25 1:53 ` [PATCH v11 08/15] xfs: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 09/15] cifs: Implement fileattr_get for case sensitivity Chuck Lever
2026-04-25 1:53 ` [PATCH v11 10/15] nfs: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 11/15] vboxsf: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 12/15] isofs: " Chuck Lever
2026-04-25 1:53 ` [PATCH v11 13/15] nfsd: Report export case-folding via NFSv3 PATHCONF Chuck Lever
2026-04-25 1:53 ` Chuck Lever [this message]
2026-04-25 1:53 ` [PATCH v11 15/15] ksmbd: Report filesystem case sensitivity via FS_ATTRIBUTE_INFORMATION Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260424-case-sensitivity-v11-14-de5619beddaf@oracle.com \
--to=cel@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=anna@kernel.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=chao@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=hansg@kernel.org \
--cc=hirofumi@mail.parknet.co.jp \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=roland.mainz@nrubsig.org \
--cc=ronniesahlberg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=sfrench@samba.org \
--cc=sj1557.seo@samsung.com \
--cc=slava@dubeyko.com \
--cc=sprasad@microsoft.com \
--cc=trondmy@kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=yuezhang.mo@sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox