[sheepdog] [PATCH 3/5] sheep: split up pathname initialization

Liu Yuan namei.unix at gmail.com
Tue Dec 4 13:20:29 CET 2012


From: Liu Yuan <tailai.ly at taobao.com>

Then init_store() can be called as late as possible. We want it late because
init_store() expect a env that has work queues ready.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c      |    2 +-
 sheep/sheep_priv.h |    1 +
 sheep/store.c      |   14 +++++++++++++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index a54e008..2ba9008 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -510,7 +510,7 @@ int main(int argc, char **argv)
 	if (ret)
 		exit(1);
 
-	ret = init_obj_path(dir);
+	ret = init_global_pathnames(dir);
 	if (ret)
 		exit(1);
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index f5cd555..bcdf427 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -221,6 +221,7 @@ int create_listen_port(char *bindaddr, int port);
 int init_unix_domain_socket(const char *dir);
 
 int init_store(const char *dir);
+int init_global_pathnames(const char *d);
 int init_base_path(const char *dir);
 int init_obj_path(const char *base_path);
 
diff --git a/sheep/store.c b/sheep/store.c
index 893d334..3c4f1d5 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -371,10 +371,15 @@ out:
 	return ret;
 }
 
-int init_store(const char *d)
+/* Initilize all the global pathnames used internally */
+int init_global_pathnames(const char *d)
 {
 	int ret;
 
+	ret = init_obj_path(d);
+	if (ret)
+		return ret;
+
 	ret = init_epoch_path(d);
 	if (ret)
 		return ret;
@@ -387,6 +392,13 @@ int init_store(const char *d)
 	if (ret)
 		return ret;
 
+	return 0;
+}
+
+int init_store(const char *d)
+{
+	int ret;
+
 	ret = init_disk_space(d);
 	if (ret)
 		return ret;
-- 
1.7.9.5




More information about the sheepdog mailing list