Commit 1c084577 authored by Sunil Mushran's avatar Sunil Mushran Committed by Mark Fasheh

ocfs2/dlm: Encapsulate adding and removing of mle from dlm->master_list

This patch encapsulates adding and removing of the mle from the
dlm->master_list. This patch is part of the series of patches that
converts the mle list to a mle hash.
Signed-off-by: default avatarSunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent feb473a6
...@@ -1008,6 +1008,9 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res) ...@@ -1008,6 +1008,9 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res)
DLM_LOCK_RES_MIGRATING)); DLM_LOCK_RES_MIGRATING));
} }
void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle);
void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle);
/* create/destroy slab caches */ /* create/destroy slab caches */
int dlm_init_master_caches(void); int dlm_init_master_caches(void);
void dlm_destroy_master_caches(void); void dlm_destroy_master_caches(void);
......
...@@ -318,6 +318,21 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, ...@@ -318,6 +318,21 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle,
__dlm_mle_attach_hb_events(dlm, mle); __dlm_mle_attach_hb_events(dlm, mle);
} }
void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
{
assert_spin_locked(&dlm->spinlock);
assert_spin_locked(&dlm->master_lock);
if (!list_empty(&mle->list))
list_del_init(&mle->list);
}
void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
{
assert_spin_locked(&dlm->master_lock);
list_add(&mle->list, &dlm->master_list);
}
/* returns 1 if found, 0 if not */ /* returns 1 if found, 0 if not */
static int dlm_find_mle(struct dlm_ctxt *dlm, static int dlm_find_mle(struct dlm_ctxt *dlm,
...@@ -420,8 +435,7 @@ static void dlm_mle_release(struct kref *kref) ...@@ -420,8 +435,7 @@ static void dlm_mle_release(struct kref *kref)
assert_spin_locked(&dlm->master_lock); assert_spin_locked(&dlm->master_lock);
/* remove from list if not already */ /* remove from list if not already */
if (!list_empty(&mle->list)) __dlm_unlink_mle(dlm, mle);
list_del_init(&mle->list);
/* detach the mle from the domain node up/down events */ /* detach the mle from the domain node up/down events */
__dlm_mle_detach_hb_events(dlm, mle); __dlm_mle_detach_hb_events(dlm, mle);
...@@ -843,7 +857,7 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm, ...@@ -843,7 +857,7 @@ struct dlm_lock_resource * dlm_get_lock_resource(struct dlm_ctxt *dlm,
alloc_mle = NULL; alloc_mle = NULL;
dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0); dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0);
set_bit(dlm->node_num, mle->maybe_map); set_bit(dlm->node_num, mle->maybe_map);
list_add(&mle->list, &dlm->master_list); __dlm_insert_mle(dlm, mle);
/* still holding the dlm spinlock, check the recovery map /* still holding the dlm spinlock, check the recovery map
* to see if there are any nodes that still need to be * to see if there are any nodes that still need to be
...@@ -1575,7 +1589,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1575,7 +1589,7 @@ int dlm_master_request_handler(struct o2net_msg *msg, u32 len, void *data,
// "add the block.\n"); // "add the block.\n");
dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, name, namelen); dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, name, namelen);
set_bit(request->node_idx, mle->maybe_map); set_bit(request->node_idx, mle->maybe_map);
list_add(&mle->list, &dlm->master_list); __dlm_insert_mle(dlm, mle);
response = DLM_MASTER_RESP_NO; response = DLM_MASTER_RESP_NO;
} else { } else {
// mlog(0, "mle was found\n"); // mlog(0, "mle was found\n");
...@@ -1967,7 +1981,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data, ...@@ -1967,7 +1981,7 @@ int dlm_assert_master_handler(struct o2net_msg *msg, u32 len, void *data,
assert->node_idx, rr, extra_ref, mle->inuse); assert->node_idx, rr, extra_ref, mle->inuse);
dlm_print_one_mle(mle); dlm_print_one_mle(mle);
} }
list_del_init(&mle->list); __dlm_unlink_mle(dlm, mle);
__dlm_mle_detach_hb_events(dlm, mle); __dlm_mle_detach_hb_events(dlm, mle);
__dlm_put_mle(mle); __dlm_put_mle(mle);
if (extra_ref) { if (extra_ref) {
...@@ -3159,10 +3173,8 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm, ...@@ -3159,10 +3173,8 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm,
tmp->master = master; tmp->master = master;
atomic_set(&tmp->woken, 1); atomic_set(&tmp->woken, 1);
wake_up(&tmp->wq); wake_up(&tmp->wq);
/* remove it from the list so that only one /* remove it so that only one mle will be found */
* mle will be found */ __dlm_unlink_mle(dlm, tmp);
list_del_init(&tmp->list);
/* this was obviously WRONG. mle is uninited here. should be tmp. */
__dlm_mle_detach_hb_events(dlm, tmp); __dlm_mle_detach_hb_events(dlm, tmp);
ret = DLM_MIGRATE_RESPONSE_MASTERY_REF; ret = DLM_MIGRATE_RESPONSE_MASTERY_REF;
mlog(0, "%s:%.*s: master=%u, newmaster=%u, " mlog(0, "%s:%.*s: master=%u, newmaster=%u, "
...@@ -3181,7 +3193,7 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm, ...@@ -3181,7 +3193,7 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm,
mle->master = master; mle->master = master;
/* do this for consistency with other mle types */ /* do this for consistency with other mle types */
set_bit(new_master, mle->maybe_map); set_bit(new_master, mle->maybe_map);
list_add(&mle->list, &dlm->master_list); __dlm_insert_mle(dlm, mle);
return ret; return ret;
} }
...@@ -3264,7 +3276,7 @@ void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node) ...@@ -3264,7 +3276,7 @@ void dlm_clean_master_list(struct dlm_ctxt *dlm, u8 dead_node)
* list_head while in list_for_each_safe */ * list_head while in list_for_each_safe */
__dlm_mle_detach_hb_events(dlm, mle); __dlm_mle_detach_hb_events(dlm, mle);
spin_lock(&mle->spinlock); spin_lock(&mle->spinlock);
list_del_init(&mle->list); __dlm_unlink_mle(dlm, mle);
atomic_set(&mle->woken, 1); atomic_set(&mle->woken, 1);
spin_unlock(&mle->spinlock); spin_unlock(&mle->spinlock);
wake_up(&mle->wq); wake_up(&mle->wq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment