diff options
author | J. Bruce Fields <bfields@redhat.com> | 2014-01-15 15:17:58 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-05-23 09:03:45 -0400 |
commit | 4aea24b2ff7510932118ec9b06c35a11625194ea (patch) | |
tree | fcd3b1ff1544696ebd0381d5fbbba0ec4ccd1df4 /fs | |
parent | e372ba60def1af33e1c0b9bbfa5c8f8559c1ad6b (diff) |
nfsd4: embed xdr_stream in nfsd4_compoundres
This is a mechanical transformation with no change in behavior.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 12 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 8 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 67 | ||||
-rw-r--r-- | fs/nfsd/xdr4.h | 4 |
4 files changed, 46 insertions, 45 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index b0e075cd6c99..6d94adf6c963 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -1270,13 +1270,13 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1270 | u32 plen = 0; | 1270 | u32 plen = 0; |
1271 | __be32 status; | 1271 | __be32 status; |
1272 | 1272 | ||
1273 | resp->xbuf = &rqstp->rq_res; | 1273 | resp->xdr.buf = &rqstp->rq_res; |
1274 | resp->p = rqstp->rq_res.head[0].iov_base + | 1274 | resp->xdr.p = rqstp->rq_res.head[0].iov_base + |
1275 | rqstp->rq_res.head[0].iov_len; | 1275 | rqstp->rq_res.head[0].iov_len; |
1276 | resp->tagp = resp->p; | 1276 | resp->tagp = resp->xdr.p; |
1277 | /* reserve space for: taglen, tag, and opcnt */ | 1277 | /* reserve space for: taglen, tag, and opcnt */ |
1278 | resp->p += 2 + XDR_QUADLEN(args->taglen); | 1278 | resp->xdr.p += 2 + XDR_QUADLEN(args->taglen); |
1279 | resp->end = rqstp->rq_res.head[0].iov_base + PAGE_SIZE; | 1279 | resp->xdr.end = rqstp->rq_res.head[0].iov_base + PAGE_SIZE; |
1280 | resp->taglen = args->taglen; | 1280 | resp->taglen = args->taglen; |
1281 | resp->tag = args->tag; | 1281 | resp->tag = args->tag; |
1282 | resp->opcnt = 0; | 1282 | resp->opcnt = 0; |
@@ -1328,7 +1328,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1328 | * failed response to the next operation. If we don't | 1328 | * failed response to the next operation. If we don't |
1329 | * have enough room, fail with ERR_RESOURCE. | 1329 | * have enough room, fail with ERR_RESOURCE. |
1330 | */ | 1330 | */ |
1331 | slack_bytes = (char *)resp->end - (char *)resp->p; | 1331 | slack_bytes = (char *)resp->xdr.end - (char *)resp->xdr.p; |
1332 | if (slack_bytes < COMPOUND_SLACK_SPACE | 1332 | if (slack_bytes < COMPOUND_SLACK_SPACE |
1333 | + COMPOUND_ERR_SLACK_SPACE) { | 1333 | + COMPOUND_ERR_SLACK_SPACE) { |
1334 | BUG_ON(slack_bytes < COMPOUND_ERR_SLACK_SPACE); | 1334 | BUG_ON(slack_bytes < COMPOUND_ERR_SLACK_SPACE); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 42f6c25ec8e8..14bfb5568715 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -1573,10 +1573,10 @@ nfsd4_store_cache_entry(struct nfsd4_compoundres *resp) | |||
1573 | slot->sl_datalen = 0; | 1573 | slot->sl_datalen = 0; |
1574 | return; | 1574 | return; |
1575 | } | 1575 | } |
1576 | slot->sl_datalen = (char *)resp->p - (char *)resp->cstate.datap; | 1576 | slot->sl_datalen = (char *)resp->xdr.p - (char *)resp->cstate.datap; |
1577 | base = (char *)resp->cstate.datap - | 1577 | base = (char *)resp->cstate.datap - |
1578 | (char *)resp->xbuf->head[0].iov_base; | 1578 | (char *)resp->xdr.buf->head[0].iov_base; |
1579 | if (read_bytes_from_xdr_buf(resp->xbuf, base, slot->sl_data, | 1579 | if (read_bytes_from_xdr_buf(resp->xdr.buf, base, slot->sl_data, |
1580 | slot->sl_datalen)) | 1580 | slot->sl_datalen)) |
1581 | WARN("%s: sessions DRC could not cache compound\n", __func__); | 1581 | WARN("%s: sessions DRC could not cache compound\n", __func__); |
1582 | return; | 1582 | return; |
@@ -1630,7 +1630,7 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp, | |||
1630 | memcpy(resp->cstate.datap, slot->sl_data, slot->sl_datalen); | 1630 | memcpy(resp->cstate.datap, slot->sl_data, slot->sl_datalen); |
1631 | 1631 | ||
1632 | resp->opcnt = slot->sl_opcnt; | 1632 | resp->opcnt = slot->sl_opcnt; |
1633 | resp->p = resp->cstate.datap + XDR_QUADLEN(slot->sl_datalen); | 1633 | resp->xdr.p = resp->cstate.datap + XDR_QUADLEN(slot->sl_datalen); |
1634 | status = slot->sl_status; | 1634 | status = slot->sl_status; |
1635 | 1635 | ||
1636 | return status; | 1636 | return status; |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e866a06b66bd..911372590ae1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -1747,10 +1747,10 @@ static void write_cinfo(__be32 **p, struct nfsd4_change_info *c) | |||
1747 | } | 1747 | } |
1748 | 1748 | ||
1749 | #define RESERVE_SPACE(nbytes) do { \ | 1749 | #define RESERVE_SPACE(nbytes) do { \ |
1750 | p = resp->p; \ | 1750 | p = resp->xdr.p; \ |
1751 | BUG_ON(p + XDR_QUADLEN(nbytes) > resp->end); \ | 1751 | BUG_ON(p + XDR_QUADLEN(nbytes) > resp->xdr.end); \ |
1752 | } while (0) | 1752 | } while (0) |
1753 | #define ADJUST_ARGS() resp->p = p | 1753 | #define ADJUST_ARGS() resp->xdr.p = p |
1754 | 1754 | ||
1755 | /* Encode as an array of strings the string given with components | 1755 | /* Encode as an array of strings the string given with components |
1756 | * separated @sep, escaped with esc_enter and esc_exit. | 1756 | * separated @sep, escaped with esc_enter and esc_exit. |
@@ -2751,9 +2751,9 @@ nfsd4_encode_getattr(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
2751 | if (nfserr) | 2751 | if (nfserr) |
2752 | return nfserr; | 2752 | return nfserr; |
2753 | 2753 | ||
2754 | buflen = resp->end - resp->p - (COMPOUND_ERR_SLACK_SPACE >> 2); | 2754 | buflen = resp->xdr.end - resp->xdr.p - (COMPOUND_ERR_SLACK_SPACE >> 2); |
2755 | nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry, | 2755 | nfserr = nfsd4_encode_fattr(fhp, fhp->fh_export, fhp->fh_dentry, |
2756 | &resp->p, buflen, getattr->ga_bmval, | 2756 | &resp->xdr.p, buflen, getattr->ga_bmval, |
2757 | resp->rqstp, 0); | 2757 | resp->rqstp, 0); |
2758 | return nfserr; | 2758 | return nfserr; |
2759 | } | 2759 | } |
@@ -2953,7 +2953,7 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
2953 | 2953 | ||
2954 | if (nfserr) | 2954 | if (nfserr) |
2955 | return nfserr; | 2955 | return nfserr; |
2956 | if (resp->xbuf->page_len) | 2956 | if (resp->xdr.buf->page_len) |
2957 | return nfserr_resource; | 2957 | return nfserr_resource; |
2958 | 2958 | ||
2959 | RESERVE_SPACE(8); /* eof flag and byte count */ | 2959 | RESERVE_SPACE(8); /* eof flag and byte count */ |
@@ -2991,18 +2991,18 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, | |||
2991 | WRITE32(eof); | 2991 | WRITE32(eof); |
2992 | WRITE32(maxcount); | 2992 | WRITE32(maxcount); |
2993 | ADJUST_ARGS(); | 2993 | ADJUST_ARGS(); |
2994 | resp->xbuf->head[0].iov_len = (char*)p | 2994 | resp->xdr.buf->head[0].iov_len = (char *)p |
2995 | - (char*)resp->xbuf->head[0].iov_base; | 2995 | - (char *)resp->xdr.buf->head[0].iov_base; |
2996 | resp->xbuf->page_len = maxcount; | 2996 | resp->xdr.buf->page_len = maxcount; |
2997 | 2997 | ||
2998 | /* Use rest of head for padding and remaining ops: */ | 2998 | /* Use rest of head for padding and remaining ops: */ |
2999 | resp->xbuf->tail[0].iov_base = p; | 2999 | resp->xdr.buf->tail[0].iov_base = p; |
3000 | resp->xbuf->tail[0].iov_len = 0; | 3000 | resp->xdr.buf->tail[0].iov_len = 0; |
3001 | if (maxcount&3) { | 3001 | if (maxcount&3) { |
3002 | RESERVE_SPACE(4); | 3002 | RESERVE_SPACE(4); |
3003 | WRITE32(0); | 3003 | WRITE32(0); |
3004 | resp->xbuf->tail[0].iov_base += maxcount&3; | 3004 | resp->xdr.buf->tail[0].iov_base += maxcount&3; |
3005 | resp->xbuf->tail[0].iov_len = 4 - (maxcount&3); | 3005 | resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3); |
3006 | ADJUST_ARGS(); | 3006 | ADJUST_ARGS(); |
3007 | } | 3007 | } |
3008 | return 0; | 3008 | return 0; |
@@ -3017,7 +3017,7 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd | |||
3017 | 3017 | ||
3018 | if (nfserr) | 3018 | if (nfserr) |
3019 | return nfserr; | 3019 | return nfserr; |
3020 | if (resp->xbuf->page_len) | 3020 | if (resp->xdr.buf->page_len) |
3021 | return nfserr_resource; | 3021 | return nfserr_resource; |
3022 | if (!*resp->rqstp->rq_next_page) | 3022 | if (!*resp->rqstp->rq_next_page) |
3023 | return nfserr_resource; | 3023 | return nfserr_resource; |
@@ -3041,18 +3041,18 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd | |||
3041 | 3041 | ||
3042 | WRITE32(maxcount); | 3042 | WRITE32(maxcount); |
3043 | ADJUST_ARGS(); | 3043 | ADJUST_ARGS(); |
3044 | resp->xbuf->head[0].iov_len = (char*)p | 3044 | resp->xdr.buf->head[0].iov_len = (char *)p |
3045 | - (char*)resp->xbuf->head[0].iov_base; | 3045 | - (char *)resp->xdr.buf->head[0].iov_base; |
3046 | resp->xbuf->page_len = maxcount; | 3046 | resp->xdr.buf->page_len = maxcount; |
3047 | 3047 | ||
3048 | /* Use rest of head for padding and remaining ops: */ | 3048 | /* Use rest of head for padding and remaining ops: */ |
3049 | resp->xbuf->tail[0].iov_base = p; | 3049 | resp->xdr.buf->tail[0].iov_base = p; |
3050 | resp->xbuf->tail[0].iov_len = 0; | 3050 | resp->xdr.buf->tail[0].iov_len = 0; |
3051 | if (maxcount&3) { | 3051 | if (maxcount&3) { |
3052 | RESERVE_SPACE(4); | 3052 | RESERVE_SPACE(4); |
3053 | WRITE32(0); | 3053 | WRITE32(0); |
3054 | resp->xbuf->tail[0].iov_base += maxcount&3; | 3054 | resp->xdr.buf->tail[0].iov_base += maxcount&3; |
3055 | resp->xbuf->tail[0].iov_len = 4 - (maxcount&3); | 3055 | resp->xdr.buf->tail[0].iov_len = 4 - (maxcount&3); |
3056 | ADJUST_ARGS(); | 3056 | ADJUST_ARGS(); |
3057 | } | 3057 | } |
3058 | return 0; | 3058 | return 0; |
@@ -3068,7 +3068,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
3068 | 3068 | ||
3069 | if (nfserr) | 3069 | if (nfserr) |
3070 | return nfserr; | 3070 | return nfserr; |
3071 | if (resp->xbuf->page_len) | 3071 | if (resp->xdr.buf->page_len) |
3072 | return nfserr_resource; | 3072 | return nfserr_resource; |
3073 | if (!*resp->rqstp->rq_next_page) | 3073 | if (!*resp->rqstp->rq_next_page) |
3074 | return nfserr_resource; | 3074 | return nfserr_resource; |
@@ -3080,7 +3080,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
3080 | WRITE32(0); | 3080 | WRITE32(0); |
3081 | WRITE32(0); | 3081 | WRITE32(0); |
3082 | ADJUST_ARGS(); | 3082 | ADJUST_ARGS(); |
3083 | resp->xbuf->head[0].iov_len = ((char*)resp->p) - (char*)resp->xbuf->head[0].iov_base; | 3083 | resp->xdr.buf->head[0].iov_len = ((char *)resp->xdr.p) |
3084 | - (char *)resp->xdr.buf->head[0].iov_base; | ||
3084 | tailbase = p; | 3085 | tailbase = p; |
3085 | 3086 | ||
3086 | maxcount = PAGE_SIZE; | 3087 | maxcount = PAGE_SIZE; |
@@ -3121,14 +3122,15 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4 | |||
3121 | p = readdir->buffer; | 3122 | p = readdir->buffer; |
3122 | *p++ = 0; /* no more entries */ | 3123 | *p++ = 0; /* no more entries */ |
3123 | *p++ = htonl(readdir->common.err == nfserr_eof); | 3124 | *p++ = htonl(readdir->common.err == nfserr_eof); |
3124 | resp->xbuf->page_len = ((char*)p) - | 3125 | resp->xdr.buf->page_len = ((char *)p) - |
3125 | (char*)page_address(*(resp->rqstp->rq_next_page-1)); | 3126 | (char*)page_address(*(resp->rqstp->rq_next_page-1)); |
3126 | 3127 | ||
3127 | /* Use rest of head for padding and remaining ops: */ | 3128 | /* Use rest of head for padding and remaining ops: */ |
3128 | resp->xbuf->tail[0].iov_base = tailbase; | 3129 | resp->xdr.buf->tail[0].iov_base = tailbase; |
3129 | resp->xbuf->tail[0].iov_len = 0; | 3130 | resp->xdr.buf->tail[0].iov_len = 0; |
3130 | resp->p = resp->xbuf->tail[0].iov_base; | 3131 | resp->xdr.p = resp->xdr.buf->tail[0].iov_base; |
3131 | resp->end = resp->p + (PAGE_SIZE - resp->xbuf->head[0].iov_len)/4; | 3132 | resp->xdr.end = resp->xdr.p + |
3133 | (PAGE_SIZE - resp->xdr.buf->head[0].iov_len)/4; | ||
3132 | 3134 | ||
3133 | return 0; | 3135 | return 0; |
3134 | err_no_verf: | 3136 | err_no_verf: |
@@ -3587,10 +3589,10 @@ __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *resp, u32 pad) | |||
3587 | session = resp->cstate.session; | 3589 | session = resp->cstate.session; |
3588 | 3590 | ||
3589 | if (xb->page_len == 0) { | 3591 | if (xb->page_len == 0) { |
3590 | length = (char *)resp->p - (char *)xb->head[0].iov_base + pad; | 3592 | length = (char *)resp->xdr.p - (char *)xb->head[0].iov_base + pad; |
3591 | } else { | 3593 | } else { |
3592 | if (xb->tail[0].iov_base && xb->tail[0].iov_len > 0) | 3594 | if (xb->tail[0].iov_base && xb->tail[0].iov_len > 0) |
3593 | tlen = (char *)resp->p - (char *)xb->tail[0].iov_base; | 3595 | tlen = (char *)resp->xdr.p - (char *)xb->tail[0].iov_base; |
3594 | 3596 | ||
3595 | length = xb->head[0].iov_len + xb->page_len + tlen + pad; | 3597 | length = xb->head[0].iov_len + xb->page_len + tlen + pad; |
3596 | } | 3598 | } |
@@ -3629,7 +3631,8 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) | |||
3629 | op->status = nfsd4_check_resp_size(resp, 0); | 3631 | op->status = nfsd4_check_resp_size(resp, 0); |
3630 | if (so) { | 3632 | if (so) { |
3631 | so->so_replay.rp_status = op->status; | 3633 | so->so_replay.rp_status = op->status; |
3632 | so->so_replay.rp_buflen = (char *)resp->p - (char *)(statp+1); | 3634 | so->so_replay.rp_buflen = (char *)resp->xdr.p |
3635 | - (char *)(statp+1); | ||
3633 | memcpy(so->so_replay.rp_buf, statp+1, so->so_replay.rp_buflen); | 3636 | memcpy(so->so_replay.rp_buf, statp+1, so->so_replay.rp_buflen); |
3634 | } | 3637 | } |
3635 | status: | 3638 | status: |
@@ -3731,7 +3734,7 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compo | |||
3731 | iov = &rqstp->rq_res.tail[0]; | 3734 | iov = &rqstp->rq_res.tail[0]; |
3732 | else | 3735 | else |
3733 | iov = &rqstp->rq_res.head[0]; | 3736 | iov = &rqstp->rq_res.head[0]; |
3734 | iov->iov_len = ((char*)resp->p) - (char*)iov->iov_base; | 3737 | iov->iov_len = ((char *)resp->xdr.p) - (char *)iov->iov_base; |
3735 | BUG_ON(iov->iov_len > PAGE_SIZE); | 3738 | BUG_ON(iov->iov_len > PAGE_SIZE); |
3736 | if (nfsd4_has_session(cs)) { | 3739 | if (nfsd4_has_session(cs)) { |
3737 | struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); | 3740 | struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); |
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 5ea7df305083..6884d70363b5 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h | |||
@@ -506,9 +506,7 @@ struct nfsd4_compoundargs { | |||
506 | 506 | ||
507 | struct nfsd4_compoundres { | 507 | struct nfsd4_compoundres { |
508 | /* scratch variables for XDR encode */ | 508 | /* scratch variables for XDR encode */ |
509 | __be32 * p; | 509 | struct xdr_stream xdr; |
510 | __be32 * end; | ||
511 | struct xdr_buf * xbuf; | ||
512 | struct svc_rqst * rqstp; | 510 | struct svc_rqst * rqstp; |
513 | 511 | ||
514 | u32 taglen; | 512 | u32 taglen; |