[sheepdog] [PATCH v6 10/17] sheep, http: don't allocate inode object on stack

Hitoshi Mitake mitake.hitoshi at gmail.com
Wed Mar 5 16:28:51 CET 2014


From: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>

The size of inode objects is expanded (larger than 12MB), so we
shouldn't allocate it on stack.

Cc: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
Cc: Valerio Pachera <sirio81 at gmail.com>
Cc: Alessandro Bolgia <alessandro at extensys.it>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/http/kv.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sheep/http/kv.c b/sheep/http/kv.c
index 6f648e3..aa80d20 100644
--- a/sheep/http/kv.c
+++ b/sheep/http/kv.c
@@ -586,7 +586,7 @@ out:
 
 int kv_iterate_bucket(const char *account, bucket_iter_cb cb, void *opaque)
 {
-	struct sd_inode account_inode;
+	struct sd_inode *account_inode;
 	struct bucket_iterater_arg arg = {opaque, cb, 0, 0, 0};
 	uint32_t account_vid;
 	uint64_t oid;
@@ -598,18 +598,21 @@ int kv_iterate_bucket(const char *account, bucket_iter_cb cb, void *opaque)
 		return ret;
 	}
 
+	account_inode = xzalloc(sizeof(*account_inode));
+
 	oid = vid_to_vdi_oid(account_vid);
 	sys->cdrv->lock(account_vid);
-	ret = sd_read_object(oid, (char *)&account_inode,
-			     sizeof(struct sd_inode), 0);
+	ret = sd_read_object(oid, (char *)account_inode,
+			     sizeof(*account_inode), 0);
 	if (ret != SD_RES_SUCCESS) {
 		sd_err("Failed to read account inode header %s", account);
 		goto out;
 	}
 
-	sd_inode_index_walk(&account_inode, bucket_iterater, &arg);
+	sd_inode_index_walk(account_inode, bucket_iterater, &arg);
 out:
 	sys->cdrv->unlock(account_vid);
+	free(account_inode);
 	return ret;
 }
 
-- 
1.8.3.2




More information about the sheepdog mailing list