Commit adf98a48 authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields

lockd: Update the NLMv1 TEST results encoder to use struct xdr_stream

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent e26ec898
...@@ -80,15 +80,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh) ...@@ -80,15 +80,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct nfs_fh *fh)
return true; return true;
} }
/*
* Encode and decode owner handle
*/
static inline __be32 *
nlm_encode_oh(__be32 *p, struct xdr_netobj *oh)
{
return xdr_encode_netobj(p, oh);
}
static bool static bool
svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)
{ {
...@@ -121,39 +112,44 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) ...@@ -121,39 +112,44 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock)
return true; return true;
} }
/* static bool
* Encode result of a TEST/TEST_MSG call svcxdr_encode_holder(struct xdr_stream *xdr, const struct nlm_lock *lock)
*/
static __be32 *
nlm_encode_testres(__be32 *p, struct nlm_res *resp)
{ {
s32 start, len; const struct file_lock *fl = &lock->fl;
s32 start, len;
if (!(p = nlm_encode_cookie(p, &resp->cookie)))
return NULL;
*p++ = resp->status;
if (resp->status == nlm_lck_denied) { /* exclusive */
struct file_lock *fl = &resp->lock.fl; if (xdr_stream_encode_bool(xdr, fl->fl_type != F_RDLCK) < 0)
return false;
*p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one; if (xdr_stream_encode_u32(xdr, lock->svid) < 0)
*p++ = htonl(resp->lock.svid); return false;
if (!svcxdr_encode_owner(xdr, &lock->oh))
/* Encode owner handle. */ return false;
if (!(p = xdr_encode_netobj(p, &resp->lock.oh))) start = loff_t_to_s32(fl->fl_start);
return NULL; if (fl->fl_end == OFFSET_MAX)
len = 0;
else
len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
if (xdr_stream_encode_u32(xdr, start) < 0)
return false;
if (xdr_stream_encode_u32(xdr, len) < 0)
return false;
start = loff_t_to_s32(fl->fl_start); return true;
if (fl->fl_end == OFFSET_MAX) }
len = 0;
else
len = loff_t_to_s32(fl->fl_end - fl->fl_start + 1);
*p++ = htonl(start); static bool
*p++ = htonl(len); svcxdr_encode_testrply(struct xdr_stream *xdr, const struct nlm_res *resp)
{
if (!svcxdr_encode_stats(xdr, resp->status))
return false;
switch (resp->status) {
case nlm_lck_denied:
if (!svcxdr_encode_holder(xdr, &resp->lock))
return false;
} }
return p; return true;
} }
...@@ -345,11 +341,11 @@ nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p) ...@@ -345,11 +341,11 @@ nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
int int
nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p) nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
{ {
struct xdr_stream *xdr = &rqstp->rq_res_stream;
struct nlm_res *resp = rqstp->rq_resp; struct nlm_res *resp = rqstp->rq_resp;
if (!(p = nlm_encode_testres(p, resp))) return svcxdr_encode_cookie(xdr, &resp->cookie) &&
return 0; svcxdr_encode_testrply(xdr, resp);
return xdr_ressize_check(rqstp, p);
} }
int int
......
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