Lines Matching refs:mle
56 struct dlm_master_list_entry *mle,
60 struct dlm_master_list_entry *mle,
71 struct dlm_master_list_entry *mle,
75 if (dlm != mle->dlm)
78 if (namelen != mle->mnamelen ||
79 memcmp(name, mle->mname, namelen) != 0)
90 static void dlm_init_mle(struct dlm_master_list_entry *mle,
96 static void dlm_put_mle(struct dlm_master_list_entry *mle);
97 static void __dlm_put_mle(struct dlm_master_list_entry *mle);
99 struct dlm_master_list_entry **mle,
103 struct dlm_master_list_entry *mle, int to);
108 struct dlm_master_list_entry *mle,
112 struct dlm_master_list_entry *mle,
116 struct dlm_master_list_entry *mle,
167 * dlm's established heartbeat callbacks. the mle is attached
170 * by the mle. the mle needs to be detached from the
172 * longer useful to the mle, and before the mle is freed.
175 * the mle once an "answer" regarding the lock master has been
179 struct dlm_master_list_entry *mle)
183 list_add_tail(&mle->hb_events, &dlm->mle_hb_events);
188 struct dlm_master_list_entry *mle)
190 if (!list_empty(&mle->hb_events))
191 list_del_init(&mle->hb_events);
196 struct dlm_master_list_entry *mle)
199 __dlm_mle_detach_hb_events(dlm, mle);
203 static void dlm_get_mle_inuse(struct dlm_master_list_entry *mle)
206 dlm = mle->dlm;
210 mle->inuse++;
211 kref_get(&mle->mle_refs);
214 static void dlm_put_mle_inuse(struct dlm_master_list_entry *mle)
217 dlm = mle->dlm;
221 mle->inuse--;
222 __dlm_put_mle(mle);
229 static void __dlm_put_mle(struct dlm_master_list_entry *mle)
232 dlm = mle->dlm;
236 if (!atomic_read(&mle->mle_refs.refcount)) {
239 mlog(ML_ERROR, "bad mle: %p\n", mle);
240 dlm_print_one_mle(mle);
243 kref_put(&mle->mle_refs, dlm_mle_release);
248 static void dlm_put_mle(struct dlm_master_list_entry *mle)
251 dlm = mle->dlm;
255 __dlm_put_mle(mle);
260 static inline void dlm_get_mle(struct dlm_master_list_entry *mle)
262 kref_get(&mle->mle_refs);
265 static void dlm_init_mle(struct dlm_master_list_entry *mle,
274 mle->dlm = dlm;
275 mle->type = type;
276 INIT_HLIST_NODE(&mle->master_hash_node);
277 INIT_LIST_HEAD(&mle->hb_events);
278 memset(mle->maybe_map, 0, sizeof(mle->maybe_map));
279 spin_lock_init(&mle->spinlock);
280 init_waitqueue_head(&mle->wq);
281 atomic_set(&mle->woken, 0);
282 kref_init(&mle->mle_refs);
283 memset(mle->response_map, 0, sizeof(mle->response_map));
284 mle->master = O2NM_MAX_NODES;
285 mle->new_master = O2NM_MAX_NODES;
286 mle->inuse = 0;
288 BUG_ON(mle->type != DLM_MLE_BLOCK &&
289 mle->type != DLM_MLE_MASTER &&
290 mle->type != DLM_MLE_MIGRATION);
292 if (mle->type == DLM_MLE_MASTER) {
294 mle->mleres = res;
295 memcpy(mle->mname, res->lockname.name, res->lockname.len);
296 mle->mnamelen = res->lockname.len;
297 mle->mnamehash = res->lockname.hash;
300 mle->mleres = NULL;
301 memcpy(mle->mname, name, namelen);
302 mle->mnamelen = namelen;
303 mle->mnamehash = dlm_lockid_hash(name, namelen);
306 atomic_inc(&dlm->mle_tot_count[mle->type]);
307 atomic_inc(&dlm->mle_cur_count[mle->type]);
310 memcpy(mle->node_map, dlm->domain_map, sizeof(mle->node_map));
311 memcpy(mle->vote_map, dlm->domain_map, sizeof(mle->vote_map));
312 clear_bit(dlm->node_num, mle->vote_map);
313 clear_bit(dlm->node_num, mle->node_map);
315 /* attach the mle to the domain node up/down events */
316 __dlm_mle_attach_hb_events(dlm, mle);
319 void __dlm_unlink_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
324 if (!hlist_unhashed(&mle->master_hash_node))
325 hlist_del_init(&mle->master_hash_node);
328 void __dlm_insert_mle(struct dlm_ctxt *dlm, struct dlm_master_list_entry *mle)
334 bucket = dlm_master_hash(dlm, mle->mnamehash);
335 hlist_add_head(&mle->master_hash_node, bucket);
340 struct dlm_master_list_entry **mle,
358 *mle = tmpmle;
366 struct dlm_master_list_entry *mle;
370 list_for_each_entry(mle, &dlm->mle_hb_events, hb_events) {
372 dlm_mle_node_up(dlm, mle, NULL, idx);
374 dlm_mle_node_down(dlm, mle, NULL, idx);
379 struct dlm_master_list_entry *mle,
382 spin_lock(&mle->spinlock);
384 if (!test_bit(idx, mle->node_map))
387 clear_bit(idx, mle->node_map);
389 spin_unlock(&mle->spinlock);
393 struct dlm_master_list_entry *mle,
396 spin_lock(&mle->spinlock);
398 if (test_bit(idx, mle->node_map))
401 set_bit(idx, mle->node_map);
403 spin_unlock(&mle->spinlock);
426 struct dlm_master_list_entry *mle;
431 mle = container_of(kref, struct dlm_master_list_entry, mle_refs);
432 dlm = mle->dlm;
437 mlog(0, "Releasing mle for %.*s, type %d\n", mle->mnamelen, mle->mname,
438 mle->type);
441 __dlm_unlink_mle(dlm, mle);
443 /* detach the mle from the domain node up/down events */
444 __dlm_mle_detach_hb_events(dlm, mle);
446 atomic_dec(&dlm->mle_cur_count[mle->type]);
450 kmem_cache_free(dlm_mle_cache, mle);
694 struct dlm_master_list_entry *mle = NULL;
782 blocked = dlm_find_mle(dlm, &mle, (char *)lockid, namelen);
785 if (mle->type == DLM_MLE_MASTER) {
789 mig = (mle->type == DLM_MLE_MIGRATION);
792 * of the MIGRATION mle: either the migrate finished or
793 * one of the nodes died and the mle was cleaned up.
796 * for us in the refmap. detach the mle and drop it.
798 if (mig || mle->master != O2NM_MAX_NODES) {
799 BUG_ON(mig && mle->master == dlm->node_num);
810 dlm_mle_detach_hb_events(dlm, mle);
811 dlm_put_mle(mle);
812 mle = NULL;
814 * the mle or lockres waitqueue here */
821 mle = alloc_mle;
824 dlm_init_mle(mle, DLM_MLE_MASTER, dlm, res, NULL, 0);
825 set_bit(dlm->node_num, mle->maybe_map);
826 __dlm_insert_mle(dlm, mle);
830 * considered. these will not appear in the mle nodemap
855 /* get an extra ref on the mle in case this is a BLOCK
859 dlm_get_mle_inuse(mle);
866 * dlm spinlock would be detectable be a change on the mle,
905 dlm_node_iter_init(mle->vote_map, &iter);
907 ret = dlm_do_master_request(res, mle, nodenum);
910 if (mle->master != O2NM_MAX_NODES) {
912 if (mle->master <= nodenum)
920 lockid, nodenum, mle->master);
926 ret = dlm_wait_for_lock_mastery(dlm, res, mle, &blocked);
939 dlm_print_one_mle(mle);
950 dlm_mle_detach_hb_events(dlm, mle);
951 dlm_put_mle(mle);
953 dlm_put_mle_inuse(mle);
964 /* need to free the unused mle */
976 struct dlm_master_list_entry *mle,
997 ret = dlm_do_master_request(res, mle, res->owner);
1010 spin_lock(&mle->spinlock);
1011 m = mle->master;
1012 map_changed = (memcmp(mle->vote_map, mle->node_map,
1013 sizeof(mle->vote_map)) != 0);
1014 voting_done = (memcmp(mle->vote_map, mle->response_map,
1015 sizeof(mle->vote_map)) == 0);
1022 ret = dlm_restart_lock_mastery(dlm, res, mle, *blocked);
1023 b = (mle->type == DLM_MLE_BLOCK);
1030 spin_unlock(&mle->spinlock);
1055 bit = find_next_bit(mle->maybe_map, O2NM_MAX_NODES, 0);
1060 mle->master = dlm->node_num;
1071 spin_unlock(&mle->spinlock);
1078 if (atomic_read(&mle->mle_refs.refcount) < 2)
1079 mlog(ML_ERROR, "mle (%p) refs=%d, name=%.*s\n", mle,
1080 atomic_read(&mle->mle_refs.refcount),
1083 atomic_set(&mle->woken, 0);
1084 (void)wait_event_timeout(mle->wq,
1085 (atomic_read(&mle->woken) == 1),
1102 ret = dlm_do_assert_master(dlm, res, mle->vote_map, 0);
1188 struct dlm_master_list_entry *mle,
1199 assert_spin_locked(&mle->spinlock);
1201 dlm_bitmap_diff_iter_init(&bdi, mle->vote_map, mle->node_map);
1212 clear_bit(node, mle->response_map);
1213 set_bit(node, mle->vote_map);
1217 int lowest = find_next_bit(mle->maybe_map,
1221 clear_bit(node, mle->maybe_map);
1227 lowest = find_next_bit(mle->maybe_map,
1238 /* mle is an MLE_BLOCK, but
1244 * has already run, so the mle
1252 mle->type = DLM_MLE_MASTER;
1253 mle->mleres = res;
1260 memset(mle->maybe_map, 0, sizeof(mle->maybe_map));
1261 memset(mle->response_map, 0, sizeof(mle->response_map));
1263 memcpy(mle->vote_map, mle->node_map,
1264 sizeof(mle->node_map));
1266 if (mle->type != DLM_MLE_BLOCK)
1267 set_bit(dlm->node_num, mle->maybe_map);
1287 struct dlm_master_list_entry *mle, int to)
1289 struct dlm_ctxt *dlm = mle->dlm;
1296 BUG_ON(mle->type == DLM_MLE_MIGRATION);
1298 request.namelen = (u8)mle->mnamelen;
1299 memcpy(request.name, mle->mname, request.namelen);
1332 spin_lock(&mle->spinlock);
1335 set_bit(to, mle->response_map);
1340 mle->master = to;
1344 set_bit(to, mle->response_map);
1348 set_bit(to, mle->response_map);
1349 set_bit(to, mle->maybe_map);
1360 spin_unlock(&mle->spinlock);
1375 * mle->spinlock
1387 struct dlm_master_list_entry *mle = NULL, *tmpmle = NULL;
1425 if (mle)
1426 kmem_cache_free(dlm_mle_cache, mle);
1436 if (mle)
1437 kmem_cache_free(dlm_mle_cache, mle);
1451 if (mle)
1452 kmem_cache_free(dlm_mle_cache, mle);
1469 mlog(ML_ERROR, "no mle found for this lock!\n");
1516 /* keep the mle attached to heartbeat events */
1518 if (mle)
1519 kmem_cache_free(dlm_mle_cache, mle);
1533 // mlog(0, "no mle found\n");
1534 if (!mle) {
1538 mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
1539 if (!mle) {
1549 dlm_init_mle(mle, DLM_MLE_BLOCK, dlm, NULL, name, namelen);
1550 set_bit(request->node_idx, mle->maybe_map);
1551 __dlm_insert_mle(dlm, mle);
1554 // mlog(0, "mle was found\n");
1558 mlog(ML_ERROR, "no lockres, but an mle with this node as master!\n");
1564 mlog(0, "migration mle was found (%u->%u)\n",
1578 /* keep the mle attached to heartbeat events */
1648 struct dlm_master_list_entry *mle = NULL;
1679 if (dlm_find_mle(dlm, &mle, (char *)lockname,
1681 dlm_print_one_mle(mle);
1682 __dlm_put_mle(mle);
1727 * mle->spinlock
1736 struct dlm_master_list_entry *mle = NULL;
1765 if (!dlm_find_mle(dlm, &mle, name, namelen)) {
1771 int bit = find_next_bit (mle->maybe_map, O2NM_MAX_NODES, 0);
1794 if (mle->type == DLM_MLE_MIGRATION) {
1805 __dlm_put_mle(mle);
1824 if (!mle) {
1834 } else if (mle->type != DLM_MLE_MIGRATION) {
1857 } else /* mle->type == DLM_MLE_MIGRATION */ {
1859 if (assert->node_idx != mle->new_master) {
1863 assert->node_idx, mle->new_master,
1864 mle->master, namelen, name);
1875 if (mle) {
1880 spin_lock(&mle->spinlock);
1881 if (mle->type == DLM_MLE_BLOCK || mle->type == DLM_MLE_MIGRATION)
1884 /* MASTER mle: if any bits set in the response map
1887 while ((nn = find_next_bit (mle->response_map, O2NM_MAX_NODES,
1893 mle->master = assert->node_idx;
1894 atomic_set(&mle->woken, 1);
1895 wake_up(&mle->wq);
1896 spin_unlock(&mle->spinlock);
1901 if (mle->type == DLM_MLE_MIGRATION) {
1905 dlm->node_num, mle->new_master);
1908 dlm_change_lockres_owner(dlm, res, mle->new_master);
1911 dlm_change_lockres_owner(dlm, res, mle->master);
1921 * on this mle. */
1924 rr = atomic_read(&mle->mle_refs.refcount);
1925 if (mle->inuse > 0) {
1940 assert->node_idx, rr, extra_ref, mle->inuse);
1941 dlm_print_one_mle(mle);
1943 __dlm_unlink_mle(dlm, mle);
1944 __dlm_mle_detach_hb_events(dlm, mle);
1945 __dlm_put_mle(mle);
1951 __dlm_put_mle(mle);
1957 "owner is %u (%.*s), no mle\n", assert->node_idx,
1978 "mle present here for %s:%.*s, but no lockres!\n",
2404 struct dlm_master_list_entry *mle = NULL;
2451 mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
2452 if (!mle) {
2486 * add the migration mle to the list
2489 ret = dlm_add_migration_mle(dlm, res, mle, &oldmle, name,
2524 dlm_mle_detach_hb_events(dlm, mle);
2525 dlm_put_mle(mle);
2526 } else if (mle) {
2527 kmem_cache_free(dlm_mle_cache, mle);
2533 * at this point, we have a migration target, an mle
2542 /* get an extra reference on the mle.
2549 dlm_get_mle_inuse(mle);
2563 /* migration failed, detach and clean up mle */
2564 dlm_mle_detach_hb_events(dlm, mle);
2565 dlm_put_mle(mle);
2566 dlm_put_mle_inuse(mle);
2576 * we had to put an mle in the list to begin the process. this
2582 * mle and sets the master to UNKNOWN. */
2587 ret = wait_event_interruptible_timeout(mle->wq,
2588 (atomic_read(&mle->woken) == 1),
2592 if (atomic_read(&mle->woken) == 1 ||
2606 /* migration failed, detach and clean up mle */
2607 dlm_mle_detach_hb_events(dlm, mle);
2608 dlm_put_mle(mle);
2609 dlm_put_mle_inuse(mle);
2630 dlm_mle_detach_hb_events(dlm, mle);
2631 dlm_put_mle_inuse(mle);
3013 /* if there is an existing mle for this lockres, we now know who the master is.
3015 * since the process that put the mle on the list still has a reference to it,
3017 * we will have no mle in the list to start with. now we can add an mle for
3026 struct dlm_master_list_entry *mle = NULL, *oldmle = NULL;
3039 mle = kmem_cache_alloc(dlm_mle_cache, GFP_NOFS);
3041 if (!mle) {
3058 kmem_cache_free(dlm_mle_cache, mle);
3068 ret = dlm_add_migration_mle(dlm, res, mle, &oldmle,
3091 * when adding a migration mle, we can clear any other mles
3093 * the master is "master". so we remove any old mle from
3095 * the new migration mle. this way we can hold with the rule
3096 * of having only one mle for a given lock name at all times. */
3099 struct dlm_master_list_entry *mle,
3128 mlog(ML_ERROR, "migration error mle: "
3142 /* remove it so that only one mle will be found */
3147 "telling master to get ref for cleared out mle "
3154 /* now add a migration mle to the tail of the list */
3155 dlm_init_mle(mle, DLM_MLE_MIGRATION, dlm, res, name, namelen);
3156 mle->new_master = new_master;
3159 mle->master = master;
3160 /* do this for consistency with other mle types */
3161 set_bit(new_master, mle->maybe_map);
3162 __dlm_insert_mle(dlm, mle);
3168 * Sets the owner of the lockres, associated to the mle, to UNKNOWN
3171 struct dlm_master_list_entry *mle)
3175 /* Find the lockres associated to the mle and set its owner to UNK */
3176 res = __dlm_lookup_lockres(dlm, mle->mname, mle->mnamelen,
3177 mle->mnamehash);
3188 /* about to get rid of mle, detach from heartbeat */
3189 __dlm_mle_detach_hb_events(dlm, mle);
3191 /* dump the mle */
3193 __dlm_put_mle(mle);
3201 struct dlm_master_list_entry *mle)
3203 __dlm_mle_detach_hb_events(dlm, mle);
3205 spin_lock(&mle->spinlock);
3206 __dlm_unlink_mle(dlm, mle);
3207 atomic_set(&mle->woken, 1);
3208 spin_unlock(&mle->spinlock);
3210 wake_up(&mle->wq);
3214 struct dlm_master_list_entry *mle, u8 dead_node)
3218 BUG_ON(mle->type != DLM_MLE_BLOCK);
3220 spin_lock(&mle->spinlock);
3221 bit = find_next_bit(mle->maybe_map, O2NM_MAX_NODES, 0);
3223 mlog(0, "mle found, but dead node %u would not have been "
3225 spin_unlock(&mle->spinlock);
3228 * never arrive. This may result in the mle being unlinked and
3232 atomic_set(&mle->woken, 1);
3233 spin_unlock(&mle->spinlock);
3234 wake_up(&mle->wq);
3237 __dlm_mle_detach_hb_events(dlm, mle);
3238 __dlm_put_mle(mle);
3244 struct dlm_master_list_entry *mle;
3259 mle = hlist_entry(list, struct dlm_master_list_entry,
3262 BUG_ON(mle->type != DLM_MLE_BLOCK &&
3263 mle->type != DLM_MLE_MASTER &&
3264 mle->type != DLM_MLE_MIGRATION);
3269 if (mle->type == DLM_MLE_MASTER)
3275 if (mle->type == DLM_MLE_BLOCK) {
3276 dlm_clean_block_mle(dlm, mle, dead_node);
3280 /* Everything else is a MIGRATION mle */
3291 if (mle->master != dead_node &&
3292 mle->new_master != dead_node)
3295 /* If we have reached this point, this mle needs to be
3297 dlm_clean_migration_mle(dlm, mle);
3300 "%u to %u!\n", dlm->name, dead_node, mle->master,
3301 mle->new_master);
3303 /* If we find a lockres associated with the mle, we've
3308 res = dlm_reset_mleres_owner(dlm, mle);
3314 __dlm_put_mle(mle);
3441 struct dlm_master_list_entry *mle;
3459 mle = hlist_entry(list, struct dlm_master_list_entry,
3461 if (mle->type != DLM_MLE_BLOCK) {
3462 mlog(ML_ERROR, "bad mle: %p\n", mle);
3463 dlm_print_one_mle(mle);
3465 atomic_set(&mle->woken, 1);
3466 wake_up(&mle->wq);
3468 __dlm_unlink_mle(dlm, mle);
3469 __dlm_mle_detach_hb_events(dlm, mle);
3470 __dlm_put_mle(mle);