summaryrefslogtreecommitdiffstats
path: root/glusterfsd
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2013-07-22 19:14:56 +0530
committerVijay Bellur <vbellur@redhat.com>2013-07-31 00:38:40 -0700
commit1127d5143c27532c07c694a4088dbeae48a1504c (patch)
tree1468e477f1620ca28c6b984b576f3f048893ed77 /glusterfsd
parentccb48ebfafba7ba50d3fb156ecd8ba9666577fd2 (diff)
glusterfsd: Use dynamic volfile buffer
Backport of fa78792 glusterfsd: Use dynamic volfile buffer from the master branch. Glusterfsd used a fixed buffer to store volfiles fetched via getspec. This caused problems with large volfiles. Changining this to a dynamic buffer allows large volfiles to be loaded in memory. BUG: 986100 Change-Id: I9ec86c09a00bc84fef7a0da05bbeb6b3e07d5146 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/5431 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 8082ad3d1d4..d20303a175c 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -1391,7 +1391,7 @@ out:
/* XXX: move these into @ctx */
-static char oldvolfile[131072];
+static char *oldvolfile = NULL;
static int oldvollen = 0;
static int
@@ -1552,6 +1552,7 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
int ret = 0;
ssize_t size = 0;
FILE *tmpfp = NULL;
+ char *volfilebuf = NULL;
frame = myframe;
ctx = frame->this->ctx;
@@ -1609,6 +1610,15 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
if (ret == 0) {
gf_log ("glusterfsd-mgmt", GF_LOG_DEBUG,
"No need to re-load volfile, reconfigure done");
+ if (oldvolfile)
+ volfilebuf = GF_REALLOC (oldvolfile, size);
+ else
+ volfilebuf = GF_CALLOC (1, size, gf_common_mt_char);
+ if (!volfilebuf) {
+ ret = -1;
+ goto out;
+ }
+ oldvolfile = volfilebuf;
oldvollen = size;
memcpy (oldvolfile, rsp.spec, size);
goto out;
@@ -1625,6 +1635,15 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
if (ret)
goto out;
+ if (oldvolfile)
+ volfilebuf = GF_REALLOC (oldvolfile, size);
+ else
+ volfilebuf = GF_CALLOC (1, size, gf_common_mt_char);
+ if (!volfilebuf) {
+ ret = -1;
+ goto out;
+ }
+ oldvolfile = volfilebuf;
oldvollen = size;
memcpy (oldvolfile, rsp.spec, size);
if (!is_mgmt_rpc_reconnect) {