Commit 3283bf64 authored by Chuck Lever's avatar Chuck Lever

NFSD: Add nfsd4_encode_fattr4_filehandle()

Refactor the encoder for FATTR4_FILEHANDLE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.

We can de-duplicate the other filehandle encoder (in GETFH) using
our new helper.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 07455dc4
...@@ -2530,6 +2530,12 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) ...@@ -2530,6 +2530,12 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
return true; return true;
} }
static __be32 nfsd4_encode_nfs_fh4(struct xdr_stream *xdr,
struct knfsd_fh *fh_handle)
{
return nfsd4_encode_opaque(xdr, fh_handle->fh_raw, fh_handle->fh_size);
}
static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr, static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr,
struct timespec64 *tv) struct timespec64 *tv)
{ {
...@@ -3125,6 +3131,12 @@ static __be32 nfsd4_encode_fattr4_acl(struct xdr_stream *xdr, ...@@ -3125,6 +3131,12 @@ static __be32 nfsd4_encode_fattr4_acl(struct xdr_stream *xdr,
return nfs_ok; return nfs_ok;
} }
static __be32 nfsd4_encode_fattr4_filehandle(struct xdr_stream *xdr,
const struct nfsd4_fattr_args *args)
{
return nfsd4_encode_nfs_fh4(xdr, &args->fhp->fh_handle);
}
/* /*
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle * Note: @fhp can be NULL; in this case, we might have to compose the filehandle
* ourselves. * ourselves.
...@@ -3344,11 +3356,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, ...@@ -3344,11 +3356,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
goto out; goto out;
} }
if (bmval0 & FATTR4_WORD0_FILEHANDLE) { if (bmval0 & FATTR4_WORD0_FILEHANDLE) {
p = xdr_reserve_space(xdr, args.fhp->fh_handle.fh_size + 4); status = nfsd4_encode_fattr4_filehandle(xdr, &args);
if (!p) if (status != nfs_ok)
goto out_resource; goto out;
p = xdr_encode_opaque(p, &args.fhp->fh_handle.fh_raw,
args.fhp->fh_handle.fh_size);
} }
if (bmval0 & FATTR4_WORD0_FILEID) { if (bmval0 & FATTR4_WORD0_FILEID) {
p = xdr_reserve_space(xdr, 8); p = xdr_reserve_space(xdr, 8);
...@@ -3933,18 +3943,11 @@ static __be32 ...@@ -3933,18 +3943,11 @@ static __be32
nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr,
union nfsd4_op_u *u) union nfsd4_op_u *u)
{ {
struct svc_fh **fhpp = &u->getfh;
struct xdr_stream *xdr = resp->xdr; struct xdr_stream *xdr = resp->xdr;
struct svc_fh *fhp = *fhpp; struct svc_fh *fhp = u->getfh;
unsigned int len;
__be32 *p;
len = fhp->fh_handle.fh_size; /* object */
p = xdr_reserve_space(xdr, len + 4); return nfsd4_encode_nfs_fh4(xdr, &fhp->fh_handle);
if (!p)
return nfserr_resource;
p = xdr_encode_opaque(p, &fhp->fh_handle.fh_raw, len);
return 0;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment