Commit cc313f80 authored by Chuck Lever's avatar Chuck Lever

NFSD: Clean up nfsd4_encode_layoutcommit()

Adopt the use of conventional XDR utility functions. Restructure
the encoder to better align with the XDR definition of the result.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 69f5f019
...@@ -2357,10 +2357,10 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp, ...@@ -2357,10 +2357,10 @@ nfsd4_layoutcommit(struct svc_rqst *rqstp,
mutex_unlock(&ls->ls_mutex); mutex_unlock(&ls->ls_mutex);
if (new_size > i_size_read(inode)) { if (new_size > i_size_read(inode)) {
lcp->lc_size_chg = 1; lcp->lc_size_chg = true;
lcp->lc_newsize = new_size; lcp->lc_newsize = new_size;
} else { } else {
lcp->lc_size_chg = 0; lcp->lc_size_chg = false;
} }
nfserr = ops->proc_layoutcommit(inode, lcp); nfserr = ops->proc_layoutcommit(inode, lcp);
......
...@@ -4914,20 +4914,15 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4914,20 +4914,15 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr,
{ {
struct nfsd4_layoutcommit *lcp = &u->layoutcommit; struct nfsd4_layoutcommit *lcp = &u->layoutcommit;
struct xdr_stream *xdr = resp->xdr; struct xdr_stream *xdr = resp->xdr;
__be32 *p;
p = xdr_reserve_space(xdr, 4); /* ns_sizechanged */
if (!p) nfserr = nfsd4_encode_bool(xdr, lcp->lc_size_chg);
return nfserr_resource; if (nfserr != nfs_ok)
*p++ = cpu_to_be32(lcp->lc_size_chg); return nfserr;
if (lcp->lc_size_chg) { if (lcp->lc_size_chg)
p = xdr_reserve_space(xdr, 8); /* ns_size */
if (!p) return nfsd4_encode_length4(xdr, lcp->lc_newsize);
return nfserr_resource; return nfs_ok;
p = xdr_encode_hyper(p, lcp->lc_newsize);
}
return 0;
} }
static __be32 static __be32
......
...@@ -618,7 +618,7 @@ struct nfsd4_layoutcommit { ...@@ -618,7 +618,7 @@ struct nfsd4_layoutcommit {
u32 lc_layout_type; /* request */ u32 lc_layout_type; /* request */
u32 lc_up_len; /* layout length */ u32 lc_up_len; /* layout length */
void *lc_up_layout; /* decoded by callback */ void *lc_up_layout; /* decoded by callback */
u32 lc_size_chg; /* boolean for response */ bool lc_size_chg; /* response */
u64 lc_newsize; /* response */ u64 lc_newsize; /* response */
}; };
......
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