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 | |
parent | 67492c990300912c717bc95e9f705feb63de2df9 (diff) |
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')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 14 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 22 |
2 files changed, 13 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 6a5b701961a4..a5b666ca560d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -1279,7 +1279,6 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1279 | struct nfsd4_compound_state *cstate = &resp->cstate; | 1279 | struct nfsd4_compound_state *cstate = &resp->cstate; |
1280 | struct svc_fh *current_fh = &cstate->current_fh; | 1280 | struct svc_fh *current_fh = &cstate->current_fh; |
1281 | struct svc_fh *save_fh = &cstate->save_fh; | 1281 | struct svc_fh *save_fh = &cstate->save_fh; |
1282 | int slack_bytes; | ||
1283 | u32 plen = 0; | 1282 | u32 plen = 0; |
1284 | __be32 status; | 1283 | __be32 status; |
1285 | 1284 | ||
@@ -1333,19 +1332,6 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1333 | goto encode_op; | 1332 | goto encode_op; |
1334 | } | 1333 | } |
1335 | 1334 | ||
1336 | /* We must be able to encode a successful response to | ||
1337 | * this operation, with enough room left over to encode a | ||
1338 | * failed response to the next operation. If we don't | ||
1339 | * have enough room, fail with ERR_RESOURCE. | ||
1340 | */ | ||
1341 | slack_bytes = (char *)resp->xdr.end - (char *)resp->xdr.p; | ||
1342 | if (slack_bytes < COMPOUND_SLACK_SPACE | ||
1343 | + COMPOUND_ERR_SLACK_SPACE) { | ||
1344 | BUG_ON(slack_bytes < COMPOUND_ERR_SLACK_SPACE); | ||
1345 | op->status = nfserr_resource; | ||
1346 | goto encode_op; | ||
1347 | } | ||
1348 | |||
1349 | opdesc = OPDESC(op); | 1335 | opdesc = OPDESC(op); |
1350 | 1336 | ||
1351 | if (!current_fh->fh_dentry) { | 1337 | if (!current_fh->fh_dentry) { |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 89c65a3e09e4..df643e0fb6b3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -3753,20 +3753,24 @@ static nfsd4_enc nfsd4_enc_ops[] = { | |||
3753 | __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 pad) | 3753 | __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 pad) |
3754 | { | 3754 | { |
3755 | struct xdr_buf *buf = &resp->rqstp->rq_res; | 3755 | struct xdr_buf *buf = &resp->rqstp->rq_res; |
3756 | struct nfsd4_session *session = NULL; | 3756 | struct nfsd4_session *session = resp->cstate.session; |
3757 | struct nfsd4_slot *slot = resp->cstate.slot; | 3757 | struct nfsd4_slot *slot = resp->cstate.slot; |
3758 | int slack_bytes = (char *)resp->xdr.end - (char *)resp->xdr.p; | ||
3758 | 3759 | ||
3759 | if (!nfsd4_has_session(&resp->cstate)) | 3760 | if (nfsd4_has_session(&resp->cstate)) { |
3760 | return 0; | ||
3761 | 3761 | ||
3762 | session = resp->cstate.session; | 3762 | if (buf->len + pad > session->se_fchannel.maxresp_sz) |
3763 | return nfserr_rep_too_big; | ||
3763 | 3764 | ||
3764 | if (buf->len + pad > session->se_fchannel.maxresp_sz) | 3765 | if ((slot->sl_flags & NFSD4_SLOT_CACHETHIS) && |
3765 | return nfserr_rep_too_big; | 3766 | buf->len + pad > session->se_fchannel.maxresp_cached) |
3767 | return nfserr_rep_too_big_to_cache; | ||
3768 | } | ||
3766 | 3769 | ||
3767 | if ((slot->sl_flags & NFSD4_SLOT_CACHETHIS) && | 3770 | if (pad > slack_bytes) { |
3768 | buf->len + pad > session->se_fchannel.maxresp_cached) | 3771 | WARN_ON_ONCE(nfsd4_has_session(&resp->cstate)); |
3769 | return nfserr_rep_too_big_to_cache; | 3772 | return nfserr_resource; |
3773 | } | ||
3770 | 3774 | ||
3771 | return 0; | 3775 | return 0; |
3772 | } | 3776 | } |