[Sheepdog] [PATCH 6/6] remove unnecessary sd_node_list access

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Fri Apr 9 09:10:45 CEST 2010


Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 collie/collie.h |    3 +--
 collie/group.c  |   36 ++++++++++++++++++------------------
 collie/store.c  |    4 ++--
 collie/vdi.c    |   10 +++++-----
 4 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/collie/collie.h b/collie/collie.h
index b183315..1d066ad 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -94,8 +94,7 @@ int lookup_vdi(char *data, int data_len, uint64_t *oid, uint32_t snapid);
 
 int read_vdis(char *data, int len, unsigned int *rsp_len);
 
-int build_node_list(struct list_head *node_list,
-		    struct sheepdog_node_list_entry *entries);
+int get_ordered_sd_node_list(struct sheepdog_node_list_entry *entries);
 
 int create_cluster(int port);
 
diff --git a/collie/group.c b/collie/group.c
index e4f78da..c71ec0a 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -144,7 +144,24 @@ static int get_node_idx(struct sheepdog_node_list_entry *ent,
 	return ent - entries;
 }
 
-static int get_ordered_sd_node_list(struct sheepdog_node_list_entry *entries)
+static int build_node_list(struct list_head *node_list,
+			   struct sheepdog_node_list_entry *entries)
+{
+	struct node *node;
+	int nr = 0;
+
+	list_for_each_entry(node, node_list, list) {
+		if (entries)
+			memcpy(entries + nr, &node->ent, sizeof(*entries));
+		nr++;
+	}
+	if (entries)
+		qsort(entries, nr, sizeof(*entries), node_cmp);
+
+	return nr;
+}
+
+int get_ordered_sd_node_list(struct sheepdog_node_list_entry *entries)
 {
 	return build_node_list(&sys->sd_node_list, entries);
 }
@@ -1040,23 +1057,6 @@ err:
 		free(w->joined_list);
 }
 
-int build_node_list(struct list_head *node_list,
-		    struct sheepdog_node_list_entry *entries)
-{
-	struct node *node;
-	int nr = 0;
-
-	list_for_each_entry(node, node_list, list) {
-		if (entries)
-			memcpy(entries + nr, &node->ent, sizeof(*entries));
-		nr++;
-	}
-	if (entries)
-		qsort(entries, nr, sizeof(*entries), node_cmp);
-
-	return nr;
-}
-
 static void set_addr(unsigned int nodeid, int port)
 {
 	int ret, nr;
diff --git a/collie/store.c b/collie/store.c
index 7bb0f48..339dc54 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -220,7 +220,7 @@ static int read_from_one(uint64_t oid,
 
 	e = zalloc(SD_MAX_NODES * sizeof(struct sheepdog_node_list_entry));
 again:
-	nr = build_node_list(&sys->sd_node_list, e);
+	nr = get_ordered_sd_node_list(e);
 
 	for (i = 0; i < nr; i++) {
 		n = obj_to_sheep(e, nr, oid, i);
@@ -314,7 +314,7 @@ static int forward_obj_req(struct request *req, char *buf)
 
 	e = zalloc(SD_MAX_NODES * sizeof(struct sheepdog_node_list_entry));
 again:
-	nr = build_node_list(&sys->sd_node_list, e);
+	nr = get_ordered_sd_node_list(e);
 
 	copies = hdr->copies;
 
diff --git a/collie/vdi.c b/collie/vdi.c
index ce37c8e..7a87760 100644
--- a/collie/vdi.c
+++ b/collie/vdi.c
@@ -29,7 +29,7 @@ static int create_vdi_obj(char *name, uint64_t new_oid, uint64_t size,
 	int ret, nr_nodes;
 	unsigned long block_size = SD_DATA_OBJ_SIZE;
 
-	nr_nodes = build_node_list(&sys->sd_node_list, entries);
+	nr_nodes = get_ordered_sd_node_list(entries);
 
 	if (base_oid) {
 		ret = read_object(entries, nr_nodes, sys->epoch,
@@ -127,7 +127,7 @@ static int find_first_vdi(unsigned long start, unsigned long end,
 	int nr_nodes, nr_reqs;
 	int ret;
 
-	nr_nodes = build_node_list(&sys->sd_node_list, entries);
+	nr_nodes = get_ordered_sd_node_list(entries);
 
 	nr_reqs = sys->nr_sobjs;
 	if (nr_reqs > nr_nodes)
@@ -291,7 +291,7 @@ int del_vdi(char *data, int data_len, uint32_t snapid)
 	if (ret != SD_RES_SUCCESS)
 		return ret;
 
-	nr_nodes = build_node_list(&sys->sd_node_list, entries);
+	nr_nodes = get_ordered_sd_node_list(entries);
 	nr_reqs = sys->nr_sobjs;
 	if (nr_reqs > nr_nodes)
 		nr_reqs = nr_nodes;
@@ -354,7 +354,7 @@ static void delete_one(struct work *work, int idx)
 
 	eprintf("%d %d, %16lx\n", dw->done, dw->count, vdi_oid);
 
-	nr_nodes = build_node_list(&sys->sd_node_list, entries);
+	nr_nodes = get_ordered_sd_node_list(entries);
 
 	ret = read_object(entries, nr_nodes, sys->epoch,
 			  vdi_oid, (void *)&inode, sizeof(inode), 0, sys->nr_sobjs);
@@ -471,7 +471,7 @@ static void __start_deletion(struct work *work, int idx)
 	int nr_nodes, ret;
 	uint64_t root_oid;
 
-	nr_nodes = build_node_list(&sys->sd_node_list, entries);
+	nr_nodes = get_ordered_sd_node_list(entries);
 
 	root_oid = get_vdi_root(entries, nr_nodes, dw->oid);
 	if (!root_oid)
-- 
1.7.0




More information about the sheepdog mailing list