From f78c8253d7fb75762effcf64683cbce10783a55b Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Sun, 28 Aug 2011 12:53:12 +0530 Subject: glusterfs protocol: bring in variable sized iobuf support is a step towards reducing glusterfs memory footprint. should also help a bit in overall performance. Change-Id: I074d5813602b2c960d59562e792b3dc6e43d2f42 BUG: 3475 Reviewed-on: http://review.gluster.com/322 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/protocol/client/src/client.c | 75 +++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 35 deletions(-) (limited to 'xlators/protocol/client/src/client.c') diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index f9c86835f..77e3f5413 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -47,7 +47,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, struct iobref *iobref, gfs_serialize_t sfunc, struct iovec *rsphdr, int rsphdr_count, struct iovec *rsp_payload, int rsp_payload_count, - struct iobref *rsp_iobref) + struct iobref *rsp_iobref, xdrproc_t xdrproc) { int ret = -1; clnt_conf_t *conf = NULL; @@ -56,6 +56,7 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, int count = 0; char start_ping = 0; struct iobref *new_iobref = NULL; + ssize_t xdr_size = 0; GF_VALIDATE_OR_GOTO ("client", this, out); GF_VALIDATE_OR_GOTO (this->name, prog, out); @@ -78,48 +79,52 @@ client_submit_request (xlator_t *this, void *req, call_frame_t *frame, goto out; } - iobuf = iobuf_get (this->ctx->iobuf_pool); - if (!iobuf) { - goto out; - }; + if (req && xdrproc) { + xdr_size = xdr_sizeof (xdrproc, req); + iobuf = iobuf_get2 (this->ctx->iobuf_pool, xdr_size); + if (!iobuf) { + goto out; + }; - new_iobref = iobref_new (); - if (!new_iobref) { - goto out; - } + new_iobref = iobref_new (); + if (!new_iobref) { + goto out; + } - if (iobref != NULL) { - ret = iobref_merge (new_iobref, iobref); + if (iobref != NULL) { + ret = iobref_merge (new_iobref, iobref); + if (ret != 0) { + gf_log (this->name, GF_LOG_WARNING, + "cannot merge iobref passed from caller " + "into new_iobref"); + } + } + + ret = iobref_add (new_iobref, iobuf); if (ret != 0) { gf_log (this->name, GF_LOG_WARNING, - "cannot merge iobref passed from caller " - "into new_iobref"); + "cannot add iobuf into iobref"); + goto out; } - } - - ret = iobref_add (new_iobref, iobuf); - if (ret != 0) { - gf_log (this->name, GF_LOG_WARNING, - "cannot add iobuf into iobref"); - goto out; - } - iov.iov_base = iobuf->ptr; - iov.iov_len = 128 * GF_UNIT_KB; - - /* Create the xdr payload */ - if (req && sfunc) { - ret = sfunc (iov, req); - if (ret == -1) { - /* callingfn so that, we can get to know which xdr - function was called */ - gf_log_callingfn (this->name, GF_LOG_WARNING, - "XDR payload creation failed"); - goto out; + iov.iov_base = iobuf->ptr; + iov.iov_len = iobuf_size (iobuf); + + /* Create the xdr payload */ + if (sfunc) { + ret = sfunc (iov, req); + if (ret == -1) { + /* callingfn so that, we can get to know which xdr + function was called */ + gf_log_callingfn (this->name, GF_LOG_WARNING, + "XDR payload creation failed"); + goto out; + } + iov.iov_len = ret; + count = 1; } - iov.iov_len = ret; - count = 1; } + /* Send the msg */ ret = rpc_clnt_submit (conf->rpc, prog, procnum, cbk, &iov, count, NULL, 0, new_iobref, frame, rsphdr, rsphdr_count, -- cgit