[sheepdog] [PATCH stable-0.7] sheep: daemon should exit directly if there is no availabe disk

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Thu Dec 26 03:01:57 CET 2013


From: Robin Dong <sanbai at taobao.com>

Currently, the sheep daemon will only report "multi-disk support need xattr feature"
and continue to run when all the data pathe are not support xattr.But if we create
a vdi, it will report path is broken.
So, we need to check the return code of md_add_disk() and exit if all the path is
unavailabe.

This patch also fix some log level in source code.

Signed-off-by: Robin Dong <sanbai at taobao.com>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 lib/net.c     |    4 ++--
 sheep/md.c    |    3 ++-
 sheep/sheep.c |    4 ++--
 sheep/store.c |   15 ++++++++++++++-
 4 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/lib/net.c b/lib/net.c
index 82b6e3a..ce978b2 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -592,12 +592,12 @@ int get_local_addr(uint8_t *bytes)
 			memset(bytes, 0, 12);
 			memcpy(bytes + 12, &sin->sin_addr, 4);
 			memcpy(bytes + 12, &sin->sin_addr, 4);
-			sd_err("found IPv4 address");
+			sd_notice("found IPv4 address");
 			goto out;
 		case AF_INET6:
 			sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
 			memcpy(bytes, &sin6->sin6_addr, 16);
-			sd_err("found IPv6 address");
+			sd_notice("found IPv6 address");
 			goto out;
 		}
 	}
diff --git a/sheep/md.c b/sheep/md.c
index 777d974..1c22b72 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -259,7 +259,8 @@ static uint64_t init_path_space(char *path)
 	char stale[PATH_MAX];
 
 	if (!is_xattr_enabled(path)) {
-		sd_info("multi-disk support need xattr feature");
+		sd_warn("multi-disk support need xattr feature for path: %s",
+			path);
 		goto broken_path;
 	}
 
diff --git a/sheep/sheep.c b/sheep/sheep.c
index c6ac8f6..c404c36 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -464,8 +464,8 @@ static void check_host_env(void)
 	 * dangerous to run Sheepdog cluster.
 	 */
 	else if (r.rlim_cur == 1024)
-		sd_err("WARN: Allowed open files 1024 too small, suggested %u",
-		       SD_RLIM_NOFILE);
+		sd_warn("Allowed open files 1024 too small, suggested %u",
+			SD_RLIM_NOFILE);
 	else if (r.rlim_cur < SD_RLIM_NOFILE)
 		sd_info("Allowed open files %lu, suggested %u", r.rlim_cur,
 			SD_RLIM_NOFILE);
diff --git a/sheep/store.c b/sheep/store.c
index 3e898b8..2c1e96e 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -203,7 +203,8 @@ static int is_meta_store(const char *path)
 static int init_obj_path(const char *base_path, char *argp)
 {
 	char *p;
-	int len;
+	int len, ret;
+	struct sd_md_info mdi;
 
 	if (check_path_len(base_path) < 0)
 		return -1;
@@ -232,6 +233,18 @@ static int init_obj_path(const char *base_path, char *argp)
 			md_add_disk(p);
 		} while ((p = strtok(NULL, ",")));
 	}
+
+	ret = md_get_info(&mdi);
+	if (ret != sizeof(mdi)) {
+		sd_err("Can't get md info");
+		return -1;
+	}
+
+	if (mdi.nr <= 0) {
+		sd_err("There isn't any available disk!");
+		return -1;
+	}
+
 	return xmkdir(obj_path, sd_def_dmode);
 }
 
-- 
1.7.10.4




More information about the sheepdog mailing list