Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229181
b: refs/heads/master
c: 49b1700
h: refs/heads/master
i:
  229179: 8424ede
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Dec 16, 2010
1 parent ffd0a1a commit 2554e4c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 44 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ead00597882c4ee3c534d6880cc3bcb4d412cc4b
refs/heads/master: 49b170047f4a9fe1483132e14a11bdf493bdb8af
68 changes: 25 additions & 43 deletions trunk/fs/lockd/mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,26 +401,22 @@ void nsm_release(struct nsm_handle *nsm)
* Status Monitor wire protocol.
*/

static int encode_nsm_string(struct xdr_stream *xdr, const char *string)
static void encode_nsm_string(struct xdr_stream *xdr, const char *string)
{
const u32 len = strlen(string);
__be32 *p;

if (unlikely(len > SM_MAXSTRLEN))
return -EIO;
p = xdr_reserve_space(xdr, sizeof(u32) + len);
if (unlikely(p == NULL))
return -EIO;
BUG_ON(len > SM_MAXSTRLEN);
p = xdr_reserve_space(xdr, 4 + len);
xdr_encode_opaque(p, string, len);
return 0;
}

/*
* "mon_name" specifies the host to be monitored.
*/
static int encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp)
static void encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp)
{
return encode_nsm_string(xdr, argp->mon_name);
encode_nsm_string(xdr, argp->mon_name);
}

/*
Expand All @@ -429,64 +425,49 @@ static int encode_mon_name(struct xdr_stream *xdr, const struct nsm_args *argp)
* (via the NLMPROC_SM_NOTIFY call) that the state of host "mon_name"
* has changed.
*/
static int encode_my_id(struct xdr_stream *xdr, const struct nsm_args *argp)
static void encode_my_id(struct xdr_stream *xdr, const struct nsm_args *argp)
{
int status;
__be32 *p;

status = encode_nsm_string(xdr, utsname()->nodename);
if (unlikely(status != 0))
return status;
p = xdr_reserve_space(xdr, 3 * sizeof(u32));
if (unlikely(p == NULL))
return -EIO;
*p++ = htonl(argp->prog);
*p++ = htonl(argp->vers);
*p++ = htonl(argp->proc);
return 0;
encode_nsm_string(xdr, utsname()->nodename);
p = xdr_reserve_space(xdr, 4 + 4 + 4);
*p++ = cpu_to_be32(argp->prog);
*p++ = cpu_to_be32(argp->vers);
*p = cpu_to_be32(argp->proc);
}

/*
* The "mon_id" argument specifies the non-private arguments
* of an NSMPROC_MON or NSMPROC_UNMON call.
*/
static int encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp)
static void encode_mon_id(struct xdr_stream *xdr, const struct nsm_args *argp)
{
int status;

status = encode_mon_name(xdr, argp);
if (unlikely(status != 0))
return status;
return encode_my_id(xdr, argp);
encode_mon_name(xdr, argp);
encode_my_id(xdr, argp);
}

/*
* The "priv" argument may contain private information required
* by the NSMPROC_MON call. This information will be supplied in the
* NLMPROC_SM_NOTIFY call.
*/
static int encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp)
static void encode_priv(struct xdr_stream *xdr, const struct nsm_args *argp)
{
__be32 *p;

p = xdr_reserve_space(xdr, SM_PRIV_SIZE);
if (unlikely(p == NULL))
return -EIO;
xdr_encode_opaque_fixed(p, argp->priv->data, SM_PRIV_SIZE);
return 0;
}

static int xdr_enc_mon(struct rpc_rqst *req, __be32 *p,
const struct nsm_args *argp)
{
struct xdr_stream xdr;
int status;

xdr_init_encode(&xdr, &req->rq_snd_buf, p);
status = encode_mon_id(&xdr, argp);
if (unlikely(status))
return status;
return encode_priv(&xdr, argp);
encode_mon_id(&xdr, argp);
encode_priv(&xdr, argp);
return 0;
}

static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p,
Expand All @@ -495,7 +476,8 @@ static int xdr_enc_unmon(struct rpc_rqst *req, __be32 *p,
struct xdr_stream xdr;

xdr_init_encode(&xdr, &req->rq_snd_buf, p);
return encode_mon_id(&xdr, argp);
encode_mon_id(&xdr, argp);
return 0;
}

static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p,
Expand All @@ -504,11 +486,11 @@ static int xdr_dec_stat_res(struct rpc_rqst *rqstp, __be32 *p,
struct xdr_stream xdr;

xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
p = xdr_inline_decode(&xdr, 2 * sizeof(u32));
p = xdr_inline_decode(&xdr, 4 + 4);
if (unlikely(p == NULL))
return -EIO;
resp->status = ntohl(*p++);
resp->state = ntohl(*p);
resp->status = be32_to_cpup(p++);
resp->state = be32_to_cpup(p);

dprintk("lockd: xdr_dec_stat_res status %d state %d\n",
resp->status, resp->state);
Expand All @@ -521,10 +503,10 @@ static int xdr_dec_stat(struct rpc_rqst *rqstp, __be32 *p,
struct xdr_stream xdr;

xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
p = xdr_inline_decode(&xdr, sizeof(u32));
p = xdr_inline_decode(&xdr, 4);
if (unlikely(p == NULL))
return -EIO;
resp->state = ntohl(*p);
resp->state = be32_to_cpup(p);

dprintk("lockd: xdr_dec_stat state %d\n", resp->state);
return 0;
Expand Down

0 comments on commit 2554e4c

Please sign in to comment.