[sheepdog] [PATCH] collie: use smaller stack size

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Mon Mar 11 08:17:49 CET 2013


This fixes a false alarm of ./check -valgrind and reduces the risk of
stack overflow.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 collie/cluster.c | 2 +-
 collie/vdi.c     | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/collie/cluster.c b/collie/cluster.c
index 505f65e..9c5974a 100644
--- a/collie/cluster.c
+++ b/collie/cluster.c
@@ -87,7 +87,7 @@ static int cluster_format(int argc, char **argv)
 	struct sd_so_rsp *rsp = (struct sd_so_rsp *)&hdr;
 	struct timeval tv;
 	char store_name[STORE_LEN];
-	DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
+	static DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
 	unsigned long nr;
 
 	fd = connect_to(sdhost, sdport);
diff --git a/collie/vdi.c b/collie/vdi.c
index 78b81f5..94acca9 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -866,7 +866,7 @@ static int do_track_object(uint64_t oid, uint8_t nr_copies)
 	int i, j, fd, ret;
 	struct sd_req hdr;
 	struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
-	struct sd_vnode vnodes[SD_MAX_VNODES];
+	struct sd_vnode *vnodes;
 	const struct sd_vnode *vnode_buf[SD_MAX_COPIES];
 	struct epoch_log *logs;
 	int vnodes_nr, nr_logs, log_length;
@@ -874,6 +874,7 @@ static int do_track_object(uint64_t oid, uint8_t nr_copies)
 
 	log_length = sd_epoch * sizeof(struct epoch_log);
 	logs = xmalloc(log_length);
+	vnodes = xmalloc(sizeof(*vnodes) * SD_MAX_VNODES);
 	fd = connect_to(sdhost, sdport);
 	if (fd < 0)
 		goto error;
@@ -922,9 +923,11 @@ static int do_track_object(uint64_t oid, uint8_t nr_copies)
 	}
 
 	free(logs);
+	free(vnodes);
 	return EXIT_SUCCESS;
 error:
 	free(logs);
+	free(vnodes);
 	return EXIT_SYSFAIL;
 }
 
-- 
1.8.1.3.566.gaa39828




More information about the sheepdog mailing list