summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2011-08-28 12:53:12 +0530
committerAnand Avati <avati@gluster.com>2011-09-07 10:48:29 -0700
commitf78c8253d7fb75762effcf64683cbce10783a55b (patch)
tree8a0280da8fb69502383334cd16048e9d96145841 /xlators/protocol/client/src/client.c
parent10d49cf0878e96301ea366276e27e91b5527483e (diff)
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 <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators/protocol/client/src/client.c')
-rw-r--r--xlators/protocol/client/src/client.c75
1 files changed, 40 insertions, 35 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index f9c86835f9c..77e3f5413a1 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,