[sheepdog] [PATCH v5 7/8] sheep: remove some unused copies related functions

levin li levin108 at gmail.com
Wed Aug 22 10:55:18 CEST 2012


From: levin li <xingke.lwp at taobao.com>


Signed-off-by: levin li <xingke.lwp at taobao.com>
---
 sheep/group.c |   36 +++++++++++-------------------------
 sheep/ops.c   |    3 +--
 2 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index e935218..c02b1fe 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -91,20 +91,27 @@ static int get_zones_nr_from(struct sd_node *nodes, int nr_nodes)
 
 bool have_enough_zones(void)
 {
+	int max_copies;
+
 	if (sys->flags & SD_FLAG_NOHALT)
 		return true;
 
 	if (!current_vnode_info)
 		return false;
 
-	dprintf("flags %d, nr_zones %d, copies %d\n",
-		sys->flags, current_vnode_info->nr_zones, sys->nr_copies);
+	max_copies = get_max_copy_number();
+
+	dprintf("flags %d, nr_zones %d, min copies %d\n",
+		sys->flags, current_vnode_info->nr_zones, max_copies);
+
+	if (!current_vnode_info->nr_zones)
+		return false;
 
 	if (sys->flags & SD_FLAG_QUORUM) {
-		if (current_vnode_info->nr_zones > (sys->nr_copies/2))
+		if (current_vnode_info->nr_zones > (max_copies/2))
 			return true;
 	} else {
-		if (current_vnode_info->nr_zones >= sys->nr_copies)
+		if (current_vnode_info->nr_zones >= max_copies)
 			return true;
 	}
 	return false;
@@ -121,18 +128,6 @@ static int get_node_idx(struct vnode_info *vnode_info, struct sd_node *ent)
 }
 
 /*
- * If we have less zones available than the desired redundancy we have to do
- * with nr_zones copies, sorry.
- *
- * Note that you generally want to use get_nr_copies below, as it uses the
- * current vnode state snapshot instead of global data.
- */
-int get_max_nr_copies_from(struct sd_node *nodes, int nr_nodes)
-{
-	return min((int)sys->nr_copies, get_zones_nr_from(nodes, nr_nodes));
-}
-
-/*
  * Grab an additional reference to the passed in vnode info.
  *
  * The caller must already hold a reference to vnode_info, this function must
@@ -244,15 +239,6 @@ int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp,
 }
 
 /*
- * If we have less zones available than the desired redundancy we have to do
- * with nr_zones copies, sorry.
- */
-int get_nr_copies(struct vnode_info *vnode_info)
-{
-	return min(vnode_info->nr_zones, (int)sys->nr_copies);
-}
-
-/*
  * Indicator if a cluster operation is currently running.
  */
 static bool cluster_op_running = false;
diff --git a/sheep/ops.c b/sheep/ops.c
index 0526fb8..59c1b9d 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -410,7 +410,7 @@ static int local_stat_cluster(struct request *req)
 			log->nr_nodes = epoch_log_read_remote(epoch, log->nodes,
 							      sizeof(log->nodes));
 
-		log->nr_copies = get_max_nr_copies_from(log->nodes, log->nr_nodes);
+		log->nr_copies = sys->nr_copies;
 
 		rsp->data_length += sizeof(*log);
 		/* FIXME: this hack would require sizeof(time_t) < sizeof(log->nodes[0]) */
@@ -754,7 +754,6 @@ int peer_read_obj(struct request *req)
 		goto out;
 
 	rsp->data_length = hdr->data_length;
-	rsp->obj.copies = sys->nr_copies;
 out:
 	return ret;
 }
-- 
1.7.1




More information about the sheepdog mailing list