summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2023-09-18 09:57:45 -0400
committerChuck Lever <chuck.lever@oracle.com>2023-10-16 12:44:13 -0400
commit36ed7e64947756baa69cfad323898b342bf71a02 (patch)
treed6bec61693b4879bc9275dc448010534894c198a
parentb06cf3754523682ff92fbc0f7702c32a024a4819 (diff)
downloadlinux-stable-36ed7e64947756baa69cfad323898b342bf71a02.tar.gz
linux-stable-36ed7e64947756baa69cfad323898b342bf71a02.tar.bz2
linux-stable-36ed7e64947756baa69cfad323898b342bf71a02.zip
NFSD: Add nfsd4_encode_fattr4_fh_expire_type()
Refactor the encoder for FATTR4_FH_EXPIRE_TYPE into a helper. In a subsequent patch, this helper will be called from a bitmask loop. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r--fs/nfsd/nfs4xdr.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 55fa9f69c1e6..622f74b36d5e 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2927,6 +2927,7 @@ out_resource:
struct nfsd4_fattr_args {
struct svc_rqst *rqstp;
struct svc_fh *fhp;
+ struct svc_export *exp;
struct dentry *dentry;
struct kstat stat;
struct kstatfs statfs;
@@ -3002,6 +3003,17 @@ static __be32 nfsd4_encode_fattr4_type(struct xdr_stream *xdr,
return nfs_ok;
}
+static __be32 nfsd4_encode_fattr4_fh_expire_type(struct xdr_stream *xdr,
+ const struct nfsd4_fattr_args *args)
+{
+ u32 mask;
+
+ mask = NFS4_FH_PERSISTENT;
+ if (!(args->exp->ex_flags & NFSEXP_NOSUBTREECHECK))
+ mask |= NFS4_FH_VOL_RENAME;
+ return nfsd4_encode_uint32_t(xdr, mask);
+}
+
/*
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
* ourselves.
@@ -3041,6 +3053,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
BUG_ON(!nfsd_attrs_supported(minorversion, bmval));
args.rqstp = rqstp;
+ args.exp = exp;
args.dentry = dentry;
args.rdattr_err = 0;
@@ -3141,14 +3154,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
goto out;
}
if (bmval0 & FATTR4_WORD0_FH_EXPIRE_TYPE) {
- p = xdr_reserve_space(xdr, 4);
- if (!p)
- goto out_resource;
- if (exp->ex_flags & NFSEXP_NOSUBTREECHECK)
- *p++ = cpu_to_be32(NFS4_FH_PERSISTENT);
- else
- *p++ = cpu_to_be32(NFS4_FH_PERSISTENT|
- NFS4_FH_VOL_RENAME);
+ status = nfsd4_encode_fattr4_fh_expire_type(xdr, &args);
+ if (status != nfs_ok)
+ goto out;
}
if (bmval0 & FATTR4_WORD0_CHANGE) {
p = xdr_reserve_space(xdr, 8);