Lines Matching refs:cinfo
193 struct md_cluster_info *cinfo = mddev->cluster_info; in lockres_init() local
200 res->ls = cinfo->lockspace; in lockres_init()
297 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_bitmaps() local
304 while (cinfo->recovery_map) { in recover_bitmaps()
305 slot = fls64((u64)cinfo->recovery_map) - 1; in recover_bitmaps()
327 spin_lock_irq(&cinfo->suspend_lock); in recover_bitmaps()
328 list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) in recover_bitmaps()
333 spin_unlock_irq(&cinfo->suspend_lock); in recover_bitmaps()
353 clear_bit(slot, &cinfo->recovery_map); in recover_bitmaps()
360 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_prep() local
361 set_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_prep()
366 struct md_cluster_info *cinfo = mddev->cluster_info; in __recover_slot() local
368 set_bit(slot, &cinfo->recovery_map); in __recover_slot()
369 if (!cinfo->recovery_thread) { in __recover_slot()
370 cinfo->recovery_thread = md_register_thread(recover_bitmaps, in __recover_slot()
372 if (!cinfo->recovery_thread) { in __recover_slot()
377 md_wakeup_thread(cinfo->recovery_thread); in __recover_slot()
383 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_slot() local
388 cinfo->slot_number); in recover_slot()
399 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_done() local
401 cinfo->slot_number = our_slot; in recover_done()
404 if (test_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state)) { in recover_done()
405 complete(&cinfo->completion); in recover_done()
406 clear_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in recover_done()
408 clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_done()
427 struct md_cluster_info *cinfo = res->mddev->cluster_info; in ack_bast() local
430 if (test_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state)) in ack_bast()
431 md_wakeup_thread(cinfo->recv_thread); in ack_bast()
433 set_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state); in ack_bast()
437 static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot) in __remove_suspend_info() argument
441 list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) in __remove_suspend_info()
451 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_suspend_info() local
453 spin_lock_irq(&cinfo->suspend_lock); in remove_suspend_info()
454 __remove_suspend_info(cinfo, slot); in remove_suspend_info()
455 spin_unlock_irq(&cinfo->suspend_lock); in remove_suspend_info()
463 struct md_cluster_info *cinfo = mddev->cluster_info; in process_suspend_info() local
495 md_bitmap_sync_with_cluster(mddev, cinfo->sync_low, cinfo->sync_hi, lo, hi); in process_suspend_info()
496 cinfo->sync_low = lo; in process_suspend_info()
497 cinfo->sync_hi = hi; in process_suspend_info()
506 spin_lock_irq(&cinfo->suspend_lock); in process_suspend_info()
508 __remove_suspend_info(cinfo, slot); in process_suspend_info()
509 list_add(&s->list, &cinfo->suspend_list); in process_suspend_info()
510 spin_unlock_irq(&cinfo->suspend_lock); in process_suspend_info()
517 struct md_cluster_info *cinfo = mddev->cluster_info; in process_add_new_disk() local
527 init_completion(&cinfo->newdisk_completion); in process_add_new_disk()
528 set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
530 wait_for_completion_timeout(&cinfo->newdisk_completion, in process_add_new_disk()
532 clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
539 struct md_cluster_info *cinfo = mddev->cluster_info; in process_metadata_update() local
542 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in process_metadata_update()
545 test_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state)); in process_metadata_update()
628 struct md_cluster_info *cinfo = thread->mddev->cluster_info; in recv_daemon() local
629 struct dlm_lock_resource *ack_lockres = cinfo->ack_lockres; in recv_daemon()
630 struct dlm_lock_resource *message_lockres = cinfo->message_lockres; in recv_daemon()
634 mutex_lock(&cinfo->recv_mutex); in recv_daemon()
638 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
665 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
672 static int lock_token(struct md_cluster_info *cinfo, bool mddev_locked) in lock_token() argument
675 struct mddev *mddev = cinfo->mddev; in lock_token()
684 &cinfo->state)) { in lock_token()
686 &cinfo->state); in lock_token()
691 error = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in lock_token()
693 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in lock_token()
700 mutex_lock(&cinfo->recv_mutex); in lock_token()
707 static int lock_comm(struct md_cluster_info *cinfo, bool mddev_locked) in lock_comm() argument
709 wait_event(cinfo->wait, in lock_comm()
710 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state)); in lock_comm()
712 return lock_token(cinfo, mddev_locked); in lock_comm()
715 static void unlock_comm(struct md_cluster_info *cinfo) in unlock_comm() argument
717 WARN_ON(cinfo->token_lockres->mode != DLM_LOCK_EX); in unlock_comm()
718 mutex_unlock(&cinfo->recv_mutex); in unlock_comm()
719 dlm_unlock_sync(cinfo->token_lockres); in unlock_comm()
720 clear_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state); in unlock_comm()
721 wake_up(&cinfo->wait); in unlock_comm()
736 static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) in __sendmsg() argument
739 int slot = cinfo->slot_number - 1; in __sendmsg()
743 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX); in __sendmsg()
749 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg, in __sendmsg()
752 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW); in __sendmsg()
760 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_EX); in __sendmsg()
768 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR); in __sendmsg()
776 error = dlm_unlock_sync(cinfo->message_lockres); in __sendmsg()
787 static int sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg, in sendmsg() argument
792 lock_comm(cinfo, mddev_locked); in sendmsg()
793 ret = __sendmsg(cinfo, cmsg); in sendmsg()
794 unlock_comm(cinfo); in sendmsg()
800 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_all_resync_info() local
814 if (i == (cinfo->slot_number - 1)) { in gather_all_resync_info()
828 spin_lock_irq(&cinfo->suspend_lock); in gather_all_resync_info()
830 list_add(&s->list, &cinfo->suspend_list); in gather_all_resync_info()
831 spin_unlock_irq(&cinfo->suspend_lock); in gather_all_resync_info()
863 struct md_cluster_info *cinfo; in join() local
867 cinfo = kzalloc(sizeof(struct md_cluster_info), GFP_KERNEL); in join()
868 if (!cinfo) in join()
871 INIT_LIST_HEAD(&cinfo->suspend_list); in join()
872 spin_lock_init(&cinfo->suspend_lock); in join()
873 init_completion(&cinfo->completion); in join()
874 set_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in join()
875 init_waitqueue_head(&cinfo->wait); in join()
876 mutex_init(&cinfo->recv_mutex); in join()
878 mddev->cluster_info = cinfo; in join()
879 cinfo->mddev = mddev; in join()
885 &md_ls_ops, mddev, &ops_rv, &cinfo->lockspace); in join()
888 wait_for_completion(&cinfo->completion); in join()
889 if (nodes < cinfo->slot_number) { in join()
891 cinfo->slot_number, nodes); in join()
897 cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv"); in join()
898 if (!cinfo->recv_thread) { in join()
902 cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1); in join()
903 if (!cinfo->message_lockres) in join()
905 cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0); in join()
906 if (!cinfo->token_lockres) in join()
908 cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0); in join()
909 if (!cinfo->no_new_dev_lockres) in join()
912 ret = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in join()
918 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); in join()
919 if (!cinfo->ack_lockres) { in join()
924 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) in join()
927 dlm_unlock_sync(cinfo->token_lockres); in join()
929 if (dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR)) in join()
933 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); in join()
934 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); in join()
935 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); in join()
936 if (!cinfo->bitmap_lockres) { in join()
940 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { in join()
946 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); in join()
947 if (!cinfo->resync_lockres) { in join()
954 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in join()
955 md_unregister_thread(&cinfo->recovery_thread); in join()
956 md_unregister_thread(&cinfo->recv_thread); in join()
957 lockres_free(cinfo->message_lockres); in join()
958 lockres_free(cinfo->token_lockres); in join()
959 lockres_free(cinfo->ack_lockres); in join()
960 lockres_free(cinfo->no_new_dev_lockres); in join()
961 lockres_free(cinfo->resync_lockres); in join()
962 lockres_free(cinfo->bitmap_lockres); in join()
963 if (cinfo->lockspace) in join()
964 dlm_release_lockspace(cinfo->lockspace, 2); in join()
966 kfree(cinfo); in join()
972 struct md_cluster_info *cinfo = mddev->cluster_info; in load_bitmaps() local
977 set_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state); in load_bitmaps()
979 if (test_and_clear_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state)) in load_bitmaps()
980 md_wakeup_thread(cinfo->recv_thread); in load_bitmaps()
985 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_bitmap() local
990 err = sendmsg(cinfo, &cmsg, 1); in resync_bitmap()
999 struct md_cluster_info *cinfo = mddev->cluster_info; in leave() local
1001 if (!cinfo) in leave()
1007 if (cinfo->slot_number > 0 && mddev->recovery_cp != MaxSector) in leave()
1010 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in leave()
1011 md_unregister_thread(&cinfo->recovery_thread); in leave()
1012 md_unregister_thread(&cinfo->recv_thread); in leave()
1013 lockres_free(cinfo->message_lockres); in leave()
1014 lockres_free(cinfo->token_lockres); in leave()
1015 lockres_free(cinfo->ack_lockres); in leave()
1016 lockres_free(cinfo->no_new_dev_lockres); in leave()
1017 lockres_free(cinfo->resync_lockres); in leave()
1018 lockres_free(cinfo->bitmap_lockres); in leave()
1020 dlm_release_lockspace(cinfo->lockspace, 2); in leave()
1021 kfree(cinfo); in leave()
1031 struct md_cluster_info *cinfo = mddev->cluster_info; in slot_number() local
1033 return cinfo->slot_number - 1; in slot_number()
1044 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_start() local
1052 &cinfo->state); in metadata_update_start()
1056 wait_event(cinfo->wait, in metadata_update_start()
1057 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state) || in metadata_update_start()
1058 test_and_clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state)); in metadata_update_start()
1061 if (cinfo->token_lockres->mode == DLM_LOCK_EX) { in metadata_update_start()
1062 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1066 ret = lock_token(cinfo, 1); in metadata_update_start()
1067 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1073 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_finish() local
1090 ret = __sendmsg(cinfo, &cmsg); in metadata_update_finish()
1093 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_finish()
1094 unlock_comm(cinfo); in metadata_update_finish()
1100 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_cancel() local
1101 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_cancel()
1102 unlock_comm(cinfo); in metadata_update_cancel()
1177 struct md_cluster_info *cinfo = mddev->cluster_info; in update_size() local
1184 lock_comm(cinfo, 1); in update_size()
1200 ret = __sendmsg(cinfo, &cmsg); in update_size()
1204 unlock_comm(cinfo); in update_size()
1209 unlock_comm(cinfo); in update_size()
1221 ret = __sendmsg(cinfo, &cmsg); in update_size()
1232 ret = __sendmsg(cinfo, &cmsg); in update_size()
1237 unlock_comm(cinfo); in update_size()
1242 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_start() local
1243 return dlm_lock_sync_interruptible(cinfo->resync_lockres, DLM_LOCK_EX, mddev); in resync_start()
1248 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_update() local
1254 memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); in resync_info_update()
1259 add_resync_info(cinfo->bitmap_lockres, lo, hi); in resync_info_update()
1261 dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW); in resync_info_update()
1271 return sendmsg(cinfo, &cmsg, 1); in resync_info_update()
1273 return sendmsg(cinfo, &cmsg, 0); in resync_info_update()
1278 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_finish() local
1289 dlm_unlock_sync(cinfo->resync_lockres); in resync_finish()
1296 struct md_cluster_info *cinfo = mddev->cluster_info; in area_resyncing() local
1301 test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) in area_resyncing()
1304 spin_lock_irq(&cinfo->suspend_lock); in area_resyncing()
1305 if (list_empty(&cinfo->suspend_list)) in area_resyncing()
1307 list_for_each_entry(s, &cinfo->suspend_list, list) in area_resyncing()
1313 spin_unlock_irq(&cinfo->suspend_lock); in area_resyncing()
1323 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk() local
1333 lock_comm(cinfo, 1); in add_new_disk()
1334 ret = __sendmsg(cinfo, &cmsg); in add_new_disk()
1336 unlock_comm(cinfo); in add_new_disk()
1339 cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE; in add_new_disk()
1340 ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX); in add_new_disk()
1341 cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE; in add_new_disk()
1346 unlock_comm(cinfo); in add_new_disk()
1348 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in add_new_disk()
1361 set_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk()
1362 wake_up(&cinfo->wait); in add_new_disk()
1369 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk_cancel() local
1370 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk_cancel()
1371 unlock_comm(cinfo); in add_new_disk_cancel()
1376 struct md_cluster_info *cinfo = mddev->cluster_info; in new_disk_ack() local
1378 if (!test_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state)) { in new_disk_ack()
1384 dlm_unlock_sync(cinfo->no_new_dev_lockres); in new_disk_ack()
1385 complete(&cinfo->newdisk_completion); in new_disk_ack()
1392 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_disk() local
1395 return sendmsg(cinfo, &cmsg, 1); in remove_disk()
1402 struct md_cluster_info *cinfo = mddev->cluster_info; in lock_all_bitmaps() local
1404 cinfo->other_bitmap_lockres = in lock_all_bitmaps()
1407 if (!cinfo->other_bitmap_lockres) { in lock_all_bitmaps()
1419 cinfo->other_bitmap_lockres[i] = lockres_init(mddev, str, NULL, 1); in lock_all_bitmaps()
1420 if (!cinfo->other_bitmap_lockres[i]) in lock_all_bitmaps()
1423 cinfo->other_bitmap_lockres[i]->flags |= DLM_LKF_NOQUEUE; in lock_all_bitmaps()
1424 ret = dlm_lock_sync(cinfo->other_bitmap_lockres[i], DLM_LOCK_PW); in lock_all_bitmaps()
1435 struct md_cluster_info *cinfo = mddev->cluster_info; in unlock_all_bitmaps() local
1439 if (cinfo->other_bitmap_lockres) { in unlock_all_bitmaps()
1441 if (cinfo->other_bitmap_lockres[i]) { in unlock_all_bitmaps()
1442 lockres_free(cinfo->other_bitmap_lockres[i]); in unlock_all_bitmaps()
1445 kfree(cinfo->other_bitmap_lockres); in unlock_all_bitmaps()
1455 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_bitmaps() local
1459 err = sendmsg(cinfo, &cmsg, 1); in gather_bitmaps()
1464 if (sn == (cinfo->slot_number - 1)) in gather_bitmaps()