Lines Matching refs:cinfo

188 	struct md_cluster_info *cinfo = mddev->cluster_info;  in lockres_init()  local
195 res->ls = cinfo->lockspace; in lockres_init()
272 struct md_cluster_info *cinfo = mddev->cluster_info; in read_resync_info() local
278 cinfo->suspend_hi = le64_to_cpu(ri.hi); in read_resync_info()
279 cinfo->suspend_lo = le64_to_cpu(ri.lo); in read_resync_info()
289 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_bitmaps() local
295 while (cinfo->recovery_map) { in recover_bitmaps()
296 slot = fls64((u64)cinfo->recovery_map) - 1; in recover_bitmaps()
318 spin_lock_irq(&cinfo->suspend_lock); in recover_bitmaps()
319 cinfo->suspend_hi = 0; in recover_bitmaps()
320 cinfo->suspend_lo = 0; in recover_bitmaps()
321 cinfo->suspend_from = -1; in recover_bitmaps()
322 spin_unlock_irq(&cinfo->suspend_lock); in recover_bitmaps()
348 clear_bit(slot, &cinfo->recovery_map); in recover_bitmaps()
355 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_prep() local
356 set_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_prep()
361 struct md_cluster_info *cinfo = mddev->cluster_info; in __recover_slot() local
363 set_bit(slot, &cinfo->recovery_map); in __recover_slot()
364 if (!cinfo->recovery_thread) { in __recover_slot()
365 cinfo->recovery_thread = md_register_thread(recover_bitmaps, in __recover_slot()
367 if (!cinfo->recovery_thread) { in __recover_slot()
372 md_wakeup_thread(cinfo->recovery_thread); in __recover_slot()
378 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_slot() local
383 cinfo->slot_number); in recover_slot()
394 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_done() local
396 cinfo->slot_number = our_slot; in recover_done()
399 if (test_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state)) { in recover_done()
400 complete(&cinfo->completion); in recover_done()
401 clear_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in recover_done()
403 clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_done()
422 struct md_cluster_info *cinfo = res->mddev->cluster_info; in ack_bast() local
425 if (test_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state)) in ack_bast()
426 md_wakeup_thread(cinfo->recv_thread); in ack_bast()
428 set_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state); in ack_bast()
434 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_suspend_info() local
436 spin_lock_irq(&cinfo->suspend_lock); in remove_suspend_info()
437 cinfo->suspend_hi = 0; in remove_suspend_info()
438 cinfo->suspend_lo = 0; in remove_suspend_info()
439 spin_unlock_irq(&cinfo->suspend_lock); in remove_suspend_info()
446 struct md_cluster_info *cinfo = mddev->cluster_info; in process_suspend_info() local
490 md_bitmap_sync_with_cluster(mddev, cinfo->sync_low, in process_suspend_info()
491 cinfo->sync_hi, lo, hi); in process_suspend_info()
492 cinfo->sync_low = lo; in process_suspend_info()
493 cinfo->sync_hi = hi; in process_suspend_info()
496 spin_lock_irq(&cinfo->suspend_lock); in process_suspend_info()
497 cinfo->suspend_from = slot; in process_suspend_info()
498 cinfo->suspend_lo = lo; in process_suspend_info()
499 cinfo->suspend_hi = hi; in process_suspend_info()
500 spin_unlock_irq(&cinfo->suspend_lock); in process_suspend_info()
507 struct md_cluster_info *cinfo = mddev->cluster_info; in process_add_new_disk() local
517 init_completion(&cinfo->newdisk_completion); in process_add_new_disk()
518 set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
520 wait_for_completion_timeout(&cinfo->newdisk_completion, in process_add_new_disk()
522 clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
529 struct md_cluster_info *cinfo = mddev->cluster_info; in process_metadata_update() local
532 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in process_metadata_update()
535 test_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state)); in process_metadata_update()
622 struct md_cluster_info *cinfo = thread->mddev->cluster_info; in recv_daemon() local
623 struct dlm_lock_resource *ack_lockres = cinfo->ack_lockres; in recv_daemon()
624 struct dlm_lock_resource *message_lockres = cinfo->message_lockres; in recv_daemon()
628 mutex_lock(&cinfo->recv_mutex); in recv_daemon()
632 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
659 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
666 static int lock_token(struct md_cluster_info *cinfo) in lock_token() argument
670 error = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in lock_token()
676 mutex_lock(&cinfo->recv_mutex); in lock_token()
684 static int lock_comm(struct md_cluster_info *cinfo, bool mddev_locked) in lock_comm() argument
687 struct mddev *mddev = cinfo->mddev; in lock_comm()
696 &cinfo->state)) { in lock_comm()
698 &cinfo->state); in lock_comm()
704 wait_event(cinfo->wait, in lock_comm()
705 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state)); in lock_comm()
706 rv = lock_token(cinfo); in lock_comm()
708 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in lock_comm()
712 static void unlock_comm(struct md_cluster_info *cinfo) in unlock_comm() argument
714 WARN_ON(cinfo->token_lockres->mode != DLM_LOCK_EX); in unlock_comm()
715 mutex_unlock(&cinfo->recv_mutex); in unlock_comm()
716 dlm_unlock_sync(cinfo->token_lockres); in unlock_comm()
717 clear_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state); in unlock_comm()
718 wake_up(&cinfo->wait); in unlock_comm()
733 static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) in __sendmsg() argument
736 int slot = cinfo->slot_number - 1; in __sendmsg()
740 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX); in __sendmsg()
746 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg, in __sendmsg()
749 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW); in __sendmsg()
757 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_EX); in __sendmsg()
765 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR); in __sendmsg()
773 error = dlm_unlock_sync(cinfo->message_lockres); in __sendmsg()
784 static int sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg, in sendmsg() argument
789 ret = lock_comm(cinfo, mddev_locked); in sendmsg()
791 ret = __sendmsg(cinfo, cmsg); in sendmsg()
792 unlock_comm(cinfo); in sendmsg()
799 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_all_resync_info() local
812 if (i == (cinfo->slot_number - 1)) { in gather_all_resync_info()
823 (unsigned long long) cinfo->suspend_lo, in gather_all_resync_info()
824 (unsigned long long) cinfo->suspend_hi, in gather_all_resync_info()
826 cinfo->suspend_from = i; in gather_all_resync_info()
858 struct md_cluster_info *cinfo; in join() local
862 cinfo = kzalloc(sizeof(struct md_cluster_info), GFP_KERNEL); in join()
863 if (!cinfo) in join()
866 INIT_LIST_HEAD(&cinfo->suspend_list); in join()
867 spin_lock_init(&cinfo->suspend_lock); in join()
868 init_completion(&cinfo->completion); in join()
869 set_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in join()
870 init_waitqueue_head(&cinfo->wait); in join()
871 mutex_init(&cinfo->recv_mutex); in join()
873 mddev->cluster_info = cinfo; in join()
874 cinfo->mddev = mddev; in join()
880 &ops_rv, &cinfo->lockspace); in join()
883 wait_for_completion(&cinfo->completion); in join()
884 if (nodes < cinfo->slot_number) { in join()
886 cinfo->slot_number, nodes); in join()
892 cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv"); in join()
893 if (!cinfo->recv_thread) { in join()
897 cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1); in join()
898 if (!cinfo->message_lockres) in join()
900 cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0); in join()
901 if (!cinfo->token_lockres) in join()
903 cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0); in join()
904 if (!cinfo->no_new_dev_lockres) in join()
907 ret = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in join()
913 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); in join()
914 if (!cinfo->ack_lockres) { in join()
919 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) in join()
922 dlm_unlock_sync(cinfo->token_lockres); in join()
924 if (dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR)) in join()
928 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); in join()
929 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); in join()
930 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); in join()
931 if (!cinfo->bitmap_lockres) { in join()
935 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { in join()
941 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); in join()
942 if (!cinfo->resync_lockres) { in join()
949 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in join()
950 md_unregister_thread(&cinfo->recovery_thread); in join()
951 md_unregister_thread(&cinfo->recv_thread); in join()
952 lockres_free(cinfo->message_lockres); in join()
953 lockres_free(cinfo->token_lockres); in join()
954 lockres_free(cinfo->ack_lockres); in join()
955 lockres_free(cinfo->no_new_dev_lockres); in join()
956 lockres_free(cinfo->resync_lockres); in join()
957 lockres_free(cinfo->bitmap_lockres); in join()
958 if (cinfo->lockspace) in join()
959 dlm_release_lockspace(cinfo->lockspace, 2); in join()
961 kfree(cinfo); in join()
967 struct md_cluster_info *cinfo = mddev->cluster_info; in load_bitmaps() local
972 set_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state); in load_bitmaps()
974 if (test_and_clear_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state)) in load_bitmaps()
975 md_wakeup_thread(cinfo->recv_thread); in load_bitmaps()
980 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_bitmap() local
985 err = sendmsg(cinfo, &cmsg, 1); in resync_bitmap()
994 struct md_cluster_info *cinfo = mddev->cluster_info; in leave() local
996 if (!cinfo) in leave()
1007 if ((cinfo->slot_number > 0 && mddev->recovery_cp != MaxSector) || in leave()
1012 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in leave()
1013 md_unregister_thread(&cinfo->recovery_thread); in leave()
1014 md_unregister_thread(&cinfo->recv_thread); in leave()
1015 lockres_free(cinfo->message_lockres); in leave()
1016 lockres_free(cinfo->token_lockres); in leave()
1017 lockres_free(cinfo->ack_lockres); in leave()
1018 lockres_free(cinfo->no_new_dev_lockres); in leave()
1019 lockres_free(cinfo->resync_lockres); in leave()
1020 lockres_free(cinfo->bitmap_lockres); in leave()
1022 dlm_release_lockspace(cinfo->lockspace, 2); in leave()
1023 kfree(cinfo); in leave()
1033 struct md_cluster_info *cinfo = mddev->cluster_info; in slot_number() local
1035 return cinfo->slot_number - 1; in slot_number()
1046 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_start() local
1054 &cinfo->state); in metadata_update_start()
1058 wait_event(cinfo->wait, in metadata_update_start()
1059 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state) || in metadata_update_start()
1060 test_and_clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state)); in metadata_update_start()
1063 if (cinfo->token_lockres->mode == DLM_LOCK_EX) { in metadata_update_start()
1064 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1068 ret = lock_token(cinfo); in metadata_update_start()
1069 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1075 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_finish() local
1092 ret = __sendmsg(cinfo, &cmsg); in metadata_update_finish()
1095 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_finish()
1096 unlock_comm(cinfo); in metadata_update_finish()
1102 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_cancel() local
1103 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_cancel()
1104 unlock_comm(cinfo); in metadata_update_cancel()
1109 struct md_cluster_info *cinfo = mddev->cluster_info; in update_bitmap_size() local
1115 ret = sendmsg(cinfo, &cmsg, 0); in update_bitmap_size()
1255 struct md_cluster_info *cinfo = mddev->cluster_info; in update_size() local
1262 if (lock_comm(cinfo, 1)) { in update_size()
1281 ret = __sendmsg(cinfo, &cmsg); in update_size()
1285 unlock_comm(cinfo); in update_size()
1290 unlock_comm(cinfo); in update_size()
1302 ret = __sendmsg(cinfo, &cmsg); in update_size()
1310 ret = __sendmsg(cinfo, &cmsg); in update_size()
1315 unlock_comm(cinfo); in update_size()
1320 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_start() local
1321 return dlm_lock_sync_interruptible(cinfo->resync_lockres, DLM_LOCK_EX, mddev); in resync_start()
1326 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_get() local
1328 spin_lock_irq(&cinfo->suspend_lock); in resync_info_get()
1329 *lo = cinfo->suspend_lo; in resync_info_get()
1330 *hi = cinfo->suspend_hi; in resync_info_get()
1331 spin_unlock_irq(&cinfo->suspend_lock); in resync_info_get()
1336 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_update() local
1342 memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); in resync_info_update()
1347 add_resync_info(cinfo->bitmap_lockres, lo, hi); in resync_info_update()
1349 dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW); in resync_info_update()
1359 return sendmsg(cinfo, &cmsg, 1); in resync_info_update()
1361 return sendmsg(cinfo, &cmsg, 0); in resync_info_update()
1366 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_finish() local
1377 dlm_unlock_sync(cinfo->resync_lockres); in resync_finish()
1384 struct md_cluster_info *cinfo = mddev->cluster_info; in area_resyncing() local
1388 test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) in area_resyncing()
1391 spin_lock_irq(&cinfo->suspend_lock); in area_resyncing()
1392 if (hi > cinfo->suspend_lo && lo < cinfo->suspend_hi) in area_resyncing()
1394 spin_unlock_irq(&cinfo->suspend_lock); in area_resyncing()
1404 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk() local
1414 if (lock_comm(cinfo, 1)) in add_new_disk()
1416 ret = __sendmsg(cinfo, &cmsg); in add_new_disk()
1418 unlock_comm(cinfo); in add_new_disk()
1421 cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE; in add_new_disk()
1422 ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX); in add_new_disk()
1423 cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE; in add_new_disk()
1428 unlock_comm(cinfo); in add_new_disk()
1430 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in add_new_disk()
1443 set_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk()
1444 wake_up(&cinfo->wait); in add_new_disk()
1451 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk_cancel() local
1452 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk_cancel()
1453 unlock_comm(cinfo); in add_new_disk_cancel()
1458 struct md_cluster_info *cinfo = mddev->cluster_info; in new_disk_ack() local
1460 if (!test_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state)) { in new_disk_ack()
1466 dlm_unlock_sync(cinfo->no_new_dev_lockres); in new_disk_ack()
1467 complete(&cinfo->newdisk_completion); in new_disk_ack()
1474 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_disk() local
1477 return sendmsg(cinfo, &cmsg, 1); in remove_disk()
1484 struct md_cluster_info *cinfo = mddev->cluster_info; in lock_all_bitmaps() local
1486 cinfo->other_bitmap_lockres = in lock_all_bitmaps()
1489 if (!cinfo->other_bitmap_lockres) { in lock_all_bitmaps()
1501 cinfo->other_bitmap_lockres[i] = lockres_init(mddev, str, NULL, 1); in lock_all_bitmaps()
1502 if (!cinfo->other_bitmap_lockres[i]) in lock_all_bitmaps()
1505 cinfo->other_bitmap_lockres[i]->flags |= DLM_LKF_NOQUEUE; in lock_all_bitmaps()
1506 ret = dlm_lock_sync(cinfo->other_bitmap_lockres[i], DLM_LOCK_PW); in lock_all_bitmaps()
1517 struct md_cluster_info *cinfo = mddev->cluster_info; in unlock_all_bitmaps() local
1521 if (cinfo->other_bitmap_lockres) { in unlock_all_bitmaps()
1523 if (cinfo->other_bitmap_lockres[i]) { in unlock_all_bitmaps()
1524 lockres_free(cinfo->other_bitmap_lockres[i]); in unlock_all_bitmaps()
1527 kfree(cinfo->other_bitmap_lockres); in unlock_all_bitmaps()
1528 cinfo->other_bitmap_lockres = NULL; in unlock_all_bitmaps()
1538 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_bitmaps() local
1542 err = sendmsg(cinfo, &cmsg, 1); in gather_bitmaps()
1547 if (sn == (cinfo->slot_number - 1)) in gather_bitmaps()