[sheepdog] [PATCH 1/2] md: move purge_directory in init_path_space()

Liu Yuan namei.unix at gmail.com
Wed Sep 4 14:40:55 CEST 2013


This also fixes a bug that false-remove .stale for newly plugged disk due to
commit 882d028

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/md.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sheep/md.c b/sheep/md.c
index 37feeb2..3ce0b15 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -215,7 +215,12 @@ static uint64_t init_path_space(const char *path)
 	char stale[PATH_MAX];
 
 	if (!is_xattr_enabled(path)) {
-		sd_info("multi-disk support need xattr feature");
+		sd_err("multi-disk support need xattr feature");
+		goto broken_path;
+	}
+
+	if (purge_directory(path) < 0) {
+		sd_err("failed to purge %s", path);
 		goto broken_path;
 	}
 
@@ -614,8 +619,7 @@ static int do_plug_unplug(char *disks, bool plug)
 	path = strtok(disks, ",");
 	do {
 		if (plug) {
-			if (md_add_disk(path) && purge_directory(path) < 0)
-				md_del_disk(path);
+			md_add_disk(path);
 		} else {
 			md_del_disk(path);
 		}
-- 
1.7.9.5




More information about the sheepdog mailing list