[sheepdog] [PATCH] plain_store: remove tmp objects in for_each_object_in_wd

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Sun Aug 26 10:49:56 CEST 2012


Currently, sheep could call a callback function against tmp objects.
This fixes the problem.

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

diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 8888521..0129d54 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -53,6 +53,7 @@ int for_each_object_in_wd(int (*func)(uint64_t oid))
 	struct dirent *d;
 	uint64_t oid;
 	int ret = SD_RES_SUCCESS;
+	char path[PATH_MAX];
 
 	dir = opendir(obj_path);
 	if (!dir)
@@ -66,6 +67,15 @@ int for_each_object_in_wd(int (*func)(uint64_t oid))
 		if (oid == 0 || oid == ULLONG_MAX)
 			continue;
 
+		/* remove object if it is temporary one */
+		if (strlen(d->d_name) == 20 &&
+		    strcmp(d->d_name + 16, ".tmp") == 0) {
+			get_tmp_obj_path(oid, path);
+			dprintf("remove tmp object %s\n", path);
+			unlink(path);
+			continue;
+		}
+
 		ret = func(oid);
 		if (ret != SD_RES_SUCCESS)
 			break;
-- 
1.7.2.5




More information about the sheepdog mailing list