[sheepdog] [PATCH 2/2] mark the functions static as much as possible

Liu Yuan namei.unix at gmail.com
Sun Sep 1 12:11:20 CEST 2013


These functions are found by 'make check-unused' and this patch doesn't try to
deal with default_xxx functions in plain.c and object_tree_print, which are
expected to be called by future users.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 dog/common.c         |   12 ++++++------
 dog/dog.h            |    1 -
 sheep/cluster.h      |    1 -
 sheep/config.c       |   20 +++++++++----------
 sheep/group.c        |   52 +++++++++++++++++++++++++-------------------------
 sheep/object_cache.c |    2 +-
 sheep/ops.c          |    6 +++---
 sheep/sheep_priv.h   |    5 -----
 8 files changed, 46 insertions(+), 53 deletions(-)

diff --git a/dog/common.c b/dog/common.c
index 99a9431..84c91f6 100644
--- a/dog/common.c
+++ b/dog/common.c
@@ -13,12 +13,7 @@
 #include "sha1.h"
 #include "sockfd_cache.h"
 
-char *strnumber(uint64_t size)
-{
-	return strnumber_raw(size, raw_output);
-}
-
-char *strnumber_raw(uint64_t _size, bool raw)
+static char *strnumber_raw(uint64_t _size, bool raw)
 {
 	const char *units[] = {"MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
 	static __thread struct size_str {
@@ -54,6 +49,11 @@ out:
 	return ret;
 }
 
+char *strnumber(uint64_t size)
+{
+	return strnumber_raw(size, raw_output);
+}
+
 int sd_read_object(uint64_t oid, void *data, unsigned int datalen,
 		   uint64_t offset, bool direct)
 {
diff --git a/dog/dog.h b/dog/dog.h
index 27e10c7..f155724 100644
--- a/dog/dog.h
+++ b/dog/dog.h
@@ -62,7 +62,6 @@ extern int sd_nodes_nr, sd_vnodes_nr;
 
 bool is_current(const struct sd_inode *i);
 char *strnumber(uint64_t _size);
-char *strnumber_raw(uint64_t _size, bool raw);
 typedef void (*vdi_parser_func_t)(uint32_t vid, const char *name,
 				  const char *tag, uint32_t snapid,
 				  uint32_t flags,
diff --git a/sheep/cluster.h b/sheep/cluster.h
index a19a4de..37a2bb7 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -174,6 +174,5 @@ void sd_update_node_handler(struct sd_node *);
 bool sd_join_handler(const struct sd_node *joining,
 		     const struct sd_node *nodes, size_t nr_nodes,
 		     void *opaque);
-void recalculate_vnodes(struct sd_node *nodes, int nr_nodes);
 
 #endif
diff --git a/sheep/config.c b/sheep/config.c
index 67198c0..f90321a 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -56,6 +56,16 @@ static void check_tmp_config(void)
 	sd_info("removed temporal config file");
 }
 
+static int get_cluster_config(struct cluster_info *cinfo)
+{
+	cinfo->ctime = config.ctime;
+	cinfo->nr_copies = config.copies;
+	cinfo->flags = config.flags;
+	memcpy(cinfo->store, config.store, sizeof(config.store));
+
+	return SD_RES_SUCCESS;
+}
+
 int init_config_file(void)
 {
 	int fd, ret;
@@ -138,16 +148,6 @@ int set_cluster_config(const struct cluster_info *cinfo)
 	return write_config();
 }
 
-int get_cluster_config(struct cluster_info *cinfo)
-{
-	cinfo->ctime = config.ctime;
-	cinfo->nr_copies = config.copies;
-	cinfo->flags = config.flags;
-	memcpy(cinfo->store, config.store, sizeof(config.store));
-
-	return SD_RES_SUCCESS;
-}
-
 int set_node_space(uint64_t space)
 {
 	config.space = space;
diff --git a/sheep/group.c b/sheep/group.c
index d063fcd..339f792 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -106,6 +106,32 @@ void put_vnode_info(struct vnode_info *vnode_info)
 	}
 }
 
+static void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
+{
+	int i, nr_non_gateway_nodes = 0;
+	uint64_t avg_size = 0;
+	float factor;
+
+	for (i = 0; i < nr_nodes; i++) {
+		if (nodes[i].space) {
+			avg_size += nodes[i].space;
+			nr_non_gateway_nodes++;
+		}
+	}
+
+	if (!nr_non_gateway_nodes)
+		return;
+
+	avg_size /= nr_non_gateway_nodes;
+
+	for (i = 0; i < nr_nodes; i++) {
+		factor = (float)nodes[i].space / (float)avg_size;
+		nodes[i].nr_vnodes = rintf(SD_DEFAULT_VNODES * factor);
+		sd_debug("node %d has %d vnodes, free space %" PRIu64,
+			 nodes[i].nid.port, nodes[i].nr_vnodes, nodes[i].space);
+	}
+}
+
 struct vnode_info *alloc_vnode_info(const struct sd_node *nodes,
 				    size_t nr_nodes)
 {
@@ -595,32 +621,6 @@ void wait_get_vdis_done(void)
 	sd_debug("vdi list ready");
 }
 
-void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
-{
-	int i, nr_non_gateway_nodes = 0;
-	uint64_t avg_size = 0;
-	float factor;
-
-	for (i = 0; i < nr_nodes; i++) {
-		if (nodes[i].space) {
-			avg_size += nodes[i].space;
-			nr_non_gateway_nodes++;
-		}
-	}
-
-	if (!nr_non_gateway_nodes)
-		return;
-
-	avg_size /= nr_non_gateway_nodes;
-
-	for (i = 0; i < nr_nodes; i++) {
-		factor = (float)nodes[i].space / (float)avg_size;
-		nodes[i].nr_vnodes = rintf(SD_DEFAULT_VNODES * factor);
-		sd_debug("node %d has %d vnodes, free space %" PRIu64,
-			 nodes[i].nid.port, nodes[i].nr_vnodes, nodes[i].space);
-	}
-}
-
 static void update_cluster_info(const struct cluster_info *cinfo,
 				const struct sd_node *joined,
 				const struct sd_node *nodes,
diff --git a/sheep/object_cache.c b/sheep/object_cache.c
index 650ab44..bd714f3 100644
--- a/sheep/object_cache.c
+++ b/sheep/object_cache.c
@@ -641,7 +641,7 @@ out:
 	return cache;
 }
 
-void object_cache_try_to_reclaim(int delay)
+static void object_cache_try_to_reclaim(int delay)
 {
 	struct reclaim_work *rw;
 
diff --git a/sheep/ops.c b/sheep/ops.c
index 21e5d39..a69c542 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -887,7 +887,7 @@ static int read_copy_from_replica(struct request *req, uint32_t epoch,
 	return ret;
 }
 
-int peer_remove_obj(struct request *req)
+static int peer_remove_obj(struct request *req)
 {
 	uint64_t oid = req->rq.obj.oid;
 
@@ -939,7 +939,7 @@ static int do_create_and_write_obj(struct siocb *iocb, struct sd_req *hdr,
 	return sd_store->create_and_write(hdr->obj.oid, iocb);
 }
 
-int peer_write_obj(struct request *req)
+static int peer_write_obj(struct request *req)
 {
 	struct sd_req *hdr = &req->rq;
 	struct siocb iocb = { };
@@ -953,7 +953,7 @@ int peer_write_obj(struct request *req)
 	return sd_store->write(oid, &iocb);
 }
 
-int peer_create_and_write_obj(struct request *req)
+static int peer_create_and_write_obj(struct request *req)
 {
 	struct sd_req *hdr = &req->rq;
 	struct sd_req cow_hdr;
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 9045112..2ace438 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -324,7 +324,6 @@ int inc_and_log_epoch(void);
 
 extern char *config_path;
 int set_cluster_config(const struct cluster_info *cinfo);
-int get_cluster_config(struct cluster_info *cinfo);
 int set_node_space(uint64_t space);
 int get_node_space(uint64_t *space);
 bool is_cluster_formatted(void);
@@ -401,9 +400,6 @@ int gateway_remove_obj(struct request *req);
 
 /* backend store */
 int peer_read_obj(struct request *req);
-int peer_write_obj(struct request *req);
-int peer_create_and_write_obj(struct request *req);
-int peer_remove_obj(struct request *req);
 
 /* object_cache */
 
@@ -411,7 +407,6 @@ void object_cache_format(void);
 bool bypass_object_cache(const struct request *req);
 bool object_is_cached(uint64_t oid);
 
-void object_cache_try_to_reclaim(int);
 int object_cache_handle_request(struct request *req);
 int object_cache_write(uint64_t oid, char *data, unsigned int datalen,
 		       uint64_t offset, bool create);
-- 
1.7.9.5




More information about the sheepdog mailing list