[sheepdog] [PATCH v2 2/2] sheep: operate vnode info between get_vnode_info() and put_vnode_info()
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Mon Jan 6 09:10:47 CET 2014
vnode_info should be obtained by get_vnode_info() and released by
put_vnode_info(). Some part of group.c don't follow the manner. It
doesn't cause a serious problem practically but is not good for coding
convention. This patch does refactoring for this problem.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/group.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 60ff31f..d4e5cc9 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -176,13 +176,15 @@ int local_get_node_list(const struct sd_req *req, struct sd_rsp *rsp,
void *data)
{
int nr_nodes;
- struct vnode_info *cur_vinfo = main_thread_get(current_vnode_info);
+ struct vnode_info *cur_vinfo = get_vnode_info();
if (cur_vinfo) {
nr_nodes = cur_vinfo->nr_nodes;
nodes_to_buffer(&cur_vinfo->nroot, data);
rsp->data_length = nr_nodes * sizeof(struct sd_node);
rsp->node.nr_nodes = nr_nodes;
+
+ put_vnode_info(cur_vinfo);
} else {
rsp->node.nr_nodes = 0;
}
@@ -536,12 +538,14 @@ static void get_vdis_done(struct work *work)
int inc_and_log_epoch(void)
{
- struct vnode_info *cur_vinfo = main_thread_get(current_vnode_info);
+ struct vnode_info *cur_vinfo = get_vnode_info();
if (cur_vinfo) {
/* update cluster info to the latest state */
sys->cinfo.nr_nodes = cur_vinfo->nr_nodes;
nodes_to_buffer(&cur_vinfo->nroot, sys->cinfo.nodes);
+
+ put_vnode_info(cur_vinfo);
} else
sys->cinfo.nr_nodes = 0;
@@ -945,12 +949,14 @@ main_fn void sd_leave_handler(const struct sd_node *left,
static void update_node_size(struct sd_node *node)
{
- struct vnode_info *cur_vinfo = main_thread_get(current_vnode_info);
+ struct vnode_info *cur_vinfo = get_vnode_info();
struct sd_node *n = rb_search(&cur_vinfo->nroot, node, rb, node_cmp);
if (unlikely(!n))
panic("can't find %s", node_to_str(node));
n->space = node->space;
+
+ put_vnode_info(cur_vinfo);
}
static void kick_node_recover(void)
--
1.7.10.4
More information about the sheepdog
mailing list