[sheepdog] [PATCH 4/4] sheep: handle node leave event for updating inode object shared state
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Aug 5 06:53:53 CEST 2014
When a node leaves from sheepdog cluster, it should be removed from a
list of participants of shared VDI.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/group.c | 2 ++
sheep/sheep_priv.h | 1 +
sheep/vdi.c | 23 +++++++++++++++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 39309eb..cdd44d4 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1159,6 +1159,8 @@ main_fn void sd_leave_handler(const struct sd_node *left,
put_vnode_info(old_vnode_info);
sockfd_cache_del_node(&left->nid);
+
+ remove_node_from_participants(&left->nid);
}
static void update_node_size(struct sd_node *node)
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 94a3a4f..26465ab 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -352,6 +352,7 @@ void validate_myself(uint32_t vid);
void invalidate_other_nodes(uint32_t vid);
int inode_coherence_update(uint32_t vid, bool validate,
const struct node_id *sender);
+void remove_node_from_participants(const struct node_id *left);
extern int ec_max_data_strip;
diff --git a/sheep/vdi.c b/sheep/vdi.c
index b8212d9..8872f91 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -386,7 +386,7 @@ static bool add_new_participant(struct vdi_state_entry *entry,
}
static void del_participant(struct vdi_state_entry *entry,
- const struct node_id *owner)
+ const struct node_id *owner, bool err_msg)
{
int idx = -1;
@@ -400,7 +400,10 @@ static void del_participant(struct vdi_state_entry *entry,
}
if (idx == -1) {
- sd_err("unknown participants: %s", node_id_to_str(owner));
+ if (err_msg)
+ sd_err("unknown participants: %s",
+ node_id_to_str(owner));
+
return;
}
@@ -515,7 +518,7 @@ bool vdi_unlock(uint32_t vid, const struct node_id *owner, int type)
sd_alert("leaving from unlocked VDI: %"PRIx32, vid);
break;
case LOCK_STATE_SHARED:
- del_participant(entry, owner);
+ del_participant(entry, owner, true);
ret = true;
break;
case LOCK_STATE_LOCKED:
@@ -572,7 +575,7 @@ static void apply_vdi_lock_state_shared(uint32_t vid, bool lock,
if (lock)
add_new_participant(entry, locker);
else
- del_participant(entry, locker);
+ del_participant(entry, locker, true);
out:
sd_rw_unlock(&vdi_state_lock);
@@ -813,6 +816,18 @@ main_fn int inode_coherence_update(uint32_t vid, bool validate,
return SD_RES_SUCCESS;
}
+main_fn void remove_node_from_participants(const struct node_id *left)
+{
+ struct vdi_state_entry *entry;
+
+ sd_write_lock(&vdi_state_lock);
+ rb_for_each_entry(entry, &vdi_state_root, node) {
+ del_participant(entry, left, false);
+ }
+ sd_rw_unlock(&vdi_state_lock);
+
+}
+
static struct sd_inode *alloc_inode(const struct vdi_iocb *iocb,
uint32_t new_snapid, uint32_t new_vid,
uint32_t *data_vdi_id,
--
1.8.3.2
More information about the sheepdog
mailing list