[sheepdog] [PATCH v2 1/2] md: purge directory before md_add_disk

Liu Yuan namei.unix at gmail.com
Thu Sep 5 04:41:47 CEST 2013


Or it will falsely remove .stale directory for newly added disk.

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

diff --git a/sheep/md.c b/sheep/md.c
index 37feeb2..1339527 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -614,8 +614,10 @@ 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);
+			if (purge_directory(path) < 0)
+				sd_err("failed to purge %s", path);
+			if (!md_add_disk(path))
+				sd_err("failed to add %s", path);
 		} else {
 			md_del_disk(path);
 		}
-- 
1.7.9.5




More information about the sheepdog mailing list