[sheepdog] [PATCH v2 3/6] sheep: use rintf() to get the vnode calc right
Liu Yuan
namei.unix at gmail.com
Mon Aug 13 13:25:36 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/Makefile.am | 2 +-
sheep/group.c | 3 ++-
tests/011.out | 6 +++---
3 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/sheep/Makefile.am b/sheep/Makefile.am
index 16c79f0..fe15d94 100644
--- a/sheep/Makefile.am
+++ b/sheep/Makefile.am
@@ -44,7 +44,7 @@ if BUILD_TRACE
sheep_SOURCES += trace/trace.c trace/mcount.S trace/stabs.c trace/graph.c
endif
-sheep_LDADD = ../lib/libsheepdog.a -lpthread \
+sheep_LDADD = ../lib/libsheepdog.a -lpthread -lm\
$(libcpg_LIBS) $(libcfg_LIBS) $(libacrd_LIBS) $(LIBS)
sheep_DEPENDENCIES = ../lib/libsheepdog.a
diff --git a/sheep/group.c b/sheep/group.c
index 05ffb3e..3f5a8fb 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -17,6 +17,7 @@
#include <sys/time.h>
#include <sys/epoll.h>
#include <urcu/uatomic.h>
+#include <math.h>
#include "sheepdog_proto.h"
#include "sheep_priv.h"
@@ -805,7 +806,7 @@ void recalculate_vnodes(struct sd_node *nodes, int nr_nodes)
for (i = 0; i < nr_nodes; i++) {
factor = (float)nodes[i].space / (float)avg_size;
- nodes[i].nr_vnodes = SD_DEFAULT_VNODES * factor;
+ nodes[i].nr_vnodes = rintf(SD_DEFAULT_VNODES * factor);
dprintf("node %d has %d vnodes, free space %" PRIu64 "\n",
nodes[i].nid.port, nodes[i].nr_vnodes, nodes[i].space);
}
diff --git a/tests/011.out b/tests/011.out
index 2ecd3d7..ce9018c 100644
--- a/tests/011.out
+++ b/tests/011.out
@@ -2,13 +2,13 @@ QA output created by 011
check the number of vnodes
M Id Host:Port V-Nodes Zone
- 0 127.0.0.1:7000 27 0
-- 1 127.0.0.1:7001 54 1
+- 1 127.0.0.1:7001 55 1
- 2 127.0.0.1:7002 110 2
M Id Host:Port V-Nodes Zone
- 0 127.0.0.1:7000 27 0
-- 1 127.0.0.1:7001 54 1
+- 1 127.0.0.1:7001 55 1
- 2 127.0.0.1:7002 110 2
M Id Host:Port V-Nodes Zone
- 0 127.0.0.1:7000 27 0
-- 1 127.0.0.1:7001 54 1
+- 1 127.0.0.1:7001 55 1
- 2 127.0.0.1:7002 110 2
--
1.7.10.2
More information about the sheepdog
mailing list