diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-03-08 17:19:55 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-30 17:31:52 -0400 |
commit | ea8d7720b274607f48fb524337254a9c43dbc2df (patch) | |
tree | 174b409140dcca608e505542ca058933d7292346 /fs/nfsd/nfs4xdr.c | |
parent | 67492c990300912c717bc95e9f705feb63de2df9 (diff) | |
download | op-kernel-dev-ea8d7720b274607f48fb524337254a9c43dbc2df.zip op-kernel-dev-ea8d7720b274607f48fb524337254a9c43dbc2df.tar.gz |
nfsd4: remove redundant encode buffer size checking
Now that all op encoders can handle running out of space, we no longer
need to check the remaining size for every operation; only nonidempotent
operations need that check, and that can be done by
nfsd4_check_resp_size.
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 89c65a3..df643e0 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3753,20 +3753,24 @@ static nfsd4_enc nfsd4_enc_ops[] = { __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 pad) { struct xdr_buf *buf = &resp->rqstp->rq_res; - struct nfsd4_session *session = NULL; + struct nfsd4_session *session = resp->cstate.session; struct nfsd4_slot *slot = resp->cstate.slot; + int slack_bytes = (char *)resp->xdr.end - (char *)resp->xdr.p; - if (!nfsd4_has_session(&resp->cstate)) - return 0; + if (nfsd4_has_session(&resp->cstate)) { - session = resp->cstate.session; + if (buf->len + pad > session->se_fchannel.maxresp_sz) + return nfserr_rep_too_big; - if (buf->len + pad > session->se_fchannel.maxresp_sz) - return nfserr_rep_too_big; + if ((slot->sl_flags & NFSD4_SLOT_CACHETHIS) && + buf->len + pad > session->se_fchannel.maxresp_cached) + return nfserr_rep_too_big_to_cache; + } - if ((slot->sl_flags & NFSD4_SLOT_CACHETHIS) && - buf->len + pad > session->se_fchannel.maxresp_cached) - return nfserr_rep_too_big_to_cache; + if (pad > slack_bytes) { + WARN_ON_ONCE(nfsd4_has_session(&resp->cstate)); + return nfserr_resource; + } return 0; } |