[sheepdog] [PATCH v6 04/16] sheep: remove farm logic from sheep

Kai Zhang kyle at zelin.io
Tue May 21 12:11:06 CEST 2013


1. sheep/ops.c: remove snapshot operations
2. sheep/store.c: check_path_len() don't need to consider farm
3. sheep/sheep_priv.h: remove snapshot, restore and get_snap_file from struct store_driver

Signed-off-by: Kai Zhang <kyle at zelin.io>
---
 sheep/ops.c        |   62 ----------------------------------------------------
 sheep/sheep_priv.h |    3 --
 sheep/store.c      |    6 +----
 3 files changed, 1 insertions(+), 70 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 9399fd8..ed0d915 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -591,20 +591,6 @@ err:
 	panic("failed in force recovery");
 }
 
-static int cluster_snapshot(const struct sd_req *req, struct sd_rsp *rsp,
-			    void *data)
-{
-	int ret;
-	struct siocb iocb = { 0 };
-
-	if (sd_store->snapshot)
-		ret = sd_store->snapshot(&iocb);
-	else
-		ret = SD_RES_NO_SUPPORT;
-
-	return ret;
-}
-
 static int cluster_cleanup(const struct sd_req *req, struct sd_rsp *rsp,
 				void *data)
 {
@@ -772,33 +758,6 @@ static int local_get_hash(struct request *request)
 				  rsp->hash.digest);
 }
 
-static int cluster_restore(const struct sd_req *req, struct sd_rsp *rsp,
-			   void *data)
-{
-	int ret;
-	struct siocb iocb = { .epoch = req->obj.tgt_epoch };
-
-	if (sd_store->restore)
-		ret = sd_store->restore(&iocb);
-	else
-		ret = SD_RES_NO_SUPPORT;
-	return ret;
-}
-
-static int local_get_snap_file(struct request *req)
-{
-	int ret;
-	struct siocb iocb = { .buf = req->data };
-
-	if (sd_store->get_snap_file) {
-		ret = sd_store->get_snap_file(&iocb);
-		req->rp.data_length = iocb.length;
-	} else
-		ret = SD_RES_NO_SUPPORT;
-
-	return ret;
-}
-
 /* Return SD_RES_INVALID_PARMS to ask client not to send flush req again */
 static int local_flush_vdi(struct request *req)
 {
@@ -1062,20 +1021,6 @@ static struct sd_op_template sd_ops[] = {
 		.process_main = cluster_force_recover_main,
 	},
 
-	[SD_OP_SNAPSHOT] = {
-		.name = "SNAPSHOT",
-		.type = SD_OP_TYPE_CLUSTER,
-		.force = true,
-		.process_main = cluster_snapshot,
-	},
-
-	[SD_OP_RESTORE] = {
-		.name = "RESTORE",
-		.type = SD_OP_TYPE_CLUSTER,
-		.force = true,
-		.process_main = cluster_restore,
-	},
-
 	[SD_OP_CLEANUP] = {
 		.name = "CLEANUP",
 		.type = SD_OP_TYPE_CLUSTER,
@@ -1188,13 +1133,6 @@ static struct sd_op_template sd_ops[] = {
 		.process_work = local_get_epoch,
 	},
 
-	[SD_OP_GET_SNAP_FILE] = {
-		.name = "GET_SNAP_FILE",
-		.type = SD_OP_TYPE_LOCAL,
-		.force = true,
-		.process_work = local_get_snap_file,
-	},
-
 	[SD_OP_FLUSH_VDI] = {
 		.name = "FLUSH_VDI",
 		.type = SD_OP_TYPE_LOCAL,
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index d086aef..ae5249d 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -160,10 +160,7 @@ struct store_driver {
 	int (*update_epoch)(uint32_t epoch);
 	int (*purge_obj)(void);
 	/* Operations for snapshot */
-	int (*snapshot)(const struct siocb *);
 	int (*cleanup)(void);
-	int (*restore)(const struct siocb *);
-	int (*get_snap_file)(struct siocb *);
 };
 
 int default_init(void);
diff --git a/sheep/store.c b/sheep/store.c
index 28e2ab7..226dd58 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -238,14 +238,10 @@ int init_base_path(const char *d)
 	return 0;
 }
 
-/*
- * farm needs extra HEX_LEN + 3 chars to store snapshot objects.
- * HEX_LEN + 3 = '/' + hex(2) + '/' + hex(38) + '\0'
- */
 static inline int check_path_len(const char *path)
 {
 	int len = strlen(path);
-	if (len + HEX_LEN + 3 > PATH_MAX) {
+	if (len > PATH_MAX) {
 		sd_eprintf("insanely long object directory %s", path);
 		return -1;
 	}
-- 
1.7.1





More information about the sheepdog mailing list