[sheepdog] [PATCH v2 2/2] store: make objects stale when sheep starts

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun Aug 26 03:04:52 CEST 2012


It is unsafe to remove objects in the working directory when starting
sheeps because it is not sure that the objects are correctly recovered
to other nodes' working directory.  We should make them stale objects
rather than removing them.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/plain_store.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 9eb2fb6..8028f7d 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -331,9 +331,6 @@ static int move_object_to_stale_dir(uint64_t oid)
 {
 	char path[PATH_MAX], stale_path[PATH_MAX];
 
-	if (!oid_stale(oid))
-		return SD_RES_SUCCESS;
-
 	get_obj_path(oid, path);
 	get_stale_obj_path(oid, stale_path);
 
@@ -346,12 +343,20 @@ static int move_object_to_stale_dir(uint64_t oid)
 	return SD_RES_SUCCESS;
 }
 
+static int check_stale_objects(uint64_t oid)
+{
+	if (oid_stale(oid))
+		return move_object_to_stale_dir(oid);
+
+	return SD_RES_SUCCESS;
+}
+
 int default_end_recover(uint32_t old_epoch, struct vnode_info *old_vnode_info)
 {
 	if (old_epoch == 0)
 		return SD_RES_SUCCESS;
 
-	return for_each_object_in_wd(move_object_to_stale_dir);
+	return for_each_object_in_wd(check_stale_objects);
 }
 
 int default_format(char *name)
@@ -394,7 +399,7 @@ int default_remove_object(uint64_t oid)
 
 int default_purge_obj(void)
 {
-	return for_each_object_in_wd(default_remove_object);
+	return for_each_object_in_wd(move_object_to_stale_dir);
 }
 
 struct store_driver plain_store = {
-- 
1.7.2.5




More information about the sheepdog mailing list