u32 minorversion;
};
-/*
- * START OF "GENERIC" ENCODE ROUTINES.
- * These may look a little ugly since they are imported from a "generic"
- * set of XDR encode/decode routines which are intended to be shared by
- * all of our NFSv4 implementations (OpenBSD, MacOS X...).
- *
- * If the pain of reading these is too great, it should be a straightforward
- * task to translate them into Linux-specific versions which are more
- * consistent with the style used in NFSv2/v3...
- */
-#define RESERVE_SPACE(nbytes) do { \
- p = xdr_reserve_space(xdr, nbytes); \
- BUG_ON(!p); \
-} while (0)
+static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
+{
+ __be32 *p = xdr_reserve_space(xdr, nbytes);
+ BUG_ON(!p);
+ return p;
+}
static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
{
dprintk("encode_compound: tag=%.*s\n", (int)hdr->taglen, hdr->tag);
BUG_ON(hdr->taglen > NFS4_MAXTAGLEN);
- RESERVE_SPACE(12 + hdr->taglen);
+ p = reserve_space(xdr, 12 + hdr->taglen);
*p++ = cpu_to_be32(hdr->taglen);
p = xdr_encode_opaque_fixed(p, hdr->tag, hdr->taglen);
*p++ = cpu_to_be32(hdr->minorversion);
len += 16;
else if (iap->ia_valid & ATTR_MTIME)
len += 4;
- RESERVE_SPACE(len);
+ p = reserve_space(xdr, len);
/*
* We write the bitmap length now, but leave the bitmap and the attribute
{
__be32 *p;
- RESERVE_SPACE(8);
+ p = reserve_space(xdr, 8);
*p++ = cpu_to_be32(OP_ACCESS);
*p++ = cpu_to_be32(access);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(8+NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, 8+NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(OP_CLOSE);
*p++ = cpu_to_be32(arg->seqid->sequence->counter);
p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
{
__be32 *p;
- RESERVE_SPACE(16);
+ p = reserve_space(xdr, 16);
*p++ = cpu_to_be32(OP_COMMIT);
p = xdr_encode_hyper(p, args->offset);
*p++ = cpu_to_be32(args->count);
{
__be32 *p;
- RESERVE_SPACE(8);
+ p = reserve_space(xdr, 8);
*p++ = cpu_to_be32(OP_CREATE);
*p++ = cpu_to_be32(create->ftype);
switch (create->ftype) {
case NF4LNK:
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(create->u.symlink.len);
xdr_write_pages(xdr, create->u.symlink.pages, 0, create->u.symlink.len);
break;
case NF4BLK: case NF4CHR:
- RESERVE_SPACE(8);
+ p = reserve_space(xdr, 8);
*p++ = cpu_to_be32(create->u.device.specdata1);
*p++ = cpu_to_be32(create->u.device.specdata2);
break;
break;
}
- RESERVE_SPACE(4 + create->name->len);
+ p = reserve_space(xdr, 4 + create->name->len);
*p++ = cpu_to_be32(create->name->len);
p = xdr_encode_opaque_fixed(p, create->name->name, create->name->len);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(12);
+ p = reserve_space(xdr, 12);
*p++ = cpu_to_be32(OP_GETATTR);
*p++ = cpu_to_be32(1);
*p++ = cpu_to_be32(bitmap);
{
__be32 *p;
- RESERVE_SPACE(16);
+ p = reserve_space(xdr, 16);
*p++ = cpu_to_be32(OP_GETATTR);
*p++ = cpu_to_be32(2);
*p++ = cpu_to_be32(bm0);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_GETFH);
hdr->nops++;
hdr->replen += decode_getfh_maxsz;
{
__be32 *p;
- RESERVE_SPACE(8 + name->len);
+ p = reserve_space(xdr, 8 + name->len);
*p++ = cpu_to_be32(OP_LINK);
*p++ = cpu_to_be32(name->len);
p = xdr_encode_opaque_fixed(p, name->name, name->len);
{
__be32 *p;
- RESERVE_SPACE(32);
+ p = reserve_space(xdr, 32);
*p++ = cpu_to_be32(OP_LOCK);
*p++ = cpu_to_be32(nfs4_lock_type(args->fl, args->block));
*p++ = cpu_to_be32(args->reclaim);
p = xdr_encode_hyper(p, nfs4_lock_length(args->fl));
*p++ = cpu_to_be32(args->new_lock_owner);
if (args->new_lock_owner){
- RESERVE_SPACE(4+NFS4_STATEID_SIZE+32);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+32);
*p++ = cpu_to_be32(args->open_seqid->sequence->counter);
p = xdr_encode_opaque_fixed(p, args->open_stateid->data, NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(args->lock_seqid->sequence->counter);
p = xdr_encode_hyper(p, args->lock_owner.id);
}
else {
- RESERVE_SPACE(NFS4_STATEID_SIZE+4);
+ p = reserve_space(xdr, NFS4_STATEID_SIZE+4);
p = xdr_encode_opaque_fixed(p, args->lock_stateid->data, NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(args->lock_seqid->sequence->counter);
}
{
__be32 *p;
- RESERVE_SPACE(52);
+ p = reserve_space(xdr, 52);
*p++ = cpu_to_be32(OP_LOCKT);
*p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
p = xdr_encode_hyper(p, args->fl->fl_start);
{
__be32 *p;
- RESERVE_SPACE(12+NFS4_STATEID_SIZE+16);
+ p = reserve_space(xdr, 12+NFS4_STATEID_SIZE+16);
*p++ = cpu_to_be32(OP_LOCKU);
*p++ = cpu_to_be32(nfs4_lock_type(args->fl, 0));
*p++ = cpu_to_be32(args->seqid->sequence->counter);
int len = name->len;
__be32 *p;
- RESERVE_SPACE(8 + len);
+ p = reserve_space(xdr, 8 + len);
*p++ = cpu_to_be32(OP_LOOKUP);
*p++ = cpu_to_be32(len);
p = xdr_encode_opaque_fixed(p, name->name, len);
{
__be32 *p;
- RESERVE_SPACE(8);
+ p = reserve_space(xdr, 8);
switch (fmode & (FMODE_READ|FMODE_WRITE)) {
case FMODE_READ:
*p++ = cpu_to_be32(NFS4_SHARE_ACCESS_READ);
* opcode 4, seqid 4, share_access 4, share_deny 4, clientid 8, ownerlen 4,
* owner 4 = 32
*/
- RESERVE_SPACE(8);
+ p = reserve_space(xdr, 8);
*p++ = cpu_to_be32(OP_OPEN);
*p++ = cpu_to_be32(arg->seqid->sequence->counter);
encode_share_access(xdr, arg->fmode);
- RESERVE_SPACE(28);
+ p = reserve_space(xdr, 28);
p = xdr_encode_hyper(p, arg->clientid);
*p++ = cpu_to_be32(16);
p = xdr_encode_opaque_fixed(p, "open id:", 8);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
switch(arg->open_flags & O_EXCL) {
case 0:
*p++ = cpu_to_be32(NFS4_CREATE_UNCHECKED);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
switch (arg->open_flags & O_CREAT) {
case 0:
*p++ = cpu_to_be32(NFS4_OPEN_NOCREATE);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
switch (delegation_type) {
case 0:
*p++ = cpu_to_be32(NFS4_OPEN_DELEGATE_NONE);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(NFS4_OPEN_CLAIM_NULL);
encode_string(xdr, name->len, name->name);
}
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(NFS4_OPEN_CLAIM_PREVIOUS);
encode_delegation_type(xdr, type);
}
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
encode_string(xdr, name->len, name->name);
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
*p++ = cpu_to_be32(OP_OPEN_CONFIRM);
p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(arg->seqid->sequence->counter);
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE+4);
*p++ = cpu_to_be32(OP_OPEN_DOWNGRADE);
p = xdr_encode_opaque_fixed(p, arg->stateid->data, NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(arg->seqid->sequence->counter);
int len = fh->size;
__be32 *p;
- RESERVE_SPACE(8 + len);
+ p = reserve_space(xdr, 8 + len);
*p++ = cpu_to_be32(OP_PUTFH);
*p++ = cpu_to_be32(len);
p = xdr_encode_opaque_fixed(p, fh->data, len);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_PUTROOTFH);
hdr->nops++;
hdr->replen += decode_putrootfh_maxsz;
nfs4_stateid stateid;
__be32 *p;
- RESERVE_SPACE(NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, NFS4_STATEID_SIZE);
if (ctx->state != NULL) {
nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
p = xdr_encode_opaque_fixed(p, stateid.data, NFS4_STATEID_SIZE);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_READ);
encode_stateid(xdr, args->context);
- RESERVE_SPACE(12);
+ p = reserve_space(xdr, 12);
p = xdr_encode_hyper(p, args->offset);
*p++ = cpu_to_be32(args->count);
hdr->nops++;
};
__be32 *p;
- RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
+ p = reserve_space(xdr, 12+NFS4_VERIFIER_SIZE+20);
*p++ = cpu_to_be32(OP_READDIR);
p = xdr_encode_hyper(p, readdir->cookie);
p = xdr_encode_opaque_fixed(p, readdir->verifier.data, NFS4_VERIFIER_SIZE);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_READLINK);
hdr->nops++;
hdr->replen += decode_readlink_maxsz;
{
__be32 *p;
- RESERVE_SPACE(8 + name->len);
+ p = reserve_space(xdr, 8 + name->len);
*p++ = cpu_to_be32(OP_REMOVE);
*p++ = cpu_to_be32(name->len);
p = xdr_encode_opaque_fixed(p, name->name, name->len);
{
__be32 *p;
- RESERVE_SPACE(8 + oldname->len);
+ p = reserve_space(xdr, 8 + oldname->len);
*p++ = cpu_to_be32(OP_RENAME);
*p++ = cpu_to_be32(oldname->len);
p = xdr_encode_opaque_fixed(p, oldname->name, oldname->len);
- RESERVE_SPACE(4 + newname->len);
+ p = reserve_space(xdr, 4 + newname->len);
*p++ = cpu_to_be32(newname->len);
p = xdr_encode_opaque_fixed(p, newname->name, newname->len);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(12);
+ p = reserve_space(xdr, 12);
*p++ = cpu_to_be32(OP_RENEW);
p = xdr_encode_hyper(p, client_stateid->cl_clientid);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_RESTOREFH);
hdr->nops++;
hdr->replen += decode_restorefh_maxsz;
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(OP_SETATTR);
p = xdr_encode_opaque_fixed(p, zero_stateid.data, NFS4_STATEID_SIZE);
- RESERVE_SPACE(2*4);
+ p = reserve_space(xdr, 2*4);
*p++ = cpu_to_be32(1);
*p++ = cpu_to_be32(FATTR4_WORD0_ACL);
if (arg->acl_len % 4)
return -EINVAL;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(arg->acl_len);
xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_SAVEFH);
hdr->nops++;
hdr->replen += decode_savefh_maxsz;
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(OP_SETATTR);
p = xdr_encode_opaque_fixed(p, arg->stateid.data, NFS4_STATEID_SIZE);
hdr->nops++;
{
__be32 *p;
- RESERVE_SPACE(4 + NFS4_VERIFIER_SIZE);
+ p = reserve_space(xdr, 4 + NFS4_VERIFIER_SIZE);
*p++ = cpu_to_be32(OP_SETCLIENTID);
p = xdr_encode_opaque_fixed(p, setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(setclientid->sc_prog);
encode_string(xdr, setclientid->sc_netid_len, setclientid->sc_netid);
encode_string(xdr, setclientid->sc_uaddr_len, setclientid->sc_uaddr);
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(setclientid->sc_cb_ident);
hdr->nops++;
hdr->replen += decode_setclientid_maxsz;
{
__be32 *p;
- RESERVE_SPACE(12 + NFS4_VERIFIER_SIZE);
+ p = reserve_space(xdr, 12 + NFS4_VERIFIER_SIZE);
*p++ = cpu_to_be32(OP_SETCLIENTID_CONFIRM);
p = xdr_encode_hyper(p, client_state->cl_clientid);
p = xdr_encode_opaque_fixed(p, client_state->cl_confirm.data, NFS4_VERIFIER_SIZE);
{
__be32 *p;
- RESERVE_SPACE(4);
+ p = reserve_space(xdr, 4);
*p++ = cpu_to_be32(OP_WRITE);
encode_stateid(xdr, args->context);
- RESERVE_SPACE(16);
+ p = reserve_space(xdr, 16);
p = xdr_encode_hyper(p, args->offset);
*p++ = cpu_to_be32(args->stable);
*p++ = cpu_to_be32(args->count);
{
__be32 *p;
- RESERVE_SPACE(4+NFS4_STATEID_SIZE);
+ p = reserve_space(xdr, 4+NFS4_STATEID_SIZE);
*p++ = cpu_to_be32(OP_DELEGRETURN);
p = xdr_encode_opaque_fixed(p, stateid->data, NFS4_STATEID_SIZE);
{
__be32 *p;
- RESERVE_SPACE(4 + sizeof(args->verifier->data));
+ p = reserve_space(xdr, 4 + sizeof(args->verifier->data));
*p++ = cpu_to_be32(OP_EXCHANGE_ID);
p = xdr_encode_opaque_fixed(p, args->verifier->data, sizeof(args->verifier->data));
encode_string(xdr, args->id_len, args->id);
- RESERVE_SPACE(12);
+ p = reserve_space(xdr, 12);
*p++ = cpu_to_be32(args->flags);
*p++ = cpu_to_be32(0); /* zero length state_protect4_a */
*p++ = cpu_to_be32(0); /* zero length implementation id array */
len = scnprintf(machine_name, sizeof(machine_name), "%s",
clp->cl_ipaddr);
- RESERVE_SPACE(20 + 2*28 + 20 + len + 12);
+ p = reserve_space(xdr, 20 + 2*28 + 20 + len + 12);
*p++ = cpu_to_be32(OP_CREATE_SESSION);
p = xdr_encode_hyper(p, clp->cl_ex_clid);
*p++ = cpu_to_be32(clp->cl_seqid); /*Sequence id */
struct compound_hdr *hdr)
{
__be32 *p;
- RESERVE_SPACE(4 + NFS4_MAX_SESSIONID_LEN);
+ p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN);
*p++ = cpu_to_be32(OP_DESTROY_SESSION);
p = xdr_encode_opaque_fixed(p, session->sess_id.data, NFS4_MAX_SESSIONID_LEN);
hdr->nops++;
WARN_ON(args->sa_slotid == NFS4_MAX_SLOT_TABLE);
slot = tp->slots + args->sa_slotid;
- RESERVE_SPACE(4 + NFS4_MAX_SESSIONID_LEN + 16);
+ p = reserve_space(xdr, 4 + NFS4_MAX_SESSIONID_LEN + 16);
*p++ = cpu_to_be32(OP_SEQUENCE);
/*