[RFC PATCH v2 02/11] NFSD: factor out nfsd_supports_nfs4_acl() to nfsd/acl.h

Mike Snitzer
2026-02-24T19:24:42Z

Check both IS_POSIXACL() and exportfs_may_passthru_nfs4acl() to
prepare for passing through nfs4_acl directly to NFSv4 filesystem
(NFSv4 will set EXPORT_OP_NFSV4_ACL_PASSTHRU flag in later commit).

Signed-off-by: Mike Snitzer <snitzer@hammerspace.com>
---
fs/nfsd/acl.h | 8 ++++++++
fs/nfsd/nfs4proc.c | 2 +-
fs/nfsd/nfs4xdr.c | 6 +++---
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/acl.h b/fs/nfsd/acl.h
index 2003523d0e65..699a3b19bdb8 100644
--- a/fs/nfsd/acl.h
+++ b/fs/nfsd/acl.h
@@ -35,6 +35,8 @@
#ifndef LINUX_NFS4_ACL_H
#define LINUX_NFS4_ACL_H

+#include <linux/exportfs.h>
+
struct nfs4_acl;
struct svc_fh;
struct svc_rqst;
@@ -51,4 +53,10 @@ __be32 nfsd4_acl_to_attr(enum nfs_ftype4 type, struct nfs4_acl *acl,
struct nfsd_attrs *attr);
void sort_pacl_range(struct posix_acl *pacl, int start, int end);

+static inline bool nfsd_supports_nfs4_acl(struct dentry *dentry)
+{
+ return IS_POSIXACL(d_inode(dentry)) ||
+ exportfs_may_passthru_nfs4acl(dentry->d_sb->s_export_op);
+}
+
#endif /* LINUX_NFS4_ACL_H */
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 85e94c30285a..bd847db8b8b4 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -89,7 +89,7 @@ check_attr_support(struct nfsd4_compound_state *cstate, u32 *bmval,

if (!nfsd_attrs_supported(cstate->minorversion, bmval))
return nfserr_attrnotsupp;
- if ((bmval[0] & FATTR4_WORD0_ACL) && !IS_POSIXACL(d_inode(dentry)))
+ if ((bmval[0] & FATTR4_WORD0_ACL) && !nfsd_supports_nfs4_acl(dentry))
return nfserr_attrnotsupp;
if ((bmval[2] & (FATTR4_WORD2_POSIX_DEFAULT_ACL |
FATTR4_WORD2_POSIX_ACCESS_ACL)) &&
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 07c48b74c559..e7793c53d214 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3195,7 +3195,7 @@ static __be32 nfsd4_encode_fattr4_supported_attrs(struct xdr_stream *xdr,
u32 supp[3];

memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp));
- if (!IS_POSIXACL(d_inode(args->dentry)))
+ if (!nfsd_supports_nfs4_acl(args->dentry))
supp[0] &= ~FATTR4_WORD0_ACL;
if (!args->contextsupport)
supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
@@ -3328,7 +3328,7 @@ static __be32 nfsd4_encode_fattr4_aclsupport(struct xdr_stream *xdr,
u32 mask;

mask = 0;
- if (IS_POSIXACL(d_inode(args->dentry)))
+ if (nfsd_supports_nfs4_acl(args->dentry))
mask = ACL4_SUPPORT_ALLOW_ACL | ACL4_SUPPORT_DENY_ACL;
return nfsd4_encode_uint32_t(xdr, mask);
}
@@ -3600,7 +3600,7 @@ static __be32 nfsd4_encode_fattr4_suppattr_exclcreat(struct xdr_stream *xdr,
u32 supp[3];

memcpy(supp, nfsd_suppattrs[resp->cstate.minorversion], sizeof(supp));
- if (!IS_POSIXACL(d_inode(args->dentry)))
+ if (!nfsd_supports_nfs4_acl(args->dentry))
supp[0] &= ~FATTR4_WORD0_ACL;
if (!args->contextsupport)
supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
--
2.44.0