[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251211152116.480799-6-cel@kernel.org>
Date: Thu, 11 Dec 2025 10:21:15 -0500
From: Chuck Lever <cel@...nel.org>
To: Al Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>
Cc: <linux-fsdevel@...r.kernel.org>,
linux-ext4@...r.kernel.org,
<linux-nfs@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
hirofumi@...l.parknet.co.jp,
almaz.alexandrovich@...agon-software.com,
tytso@....edu,
adilger.kernel@...ger.ca,
Volker.Lendecke@...net.de,
Chuck Lever <chuck.lever@...cle.com>
Subject: [PATCH v2 5/6] nfsd: Report export case-folding via NFSv3 PATHCONF
From: Chuck Lever <chuck.lever@...cle.com>
Replace the hard-coded MSDOS_SUPER_MAGIC check in
nfsd3_proc_pathconf() with a real check of the export's case
behavior settings. Filesystems that implement ->fileattr_get can
then report their case sensitivity behavior to NFSv3 clients. For
filesystems without ->fileattr_get, the default POSIX behavior
(case-sensitive, case-preserving) is reported to NFSv3 clients.
Signed-off-by: Chuck Lever <chuck.lever@...cle.com>
---
fs/nfsd/nfs3proc.c | 18 ++++++++++--------
fs/nfsd/vfs.c | 25 +++++++++++++++++++++++++
fs/nfsd/vfs.h | 2 ++
3 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index b6d03e1ef5f7..c8c76819cfbc 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -721,17 +721,19 @@ nfsd3_proc_pathconf(struct svc_rqst *rqstp)
if (resp->status == nfs_ok) {
struct super_block *sb = argp->fh.fh_dentry->d_sb;
+ bool case_insensitive, case_preserving;
- /* Note that we don't care for remote fs's here */
- switch (sb->s_magic) {
- case EXT2_SUPER_MAGIC:
+ if (sb->s_magic == EXT2_SUPER_MAGIC) {
resp->p_link_max = EXT2_LINK_MAX;
resp->p_name_max = EXT2_NAME_LEN;
- break;
- case MSDOS_SUPER_MAGIC:
- resp->p_case_insensitive = 1;
- resp->p_case_preserving = 0;
- break;
+ }
+
+ resp->status = nfsd_get_case_info(&argp->fh,
+ &case_insensitive,
+ &case_preserving);
+ if (resp->status == nfs_ok) {
+ resp->p_case_insensitive = case_insensitive;
+ resp->p_case_preserving = case_preserving;
}
}
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 9cb20d4aeab1..157ddf405a5d 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -32,6 +32,7 @@
#include <linux/writeback.h>
#include <linux/security.h>
#include <linux/sunrpc/xdr.h>
+#include <linux/fileattr.h>
#include "xdr3.h"
@@ -2679,3 +2680,27 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
return err? nfserrno(err) : 0;
}
+
+/**
+ * nfsd_get_case_info - get case sensitivity info for a file handle
+ * @fhp: file handle that has already been verified
+ * @case_insensitive: output, true if the filesystem is case-insensitive
+ * @case_preserving: output, true if the filesystem preserves case
+ *
+ * Returns nfs_ok on success, or an nfserr on failure.
+ */
+__be32
+nfsd_get_case_info(struct svc_fh *fhp, bool *case_insensitive,
+ bool *case_preserving)
+{
+ u32 case_info;
+ int err;
+
+ err = vfs_get_case_info(fhp->fh_dentry, &case_info);
+ if (err)
+ return nfserrno(err);
+
+ *case_insensitive = (case_info & FILEATTR_CASEFOLD_TYPE) != 0;
+ *case_preserving = (case_info & FILEATTR_CASE_PRESERVING) != 0;
+ return nfs_ok;
+}
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 0c0292611c6d..a80177744325 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -154,6 +154,8 @@ __be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *,
loff_t *, struct readdir_cd *, nfsd_filldir_t);
__be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *,
struct kstatfs *, int access);
+__be32 nfsd_get_case_info(struct svc_fh *fhp, bool *case_insensitive,
+ bool *case_preserving);
__be32 nfsd_permission(struct svc_cred *cred, struct svc_export *exp,
struct dentry *dentry, int acc);
--
2.52.0
Powered by blists - more mailing lists