[sheepdog] [PATCH 2/2] sheep: add a description about treatment of current_vnode_info()
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Jan 9 03:48:00 CET 2014
Some part of group.c use main_thread_get() instead of
get_vnode_info(). It is a little bit tricky so this patch adds
comments as a description.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/group.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/sheep/group.c b/sheep/group.c
index e37b198..ad64a8d 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -652,6 +652,12 @@ static void update_cluster_info(const struct cluster_info *cinfo,
sockfd_cache_add_group(nroot);
sockfd_cache_add(&joined->nid);
+ /*
+ * We can use main_thread_get() to obtain current_vnode_info. The
+ * reference count of old_vnode_info is decremented at the last of this
+ * function, but it doesn't cause an illegal release. The counter part
+ * of this reference decrement is alloc_vnode_info().
+ */
old_vnode_info = main_thread_get(current_vnode_info);
main_thread_set(current_vnode_info, alloc_vnode_info(nroot));
@@ -932,6 +938,10 @@ main_fn void sd_leave_handler(const struct sd_node *left,
/* Mark leave node as gateway only node */
sys->this_node.nr_vnodes = 0;
+ /*
+ * Using main_thread_get() instead of get_vnode_info() is allowed
+ * because of the same reason of update_cluster_info()
+ */
old_vnode_info = main_thread_get(current_vnode_info);
main_thread_set(current_vnode_info, alloc_vnode_info(nroot));
if (sys->cinfo.status == SD_STATUS_OK) {
@@ -961,6 +971,10 @@ static void update_node_size(struct sd_node *node)
static void kick_node_recover(void)
{
+ /*
+ * Using main_thread_get() instead of get_vnode_info() is allowed
+ * because of the same reason of update_cluster_info()
+ */
struct vnode_info *old = main_thread_get(current_vnode_info);
int ret;
--
1.7.10.4
More information about the sheepdog
mailing list