Commit bac966d6 authored by J. Bruce Fields's avatar J. Bruce Fields

nfsd4: individual encoders no longer see error cases

With a few exceptions, most individual encoders don't handle error
cases.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent b7571e4c
...@@ -3105,14 +3105,12 @@ nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -3105,14 +3105,12 @@ nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 8);
p = xdr_reserve_space(xdr, 8); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; *p++ = cpu_to_be32(access->ac_supported);
*p++ = cpu_to_be32(access->ac_supported); *p++ = cpu_to_be32(access->ac_resp_access);
*p++ = cpu_to_be32(access->ac_resp_access); return 0;
}
return nfserr;
} }
static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_bind_conn_to_session *bcts) static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_bind_conn_to_session *bcts)
...@@ -3120,17 +3118,15 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp, ...@@ -3120,17 +3118,15 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp,
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8);
p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = xdr_encode_opaque_fixed(p, bcts->sessionid.data,
p = xdr_encode_opaque_fixed(p, bcts->sessionid.data, NFS4_MAX_SESSIONID_LEN);
NFS4_MAX_SESSIONID_LEN); *p++ = cpu_to_be32(bcts->dir);
*p++ = cpu_to_be32(bcts->dir); /* Upshifting from TCP to RDMA is not supported */
/* Upshifting from TCP to RDMA is not supported */ *p++ = cpu_to_be32(0);
*p++ = cpu_to_be32(0); return 0;
}
return nfserr;
} }
static __be32 static __be32
...@@ -3138,10 +3134,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c ...@@ -3138,10 +3134,7 @@ nfsd4_encode_close(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_c
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
if (!nfserr) return nfsd4_encode_stateid(xdr, &close->cl_stateid);
nfserr = nfsd4_encode_stateid(xdr, &close->cl_stateid);
return nfserr;
} }
...@@ -3151,14 +3144,12 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -3151,14 +3144,12 @@ nfsd4_encode_commit(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = xdr_encode_opaque_fixed(p, commit->co_verf.data,
p = xdr_encode_opaque_fixed(p, commit->co_verf.data,
NFS4_VERIFIER_SIZE); NFS4_VERIFIER_SIZE);
} return 0;
return nfserr;
} }
static __be32 static __be32
...@@ -3167,15 +3158,13 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -3167,15 +3158,13 @@ nfsd4_encode_create(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 20);
p = xdr_reserve_space(xdr, 20); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; encode_cinfo(p, &create->cr_cinfo);
encode_cinfo(p, &create->cr_cinfo); nfserr = nfsd4_encode_bitmap(xdr, create->cr_bmval[0],
nfserr = nfsd4_encode_bitmap(xdr, create->cr_bmval[0], create->cr_bmval[1], create->cr_bmval[2]);
create->cr_bmval[1], create->cr_bmval[2]); return 0;
}
return nfserr;
} }
static __be32 static __be32
...@@ -3184,13 +3173,8 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 ...@@ -3184,13 +3173,8 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
struct svc_fh *fhp = getattr->ga_fhp; struct svc_fh *fhp = getattr->ga_fhp;
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
if (nfserr) return nfsd4_encode_fattr(xdr, fhp, fhp->fh_export, fhp->fh_dentry,
return nfserr; getattr->ga_bmval, resp->rqstp, 0);
nfserr = nfsd4_encode_fattr(xdr, fhp, fhp->fh_export, fhp->fh_dentry,
getattr->ga_bmval,
resp->rqstp, 0);
return nfserr;
} }
static __be32 static __be32
...@@ -3201,14 +3185,12 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh ...@@ -3201,14 +3185,12 @@ nfsd4_encode_getfh(struct nfsd4_compoundres *resp, __be32 nfserr, struct svc_fh
unsigned int len; unsigned int len;
__be32 *p; __be32 *p;
if (!nfserr) { len = fhp->fh_handle.fh_size;
len = fhp->fh_handle.fh_size; p = xdr_reserve_space(xdr, len + 4);
p = xdr_reserve_space(xdr, len + 4); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, len);
p = xdr_encode_opaque(p, &fhp->fh_handle.fh_base, len); return 0;
}
return nfserr;
} }
/* /*
...@@ -3278,10 +3260,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l ...@@ -3278,10 +3260,7 @@ nfsd4_encode_locku(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_l
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
if (!nfserr) return nfsd4_encode_stateid(xdr, &locku->lu_stateid);
nfserr = nfsd4_encode_stateid(xdr, &locku->lu_stateid);
return nfserr;
} }
...@@ -3291,13 +3270,11 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_li ...@@ -3291,13 +3270,11 @@ nfsd4_encode_link(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_li
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 20);
p = xdr_reserve_space(xdr, 20); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = encode_cinfo(p, &link->li_cinfo);
p = encode_cinfo(p, &link->li_cinfo); return 0;
}
return nfserr;
} }
...@@ -3307,12 +3284,9 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -3307,12 +3284,9 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (nfserr)
goto out;
nfserr = nfsd4_encode_stateid(xdr, &open->op_stateid); nfserr = nfsd4_encode_stateid(xdr, &open->op_stateid);
if (nfserr) if (nfserr)
goto out; return nfserr;
p = xdr_reserve_space(xdr, 24); p = xdr_reserve_space(xdr, 24);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -3322,7 +3296,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -3322,7 +3296,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
nfserr = nfsd4_encode_bitmap(xdr, open->op_bmval[0], open->op_bmval[1], nfserr = nfsd4_encode_bitmap(xdr, open->op_bmval[0], open->op_bmval[1],
open->op_bmval[2]); open->op_bmval[2]);
if (nfserr) if (nfserr)
goto out; return nfserr;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
...@@ -3395,8 +3369,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op ...@@ -3395,8 +3369,7 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_op
BUG(); BUG();
} }
/* XXX save filehandle here */ /* XXX save filehandle here */
out: return 0;
return nfserr;
} }
static __be32 static __be32
...@@ -3404,10 +3377,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct ...@@ -3404,10 +3377,7 @@ nfsd4_encode_open_confirm(struct nfsd4_compoundres *resp, __be32 nfserr, struct
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
if (!nfserr) return nfsd4_encode_stateid(xdr, &oc->oc_resp_stateid);
nfserr = nfsd4_encode_stateid(xdr, &oc->oc_resp_stateid);
return nfserr;
} }
static __be32 static __be32
...@@ -3415,10 +3385,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc ...@@ -3415,10 +3385,7 @@ nfsd4_encode_open_downgrade(struct nfsd4_compoundres *resp, __be32 nfserr, struc
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
if (!nfserr) return nfsd4_encode_stateid(xdr, &od->od_stateid);
nfserr = nfsd4_encode_stateid(xdr, &od->od_stateid);
return nfserr;
} }
static __be32 nfsd4_encode_splice_read( static __be32 nfsd4_encode_splice_read(
...@@ -3555,20 +3522,15 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3555,20 +3522,15 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
struct raparms *ra = NULL; struct raparms *ra = NULL;
__be32 *p; __be32 *p;
if (nfserr)
goto out;
p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */ p = xdr_reserve_space(xdr, 8); /* eof flag and byte count */
if (!p) { if (!p) {
WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)); WARN_ON_ONCE(test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags));
nfserr = nfserr_resource; return nfserr_resource;
goto out;
} }
if (resp->xdr.buf->page_len && if (resp->xdr.buf->page_len &&
test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) { test_bit(RQ_SPLICE_OK, &resp->rqstp->rq_flags)) {
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
nfserr = nfserr_resource; return nfserr_resource;
goto out;
} }
xdr_commit_encode(xdr); xdr_commit_encode(xdr);
...@@ -3592,7 +3554,6 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3592,7 +3554,6 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr,
if (nfserr) if (nfserr)
xdr_truncate_encode(xdr, starting_len); xdr_truncate_encode(xdr, starting_len);
out:
return nfserr; return nfserr;
} }
...@@ -3606,9 +3567,6 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd ...@@ -3606,9 +3567,6 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd
int length_offset = xdr->buf->len; int length_offset = xdr->buf->len;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -3652,9 +3610,6 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 ...@@ -3652,9 +3610,6 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
int starting_len = xdr->buf->len; int starting_len = xdr->buf->len;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE); p = xdr_reserve_space(xdr, NFS4_VERIFIER_SIZE);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -3740,13 +3695,11 @@ nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -3740,13 +3695,11 @@ nfsd4_encode_remove(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 20);
p = xdr_reserve_space(xdr, 20); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = encode_cinfo(p, &remove->rm_cinfo);
p = encode_cinfo(p, &remove->rm_cinfo); return 0;
}
return nfserr;
} }
static __be32 static __be32
...@@ -3755,19 +3708,16 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_ ...@@ -3755,19 +3708,16 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 40);
p = xdr_reserve_space(xdr, 40); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; p = encode_cinfo(p, &rename->rn_sinfo);
p = encode_cinfo(p, &rename->rn_sinfo); p = encode_cinfo(p, &rename->rn_tinfo);
p = encode_cinfo(p, &rename->rn_tinfo); return 0;
}
return nfserr;
} }
static __be32 static __be32
nfsd4_do_encode_secinfo(struct xdr_stream *xdr, nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp)
__be32 nfserr, struct svc_export *exp)
{ {
u32 i, nflavs, supported; u32 i, nflavs, supported;
struct exp_flavor_info *flavs; struct exp_flavor_info *flavs;
...@@ -3775,9 +3725,6 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3775,9 +3725,6 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
__be32 *p, *flavorsp; __be32 *p, *flavorsp;
static bool report = true; static bool report = true;
if (nfserr)
goto out;
nfserr = nfserr_resource;
if (exp->ex_nflavors) { if (exp->ex_nflavors) {
flavs = exp->ex_flavors; flavs = exp->ex_flavors;
nflavs = exp->ex_nflavors; nflavs = exp->ex_nflavors;
...@@ -3801,7 +3748,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3801,7 +3748,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
supported = 0; supported = 0;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
goto out; return nfserr_resource;
flavorsp = p++; /* to be backfilled later */ flavorsp = p++; /* to be backfilled later */
for (i = 0; i < nflavs; i++) { for (i = 0; i < nflavs; i++) {
...@@ -3813,7 +3760,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3813,7 +3760,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
p = xdr_reserve_space(xdr, 4 + 4 + p = xdr_reserve_space(xdr, 4 + 4 +
XDR_LEN(info.oid.len) + 4 + 4); XDR_LEN(info.oid.len) + 4 + 4);
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = cpu_to_be32(RPC_AUTH_GSS); *p++ = cpu_to_be32(RPC_AUTH_GSS);
p = xdr_encode_opaque(p, info.oid.data, info.oid.len); p = xdr_encode_opaque(p, info.oid.data, info.oid.len);
*p++ = cpu_to_be32(info.qop); *p++ = cpu_to_be32(info.qop);
...@@ -3822,7 +3769,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3822,7 +3769,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
supported++; supported++;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = cpu_to_be32(pf); *p++ = cpu_to_be32(pf);
} else { } else {
if (report) if (report)
...@@ -3834,9 +3781,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, ...@@ -3834,9 +3781,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr,
if (nflavs != supported) if (nflavs != supported)
report = false; report = false;
*flavorsp = htonl(supported); *flavorsp = htonl(supported);
nfserr = 0; return 0;
out:
return nfserr;
} }
static __be32 static __be32
...@@ -3845,7 +3790,7 @@ nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3845,7 +3790,7 @@ nfsd4_encode_secinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
return nfsd4_do_encode_secinfo(xdr, nfserr, secinfo->si_exp); return nfsd4_do_encode_secinfo(xdr, secinfo->si_exp);
} }
static __be32 static __be32
...@@ -3854,7 +3799,7 @@ nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3854,7 +3799,7 @@ nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr,
{ {
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
return nfsd4_do_encode_secinfo(xdr, nfserr, secinfo->sin_exp); return nfsd4_do_encode_secinfo(xdr, secinfo->sin_exp);
} }
/* /*
...@@ -3915,16 +3860,14 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w ...@@ -3915,16 +3860,14 @@ nfsd4_encode_write(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_w
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (!nfserr) { p = xdr_reserve_space(xdr, 16);
p = xdr_reserve_space(xdr, 16); if (!p)
if (!p) return nfserr_resource;
return nfserr_resource; *p++ = cpu_to_be32(write->wr_bytes_written);
*p++ = cpu_to_be32(write->wr_bytes_written); *p++ = cpu_to_be32(write->wr_how_written);
*p++ = cpu_to_be32(write->wr_how_written); p = xdr_encode_opaque_fixed(p, write->wr_verifier.data,
p = xdr_encode_opaque_fixed(p, write->wr_verifier.data, NFS4_VERIFIER_SIZE);
NFS4_VERIFIER_SIZE); return 0;
}
return nfserr;
} }
static __be32 static __be32
...@@ -3937,12 +3880,8 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3937,12 +3880,8 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
char *server_scope; char *server_scope;
int major_id_sz; int major_id_sz;
int server_scope_sz; int server_scope_sz;
int status = 0;
uint64_t minor_id = 0; uint64_t minor_id = 0;
if (nfserr)
return nfserr;
major_id = utsname()->nodename; major_id = utsname()->nodename;
major_id_sz = strlen(major_id); major_id_sz = strlen(major_id);
server_scope = utsname()->nodename; server_scope = utsname()->nodename;
...@@ -3967,19 +3906,19 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -3967,19 +3906,19 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
break; break;
case SP4_MACH_CRED: case SP4_MACH_CRED:
/* spo_must_enforce bitmap: */ /* spo_must_enforce bitmap: */
status = nfsd4_encode_bitmap(xdr, nfserr = nfsd4_encode_bitmap(xdr,
exid->spo_must_enforce[0], exid->spo_must_enforce[0],
exid->spo_must_enforce[1], exid->spo_must_enforce[1],
exid->spo_must_enforce[2]); exid->spo_must_enforce[2]);
if (status) if (nfserr)
goto out; return nfserr;
/* spo_must_allow bitmap: */ /* spo_must_allow bitmap: */
status = nfsd4_encode_bitmap(xdr, nfserr = nfsd4_encode_bitmap(xdr,
exid->spo_must_allow[0], exid->spo_must_allow[0],
exid->spo_must_allow[1], exid->spo_must_allow[1],
exid->spo_must_allow[2]); exid->spo_must_allow[2]);
if (status) if (nfserr)
goto out; return nfserr;
break; break;
default: default:
WARN_ON_ONCE(1); WARN_ON_ONCE(1);
...@@ -4006,8 +3945,6 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4006,8 +3945,6 @@ nfsd4_encode_exchange_id(struct nfsd4_compoundres *resp, __be32 nfserr,
/* Implementation id */ /* Implementation id */
*p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */ *p++ = cpu_to_be32(0); /* zero length nfs_impl_id4 array */
return 0; return 0;
out:
return status;
} }
static __be32 static __be32
...@@ -4017,9 +3954,6 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4017,9 +3954,6 @@ nfsd4_encode_create_session(struct nfsd4_compoundres *resp, __be32 nfserr,
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 24); p = xdr_reserve_space(xdr, 24);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -4073,9 +4007,6 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4073,9 +4007,6 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, __be32 nfserr,
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20); p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 20);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -4100,9 +4031,6 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4100,9 +4031,6 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr,
struct nfsd4_test_stateid_id *stateid, *next; struct nfsd4_test_stateid_id *stateid, *next;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 4 + (4 * test_stateid->ts_num_ids)); p = xdr_reserve_space(xdr, 4 + (4 * test_stateid->ts_num_ids));
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -4112,7 +4040,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4112,7 +4040,7 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr,
*p++ = stateid->ts_id_status; *p++ = stateid->ts_id_status;
} }
return nfserr; return 0;
} }
#ifdef CONFIG_NFSD_PNFS #ifdef CONFIG_NFSD_PNFS
...@@ -4125,14 +4053,9 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4125,14 +4053,9 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
u32 starting_len = xdr->buf->len, needed_len; u32 starting_len = xdr->buf->len, needed_len;
__be32 *p; __be32 *p;
dprintk("%s: err %d\n", __func__, be32_to_cpu(nfserr));
if (nfserr)
goto out;
nfserr = nfserr_resource;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = cpu_to_be32(gdev->gd_layout_type); *p++ = cpu_to_be32(gdev->gd_layout_type);
...@@ -4148,41 +4071,33 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4148,41 +4071,33 @@ nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
*/ */
if (xdr->buf->len + 4 > gdev->gd_maxcount) if (xdr->buf->len + 4 > gdev->gd_maxcount)
goto toosmall; goto toosmall;
goto out; return nfserr;
} }
} }
nfserr = nfserr_resource;
if (gdev->gd_notify_types) { if (gdev->gd_notify_types) {
p = xdr_reserve_space(xdr, 4 + 4); p = xdr_reserve_space(xdr, 4 + 4);
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = cpu_to_be32(1); /* bitmap length */ *p++ = cpu_to_be32(1); /* bitmap length */
*p++ = cpu_to_be32(gdev->gd_notify_types); *p++ = cpu_to_be32(gdev->gd_notify_types);
} else { } else {
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = 0; *p++ = 0;
} }
nfserr = 0; return 0;
out:
dprintk("%s: done: %d\n", __func__, be32_to_cpu(nfserr));
return nfserr;
toosmall: toosmall:
dprintk("%s: maxcount too small\n", __func__); dprintk("%s: maxcount too small\n", __func__);
needed_len = xdr->buf->len + 4 /* notifications */; needed_len = xdr->buf->len + 4 /* notifications */;
xdr_truncate_encode(xdr, starting_len); xdr_truncate_encode(xdr, starting_len);
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) { if (!p)
nfserr = nfserr_resource; return nfserr_resource;
} else { *p++ = cpu_to_be32(needed_len);
*p++ = cpu_to_be32(needed_len); return nfserr_toosmall;
nfserr = nfserr_toosmall;
}
goto out;
} }
static __be32 static __be32
...@@ -4193,14 +4108,9 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4193,14 +4108,9 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr,
const struct nfsd4_layout_ops *ops; const struct nfsd4_layout_ops *ops;
__be32 *p; __be32 *p;
dprintk("%s: err %d\n", __func__, nfserr);
if (nfserr)
goto out;
nfserr = nfserr_resource;
p = xdr_reserve_space(xdr, 36 + sizeof(stateid_opaque_t)); p = xdr_reserve_space(xdr, 36 + sizeof(stateid_opaque_t));
if (!p) if (!p)
goto out; return nfserr_resource;
*p++ = cpu_to_be32(1); /* we always set return-on-close */ *p++ = cpu_to_be32(1); /* we always set return-on-close */
*p++ = cpu_to_be32(lgp->lg_sid.si_generation); *p++ = cpu_to_be32(lgp->lg_sid.si_generation);
...@@ -4214,9 +4124,7 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4214,9 +4124,7 @@ nfsd4_encode_layoutget(struct nfsd4_compoundres *resp, __be32 nfserr,
*p++ = cpu_to_be32(lgp->lg_layout_type); *p++ = cpu_to_be32(lgp->lg_layout_type);
ops = nfsd4_layout_ops[lgp->lg_layout_type]; ops = nfsd4_layout_ops[lgp->lg_layout_type];
nfserr = ops->encode_layoutget(xdr, lgp); return ops->encode_layoutget(xdr, lgp);
out:
return nfserr;
} }
static __be32 static __be32
...@@ -4226,9 +4134,6 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4226,9 +4134,6 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr,
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
...@@ -4240,7 +4145,7 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4240,7 +4145,7 @@ nfsd4_encode_layoutcommit(struct nfsd4_compoundres *resp, __be32 nfserr,
p = xdr_encode_hyper(p, lcp->lc_newsize); p = xdr_encode_hyper(p, lcp->lc_newsize);
} }
return nfs_ok; return 0;
} }
static __be32 static __be32
...@@ -4250,16 +4155,13 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4250,16 +4155,13 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr,
struct xdr_stream *xdr = &resp->xdr; struct xdr_stream *xdr = &resp->xdr;
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 4); p = xdr_reserve_space(xdr, 4);
if (!p) if (!p)
return nfserr_resource; return nfserr_resource;
*p++ = cpu_to_be32(lrp->lrs_present); *p++ = cpu_to_be32(lrp->lrs_present);
if (lrp->lrs_present) if (lrp->lrs_present)
return nfsd4_encode_stateid(xdr, &lrp->lr_sid); return nfsd4_encode_stateid(xdr, &lrp->lr_sid);
return nfs_ok; return 0;
} }
#endif /* CONFIG_NFSD_PNFS */ #endif /* CONFIG_NFSD_PNFS */
...@@ -4286,16 +4188,14 @@ nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4286,16 +4188,14 @@ nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr,
{ {
__be32 *p; __be32 *p;
if (!nfserr) { nfserr = nfsd42_encode_write_res(resp, &copy->cp_res);
nfserr = nfsd42_encode_write_res(resp, &copy->cp_res); if (nfserr)
if (nfserr) return nfserr;
return nfserr;
p = xdr_reserve_space(&resp->xdr, 4 + 4); p = xdr_reserve_space(&resp->xdr, 4 + 4);
*p++ = cpu_to_be32(copy->cp_consecutive); *p++ = cpu_to_be32(copy->cp_consecutive);
*p++ = cpu_to_be32(copy->cp_synchronous); *p++ = cpu_to_be32(copy->cp_synchronous);
} return 0;
return nfserr;
} }
static __be32 static __be32
...@@ -4304,14 +4204,11 @@ nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4304,14 +4204,11 @@ nfsd4_encode_seek(struct nfsd4_compoundres *resp, __be32 nfserr,
{ {
__be32 *p; __be32 *p;
if (nfserr)
return nfserr;
p = xdr_reserve_space(&resp->xdr, 4 + 8); p = xdr_reserve_space(&resp->xdr, 4 + 8);
*p++ = cpu_to_be32(seek->seek_eof); *p++ = cpu_to_be32(seek->seek_eof);
p = xdr_encode_hyper(p, seek->seek_pos); p = xdr_encode_hyper(p, seek->seek_pos);
return nfserr; return 0;
} }
static __be32 static __be32
......
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