[Sheepdog] [PATCH] store: set correct path for farm in store_remove_obj

zituan at taobao.com zituan at taobao.com
Thu Apr 12 11:02:16 CEST 2012


From: Yibin Shen <zituan at taobao.com>


Signed-off-by: Yibin Shen <zituan at taobao.com>
---
 sheep/store.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/sheep/store.c b/sheep/store.c
index 739862c..027443f 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -588,18 +588,23 @@ int store_remove_obj(const struct sd_req *req, struct sd_rsp *rsp, void *data)
 	struct sd_obj_req *hdr = (struct sd_obj_req *)req;
 	uint32_t epoch = hdr->epoch;
 	char path[1024];
+	struct strbuf store_dir = STRBUF_INIT;
+	int ret = SD_RES_SUCCESS;
+	get_store_dir(&store_dir, epoch);
 
-	snprintf(path, sizeof(path), "%s%08u/%016" PRIx64, obj_path,
-		 epoch, hdr->oid);
+	snprintf(path, sizeof(path), "%s%016" PRIx64, store_dir.buf, hdr->oid);
 
 	if (unlink(path) < 0) {
-		if (errno == ENOENT)
-			return SD_RES_NO_OBJ;
+		if (errno == ENOENT) {
+			ret = SD_RES_NO_OBJ;
+			goto out;
+		}
 		eprintf("%m\n");
-		return SD_RES_EIO;
+		ret =  SD_RES_EIO;
 	}
-
-	return SD_RES_SUCCESS;
+ out:
+	strbuf_release(&store_dir);
+	return ret;
 }
 
 int store_read_obj(const struct sd_req *req, struct sd_rsp *rsp, void *data)
-- 
1.7.7.3




More information about the sheepdog mailing list