diff options
author | Amar Tumballi <amar@gluster.com> | 2012-02-14 15:05:19 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2012-02-20 00:46:27 -0800 |
commit | c0b8e886cac4ef0f16d5f93adab02229bb1414cd (patch) | |
tree | 03f5bc6550d5f2501d5b968776f4bb0ee8025310 /rpc/rpc-transport | |
parent | 975933a25d14cbac861e809b40c6edd01acaa28d (diff) |
iobuf: use 'iobuf_get2()' to get variable sized buffers
added 'TODO' in places where it is missing.
Change-Id: Ia802c94e3bb76930f7c88c990f078525be5459f5
Signed-off-by: Amar Tumballi <amar@gluster.com>
BUG: 765264
Reviewed-on: http://review.gluster.com/388
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'rpc/rpc-transport')
-rw-r--r-- | rpc/rpc-transport/rdma/src/rdma.c | 23 | ||||
-rw-r--r-- | rpc/rpc-transport/socket/src/socket.c | 15 |
2 files changed, 21 insertions, 17 deletions
diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c index d3a8e9c8d..04531cda0 100644 --- a/rpc/rpc-transport/rdma/src/rdma.c +++ b/rpc/rpc-transport/rdma/src/rdma.c @@ -1992,7 +1992,7 @@ gf_rdma_receive (rpc_transport_t *this, char **hdr_p, size_t *hdrlen_p, *hdrlen_p = size1; if (size2) { - iobuf = iobuf_get (this->ctx->iobuf_pool); + iobuf = iobuf_get2 (this->ctx->iobuf_pool, size2); if (!iobuf) { gf_log (this->name, GF_LOG_ERROR, "unable to allocate IO buffer for peer %s", @@ -2716,7 +2716,7 @@ gf_rdma_decode_error_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, ntoh32 (header->rm_body.rm_error.rm_version.gf_rdma_vers_high); } - iobuf = iobuf_get (peer->trans->ctx->iobuf_pool); + iobuf = iobuf_get2 (peer->trans->ctx->iobuf_pool, bytes_in_post); if (iobuf == NULL) { ret = -1; goto out; @@ -2822,15 +2822,17 @@ gf_rdma_decode_msg (gf_rdma_peer_t *peer, gf_rdma_post_t *post, /* skip terminator of reply chunk */ ptr = ptr + sizeof (uint32_t); if (header->rm_type != GF_RDMA_NOMSG) { - post->ctx.hdr_iobuf = iobuf_get (peer->trans->ctx->iobuf_pool); + header_len = (long)ptr - (long)post->buf; + post->ctx.vector[0].iov_len = (bytes_in_post - header_len); + + post->ctx.hdr_iobuf = iobuf_get2 (peer->trans->ctx->iobuf_pool, + (bytes_in_post - header_len)); if (post->ctx.hdr_iobuf == NULL) { ret = -1; goto out; } - header_len = (long)ptr - (long)post->buf; post->ctx.vector[0].iov_base = iobuf_ptr (post->ctx.hdr_iobuf); - post->ctx.vector[0].iov_len = bytes_in_post - header_len; memcpy (post->ctx.vector[0].iov_base, ptr, post->ctx.vector[0].iov_len); post->ctx.count = 1; @@ -2965,16 +2967,7 @@ gf_rdma_do_reads (gf_rdma_peer_t *peer, gf_rdma_post_t *post, post->ctx.gf_rdma_reads = i; - if (size > peer->trans->ctx->page_size) { - gf_log (GF_RDMA_LOG_NAME, GF_LOG_ERROR, - "total size of rdma-read (%lu) is greater than " - "page-size (%lu). This is not supported till variable " - "sized iobufs are implemented", (unsigned long)size, - (unsigned long)peer->trans->ctx->page_size); - goto out; - } - - iobuf = iobuf_get (peer->trans->ctx->iobuf_pool); + iobuf = iobuf_get2 (peer->trans->ctx->iobuf_pool, size); if (iobuf == NULL) { goto out; } diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index 3b2d05c45..120e193dd 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -823,6 +823,7 @@ __socket_read_vectored_request (rpc_transport_t *this, rpcsvc_vector_sizer vecto struct iobuf *iobuf = NULL; uint32_t remaining_size = 0; ssize_t readsize = 0; + size_t size = 0; GF_VALIDATE_OR_GOTO ("socket", this, out); GF_VALIDATE_OR_GOTO ("socket", this->private, out); @@ -907,7 +908,10 @@ sp_state_reading_proghdr: case SP_STATE_READ_PROGHDR: if (priv->incoming.payload_vector.iov_base == NULL) { - iobuf = iobuf_get (this->ctx->iobuf_pool); + + size = RPC_FRAGSIZE (priv->incoming.fraghdr) - + priv->incoming.frag.bytes_read; + iobuf = iobuf_get2 (this->ctx->iobuf_pool, size); if (!iobuf) { ret = -1; break; @@ -1048,6 +1052,7 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this) struct iobuf *iobuf = NULL; uint32_t gluster_read_rsp_hdr_len = 0; gfs3_read_rsp read_rsp = {0, }; + size_t size = 0; GF_VALIDATE_OR_GOTO ("socket", this, out); GF_VALIDATE_OR_GOTO ("socket", this->private, out); @@ -1080,7 +1085,11 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this) = SP_STATE_READ_PROC_HEADER; if (priv->incoming.payload_vector.iov_base == NULL) { - iobuf = iobuf_get (this->ctx->iobuf_pool); + + size = (RPC_FRAGSIZE (priv->incoming.fraghdr) - + priv->incoming.frag.bytes_read); + + iobuf = iobuf_get2 (this->ctx->iobuf_pool, size); if (iobuf == NULL) { ret = -1; goto out; @@ -1100,6 +1109,8 @@ __socket_read_accepted_successful_reply (rpc_transport_t *this) priv->incoming.payload_vector.iov_base = iobuf_ptr (iobuf); + + priv->incoming.payload_vector.iov_len = size; } priv->incoming.frag.fragcurrent |