diff options
author | Sunil Mushran <sunil.mushran@oracle.com> | 2009-02-26 18:00:37 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-04-03 14:39:18 -0400 |
commit | 1c0845773ad9f4875603b752235aea8aa04565f3 (patch) | |
tree | 35554daeb156154197c664d6dd5a52552eb292e4 /fs | |
parent | feb473a6e8bd19297d0f3bb377b25055c0228c0a (diff) |
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: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ocfs2/dlm/dlmcommon.h | 3 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmmaster.c | 34 |
2 files changed, 26 insertions, 11 deletions
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index bb53714813ab..261e26501e57 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -1008,6 +1008,9 @@ static inline void __dlm_wait_on_lockres(struct dlm_lock_resource *res) | |||
1008 | DLM_LOCK_RES_MIGRATING)); | 1008 | DLM_LOCK_RES_MIGRATING)); |
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle); | ||
1012 | void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle); | ||
1013 | |||
1011 | /* create/destroy slab caches */ | 1014 | /* create/destroy slab caches */ |
1012 | int dlm_init_master_caches(void); | 1015 | int dlm_init_master_caches(void); |
1013 | void dlm_destroy_master_caches(void); | 1016 | void dlm_destroy_master_caches(void); |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index 0a2813947853..0aa4b043f4de 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -318,6 +318,21 @@ static void dlm_init_mle(struct dlm_master_list_entry *mle, | |||
318 | __dlm_mle_attach_hb_events(dlm, mle); | 318 | __dlm_mle_attach_hb_events(dlm, mle); |
319 | } | 319 | } |
320 | 320 | ||
321 | void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) | ||
322 | { | ||
323 | assert_spin_locked(&dlm->spinlock); | ||
324 | assert_spin_locked(&dlm->master_lock); | ||
325 | |||
326 | if (!list_empty(&mle->list)) | ||
327 | list_del_init(&mle->list); | ||
328 | } | ||
329 | |||
330 | void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle) | ||
331 | { | ||
332 | assert_spin_locked(&dlm->master_lock); | ||
333 | |||
334 | list_add(&mle->list, &dlm->master_list); | ||
335 | } | ||
321 | 336 | ||
322 | /* returns 1 if found, 0 if not */ | 337 | /* returns 1 if found, 0 if not */ |
323 | static int dlm_find_mle(struct dlm_ctxt *dlm, | 338 | static int dlm_find_mle(struct dlm_ctxt *dlm, |
@@ -420,8 +435,7 @@ static void dlm_mle_release(struct kref *kref) | |||
420 | assert_spin_locked(&dlm->master_lock); | 435 | assert_spin_locked(&dlm->master_lock); |
421 | 436 | ||
422 | /* remove from list if not already */ | 437 | /* remove from list if not already */ |
423 | if (!list_empty(&mle->list)) | 438 | __dlm_unlink_mle(dlm, mle); |
424 | list_del_init(&mle->list); | ||
425 | 439 | ||
426 | /* detach the mle from the domain node up/down events */ | 440 | /* detach the mle from the domain node up/down events */ |
427 | __dlm_mle_detach_hb_events(dlm, mle); | 441 | __dlm_mle_detach_hb_events(dlm, mle); |
@@ -843,7 +857,7 @@ lookup: | |||
843 | alloc_mle = NULL; | 857 | alloc_mle = NULL; |
844 | dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0); | 858 | dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0); |
845 | set_bit(dlm->node_num, mle->maybe_map); | 859 | set_bit(dlm->node_num, mle->maybe_map); |
846 | list_add(&mle->list, &dlm->master_list); | 860 | __dlm_insert_mle(dlm, mle); |
847 | 861 | ||
848 | /* still holding the dlm spinlock, check the recovery map | 862 | /* still holding the dlm spinlock, check the recovery map |
849 | * to see if there are any nodes that still need to be | 863 | * to see if there are any nodes that still need to be |
@@ -1575,7 +1589,7 @@ way_up_top: | |||
1575 | // "add the block.\n"); | 1589 | // "add the block.\n"); |
1576 | dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, name, namelen); | 1590 | dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, name, namelen); |
1577 | set_bit(request->node_idx, mle->maybe_map); | 1591 | set_bit(request->node_idx, mle->maybe_map); |
1578 | list_add(&mle->list, &dlm->master_list); | 1592 | __dlm_insert_mle(dlm, mle); |
1579 | response = DLM_MASTER_RESP_NO; | 1593 | response = DLM_MASTER_RESP_NO; |
1580 | } else { | 1594 | } else { |
1581 | // mlog(0, "mle was found\n"); | 1595 | // mlog(0, "mle was found\n"); |
@@ -1967,7 +1981,7 @@ ok: | |||
1967 | assert->node_idx, rr, extra_ref, mle->inuse); | 1981 | assert->node_idx, rr, extra_ref, mle->inuse); |
1968 | dlm_print_one_mle(mle); | 1982 | dlm_print_one_mle(mle); |
1969 | } | 1983 | } |
1970 | list_del_init(&mle->list); | 1984 | __dlm_unlink_mle(dlm, mle); |
1971 | __dlm_mle_detach_hb_events(dlm, mle); | 1985 | __dlm_mle_detach_hb_events(dlm, mle); |
1972 | __dlm_put_mle(mle); | 1986 | __dlm_put_mle(mle); |
1973 | if (extra_ref) { | 1987 | if (extra_ref) { |
@@ -3159,10 +3173,8 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm, | |||
3159 | tmp->master = master; | 3173 | tmp->master = master; |
3160 | atomic_set(&tmp->woken, 1); | 3174 | atomic_set(&tmp->woken, 1); |
3161 | wake_up(&tmp->wq); | 3175 | wake_up(&tmp->wq); |
3162 | /* remove it from the list so that only one | 3176 | /* remove it so that only one mle will be found */ |
3163 | * mle will be found */ | 3177 | __dlm_unlink_mle(dlm, tmp); |
3164 | list_del_init(&tmp->list); | ||
3165 | /* this was obviously WRONG. mle is uninited here. should be tmp. */ | ||
3166 | __dlm_mle_detach_hb_events(dlm, tmp); | 3178 | __dlm_mle_detach_hb_events(dlm, tmp); |
3167 | ret = DLM_MIGRATE_RESPONSE_MASTERY_REF; | 3179 | ret = DLM_MIGRATE_RESPONSE_MASTERY_REF; |
3168 | mlog(0, "%s:%.*s: master=%u, newmaster=%u, " | 3180 | mlog(0, "%s:%.*s: master=%u, newmaster=%u, " |
@@ -3181,7 +3193,7 @@ static int dlm_add_migration_mle(struct dlm_ctxt *dlm, | |||
3181 | mle->master = master; | 3193 | mle->master = master; |
3182 | /* do this for consistency with other mle types */ | 3194 | /* do this for consistency with other mle types */ |
3183 | set_bit(new_master, mle->maybe_map); | 3195 | set_bit(new_master, mle->maybe_map); |
3184 | list_add(&mle->list, &dlm->master_list); | 3196 | __dlm_insert_mle(dlm, mle); |
3185 | 3197 | ||
3186 | return ret; | 3198 | return ret; |
3187 | } | 3199 | } |
@@ -3264,7 +3276,7 @@ top: | |||
3264 | * list_head while in list_for_each_safe */ | 3276 | * list_head while in list_for_each_safe */ |
3265 | __dlm_mle_detach_hb_events(dlm, mle); | 3277 | __dlm_mle_detach_hb_events(dlm, mle); |
3266 | spin_lock(&mle->spinlock); | 3278 | spin_lock(&mle->spinlock); |
3267 | list_del_init(&mle->list); | 3279 | __dlm_unlink_mle(dlm, mle); |
3268 | atomic_set(&mle->woken, 1); | 3280 | atomic_set(&mle->woken, 1); |
3269 | spin_unlock(&mle->spinlock); | 3281 | spin_unlock(&mle->spinlock); |
3270 | wake_up(&mle->wq); | 3282 | wake_up(&mle->wq); |