Commit 1beef147 authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields
Browse files

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

parent ec757e42
Loading
Loading
Loading
Loading
+36 −38
Original line number Original line Diff line number Diff line
@@ -20,8 +20,6 @@


#include "svcxdr.h"
#include "svcxdr.h"


#define NLMDBG_FACILITY		NLMDBG_XDR

static inline loff_t
static inline loff_t
s64_to_loff_t(__s64 offset)
s64_to_loff_t(__s64 offset)
{
{
@@ -110,44 +108,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 *
nlm4_encode_testres(__be32 *p, struct nlm_res *resp)
{
{
	const struct file_lock *fl = &lock->fl;
	s64 start, len;
	s64 start, len;


	dprintk("xdr: before encode_testres (p %p resp %p)\n", p, resp);
	/* exclusive */
	if (!(p = nlm4_encode_cookie(p, &resp->cookie)))
	if (xdr_stream_encode_bool(xdr, fl->fl_type != F_RDLCK) < 0)
		return NULL;
		return false;
	*p++ = resp->status;
	if (xdr_stream_encode_u32(xdr, lock->svid) < 0)

		return false;
	if (resp->status == nlm_lck_denied) {
	if (!svcxdr_encode_owner(xdr, &lock->oh))
		struct file_lock	*fl = &resp->lock.fl;
		return false;

		*p++ = (fl->fl_type == F_RDLCK)? xdr_zero : xdr_one;
		*p++ = htonl(resp->lock.svid);

		/* Encode owner handle. */
		if (!(p = xdr_encode_netobj(p, &resp->lock.oh)))
			return NULL;

	start = loff_t_to_s64(fl->fl_start);
	start = loff_t_to_s64(fl->fl_start);
	if (fl->fl_end == OFFSET_MAX)
	if (fl->fl_end == OFFSET_MAX)
		len = 0;
		len = 0;
	else
	else
		len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
		len = loff_t_to_s64(fl->fl_end - fl->fl_start + 1);
	if (xdr_stream_encode_u64(xdr, start) < 0)
		return false;
	if (xdr_stream_encode_u64(xdr, len) < 0)
		return false;


		p = xdr_encode_hyper(p, start);
	return true;
		p = xdr_encode_hyper(p, len);
		dprintk("xdr: encode_testres (status %u pid %d type %d start %Ld end %Ld)\n",
			resp->status, (int)resp->lock.svid, fl->fl_type,
			(long long)fl->fl_start,  (long long)fl->fl_end);
}
}


	dprintk("xdr: after encode_testres (p %p resp %p)\n", p, resp);
static bool
	return p;
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 true;
}
}




@@ -338,11 +336,11 @@ nlm4svc_encode_void(struct svc_rqst *rqstp, __be32 *p)
int
int
nlm4svc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
nlm4svc_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 = nlm4_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