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()
347 clear_bit(slot, &cinfo->recovery_map); in recover_bitmaps()
354 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_prep() local
355 set_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_prep()
360 struct md_cluster_info *cinfo = mddev->cluster_info; in __recover_slot() local
362 set_bit(slot, &cinfo->recovery_map); in __recover_slot()
363 if (!cinfo->recovery_thread) { in __recover_slot()
364 cinfo->recovery_thread = md_register_thread(recover_bitmaps, in __recover_slot()
366 if (!cinfo->recovery_thread) { in __recover_slot()
371 md_wakeup_thread(cinfo->recovery_thread); in __recover_slot()
377 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_slot() local
382 cinfo->slot_number); in recover_slot()
393 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_done() local
395 cinfo->slot_number = our_slot; in recover_done()
398 if (test_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state)) { in recover_done()
399 complete(&cinfo->completion); in recover_done()
400 clear_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in recover_done()
402 clear_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state); in recover_done()
421 struct md_cluster_info *cinfo = res->mddev->cluster_info; in ack_bast() local
424 if (test_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state)) in ack_bast()
425 md_wakeup_thread(cinfo->recv_thread); in ack_bast()
427 set_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state); in ack_bast()
431 static void __remove_suspend_info(struct md_cluster_info *cinfo, int slot) in __remove_suspend_info() argument
435 list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list) in __remove_suspend_info()
445 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_suspend_info() local
447 spin_lock_irq(&cinfo->suspend_lock); in remove_suspend_info()
448 __remove_suspend_info(cinfo, slot); in remove_suspend_info()
449 spin_unlock_irq(&cinfo->suspend_lock); in remove_suspend_info()
457 struct md_cluster_info *cinfo = mddev->cluster_info; in process_suspend_info() local
484 bitmap_sync_with_cluster(mddev, cinfo->sync_low, in process_suspend_info()
485 cinfo->sync_hi, in process_suspend_info()
487 cinfo->sync_low = lo; in process_suspend_info()
488 cinfo->sync_hi = hi; in process_suspend_info()
497 spin_lock_irq(&cinfo->suspend_lock); in process_suspend_info()
499 __remove_suspend_info(cinfo, slot); in process_suspend_info()
500 list_add(&s->list, &cinfo->suspend_list); in process_suspend_info()
501 spin_unlock_irq(&cinfo->suspend_lock); in process_suspend_info()
508 struct md_cluster_info *cinfo = mddev->cluster_info; in process_add_new_disk() local
518 init_completion(&cinfo->newdisk_completion); in process_add_new_disk()
519 set_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
521 wait_for_completion_timeout(&cinfo->newdisk_completion, in process_add_new_disk()
523 clear_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state); in process_add_new_disk()
530 struct md_cluster_info *cinfo = mddev->cluster_info; in process_metadata_update() local
533 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in process_metadata_update()
536 test_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state)); in process_metadata_update()
618 struct md_cluster_info *cinfo = thread->mddev->cluster_info; in recv_daemon() local
619 struct dlm_lock_resource *ack_lockres = cinfo->ack_lockres; in recv_daemon()
620 struct dlm_lock_resource *message_lockres = cinfo->message_lockres; in recv_daemon()
624 mutex_lock(&cinfo->recv_mutex); in recv_daemon()
628 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
655 mutex_unlock(&cinfo->recv_mutex); in recv_daemon()
662 static int lock_token(struct md_cluster_info *cinfo, bool mddev_locked) in lock_token() argument
665 struct mddev *mddev = cinfo->mddev; in lock_token()
674 &cinfo->state)) { in lock_token()
676 &cinfo->state); in lock_token()
681 error = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in lock_token()
683 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in lock_token()
690 mutex_lock(&cinfo->recv_mutex); in lock_token()
697 static int lock_comm(struct md_cluster_info *cinfo, bool mddev_locked) in lock_comm() argument
699 wait_event(cinfo->wait, in lock_comm()
700 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state)); in lock_comm()
702 return lock_token(cinfo, mddev_locked); in lock_comm()
705 static void unlock_comm(struct md_cluster_info *cinfo) in unlock_comm() argument
707 WARN_ON(cinfo->token_lockres->mode != DLM_LOCK_EX); in unlock_comm()
708 mutex_unlock(&cinfo->recv_mutex); in unlock_comm()
709 dlm_unlock_sync(cinfo->token_lockres); in unlock_comm()
710 clear_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state); in unlock_comm()
711 wake_up(&cinfo->wait); in unlock_comm()
726 static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg) in __sendmsg() argument
729 int slot = cinfo->slot_number - 1; in __sendmsg()
733 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_EX); in __sendmsg()
739 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg, in __sendmsg()
742 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW); in __sendmsg()
750 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_EX); in __sendmsg()
758 error = dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR); in __sendmsg()
766 error = dlm_unlock_sync(cinfo->message_lockres); in __sendmsg()
777 static int sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg, in sendmsg() argument
782 lock_comm(cinfo, mddev_locked); in sendmsg()
783 ret = __sendmsg(cinfo, cmsg); in sendmsg()
784 unlock_comm(cinfo); in sendmsg()
790 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_all_resync_info() local
804 if (i == (cinfo->slot_number - 1)) { in gather_all_resync_info()
818 spin_lock_irq(&cinfo->suspend_lock); in gather_all_resync_info()
820 list_add(&s->list, &cinfo->suspend_list); in gather_all_resync_info()
821 spin_unlock_irq(&cinfo->suspend_lock); in gather_all_resync_info()
853 struct md_cluster_info *cinfo; in join() local
857 cinfo = kzalloc(sizeof(struct md_cluster_info), GFP_KERNEL); in join()
858 if (!cinfo) in join()
861 INIT_LIST_HEAD(&cinfo->suspend_list); in join()
862 spin_lock_init(&cinfo->suspend_lock); in join()
863 init_completion(&cinfo->completion); in join()
864 set_bit(MD_CLUSTER_BEGIN_JOIN_CLUSTER, &cinfo->state); in join()
865 init_waitqueue_head(&cinfo->wait); in join()
866 mutex_init(&cinfo->recv_mutex); in join()
868 mddev->cluster_info = cinfo; in join()
869 cinfo->mddev = mddev; in join()
875 &md_ls_ops, mddev, &ops_rv, &cinfo->lockspace); in join()
878 wait_for_completion(&cinfo->completion); in join()
879 if (nodes < cinfo->slot_number) { in join()
881 cinfo->slot_number, nodes); in join()
887 cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv"); in join()
888 if (!cinfo->recv_thread) { in join()
892 cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1); in join()
893 if (!cinfo->message_lockres) in join()
895 cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0); in join()
896 if (!cinfo->token_lockres) in join()
898 cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0); in join()
899 if (!cinfo->no_new_dev_lockres) in join()
902 ret = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX); in join()
908 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); in join()
909 if (!cinfo->ack_lockres) { in join()
914 if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR)) in join()
917 dlm_unlock_sync(cinfo->token_lockres); in join()
919 if (dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR)) in join()
923 pr_info("md-cluster: Joined cluster %s slot %d\n", str, cinfo->slot_number); in join()
924 snprintf(str, 64, "bitmap%04d", cinfo->slot_number - 1); in join()
925 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); in join()
926 if (!cinfo->bitmap_lockres) { in join()
930 if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) { in join()
936 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); in join()
937 if (!cinfo->resync_lockres) { in join()
944 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in join()
945 md_unregister_thread(&cinfo->recovery_thread); in join()
946 md_unregister_thread(&cinfo->recv_thread); in join()
947 lockres_free(cinfo->message_lockres); in join()
948 lockres_free(cinfo->token_lockres); in join()
949 lockres_free(cinfo->ack_lockres); in join()
950 lockres_free(cinfo->no_new_dev_lockres); in join()
951 lockres_free(cinfo->resync_lockres); in join()
952 lockres_free(cinfo->bitmap_lockres); in join()
953 if (cinfo->lockspace) in join()
954 dlm_release_lockspace(cinfo->lockspace, 2); in join()
956 kfree(cinfo); in join()
962 struct md_cluster_info *cinfo = mddev->cluster_info; in load_bitmaps() local
967 set_bit(MD_CLUSTER_ALREADY_IN_CLUSTER, &cinfo->state); in load_bitmaps()
969 if (test_and_clear_bit(MD_CLUSTER_PENDING_RECV_EVENT, &cinfo->state)) in load_bitmaps()
970 md_wakeup_thread(cinfo->recv_thread); in load_bitmaps()
975 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_bitmap() local
980 err = sendmsg(cinfo, &cmsg, 1); in resync_bitmap()
989 struct md_cluster_info *cinfo = mddev->cluster_info; in leave() local
991 if (!cinfo) in leave()
997 if (cinfo->slot_number > 0 && mddev->recovery_cp != MaxSector) in leave()
1000 set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in leave()
1001 md_unregister_thread(&cinfo->recovery_thread); in leave()
1002 md_unregister_thread(&cinfo->recv_thread); in leave()
1003 lockres_free(cinfo->message_lockres); in leave()
1004 lockres_free(cinfo->token_lockres); in leave()
1005 lockres_free(cinfo->ack_lockres); in leave()
1006 lockres_free(cinfo->no_new_dev_lockres); in leave()
1007 lockres_free(cinfo->resync_lockres); in leave()
1008 lockres_free(cinfo->bitmap_lockres); in leave()
1010 dlm_release_lockspace(cinfo->lockspace, 2); in leave()
1011 kfree(cinfo); in leave()
1021 struct md_cluster_info *cinfo = mddev->cluster_info; in slot_number() local
1023 return cinfo->slot_number - 1; in slot_number()
1034 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_start() local
1042 &cinfo->state); in metadata_update_start()
1046 wait_event(cinfo->wait, in metadata_update_start()
1047 !test_and_set_bit(MD_CLUSTER_SEND_LOCK, &cinfo->state) || in metadata_update_start()
1048 test_and_clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state)); in metadata_update_start()
1051 if (cinfo->token_lockres->mode == DLM_LOCK_EX) { in metadata_update_start()
1052 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1056 ret = lock_token(cinfo, 1); in metadata_update_start()
1057 clear_bit_unlock(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state); in metadata_update_start()
1063 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_finish() local
1080 ret = __sendmsg(cinfo, &cmsg); in metadata_update_finish()
1083 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_finish()
1084 unlock_comm(cinfo); in metadata_update_finish()
1090 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_cancel() local
1091 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in metadata_update_cancel()
1092 unlock_comm(cinfo); in metadata_update_cancel()
1167 struct md_cluster_info *cinfo = mddev->cluster_info; in update_size() local
1174 lock_comm(cinfo, 1); in update_size()
1190 ret = __sendmsg(cinfo, &cmsg); in update_size()
1194 unlock_comm(cinfo); in update_size()
1199 unlock_comm(cinfo); in update_size()
1211 ret = __sendmsg(cinfo, &cmsg); in update_size()
1222 ret = __sendmsg(cinfo, &cmsg); in update_size()
1227 unlock_comm(cinfo); in update_size()
1232 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_start() local
1233 return dlm_lock_sync_interruptible(cinfo->resync_lockres, DLM_LOCK_EX, mddev); in resync_start()
1238 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_update() local
1244 memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(struct resync_info)); in resync_info_update()
1249 add_resync_info(cinfo->bitmap_lockres, lo, hi); in resync_info_update()
1251 dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW); in resync_info_update()
1261 return sendmsg(cinfo, &cmsg, 1); in resync_info_update()
1263 return sendmsg(cinfo, &cmsg, 0); in resync_info_update()
1268 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_finish() local
1269 dlm_unlock_sync(cinfo->resync_lockres); in resync_finish()
1276 struct md_cluster_info *cinfo = mddev->cluster_info; in area_resyncing() local
1281 test_bit(MD_CLUSTER_SUSPEND_READ_BALANCING, &cinfo->state)) in area_resyncing()
1284 spin_lock_irq(&cinfo->suspend_lock); in area_resyncing()
1285 if (list_empty(&cinfo->suspend_list)) in area_resyncing()
1287 list_for_each_entry(s, &cinfo->suspend_list, list) in area_resyncing()
1293 spin_unlock_irq(&cinfo->suspend_lock); in area_resyncing()
1303 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk() local
1313 lock_comm(cinfo, 1); in add_new_disk()
1314 ret = __sendmsg(cinfo, &cmsg); in add_new_disk()
1316 unlock_comm(cinfo); in add_new_disk()
1319 cinfo->no_new_dev_lockres->flags |= DLM_LKF_NOQUEUE; in add_new_disk()
1320 ret = dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_EX); in add_new_disk()
1321 cinfo->no_new_dev_lockres->flags &= ~DLM_LKF_NOQUEUE; in add_new_disk()
1326 unlock_comm(cinfo); in add_new_disk()
1328 dlm_lock_sync(cinfo->no_new_dev_lockres, DLM_LOCK_CR); in add_new_disk()
1341 set_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk()
1342 wake_up(&cinfo->wait); in add_new_disk()
1349 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk_cancel() local
1350 clear_bit(MD_CLUSTER_SEND_LOCKED_ALREADY, &cinfo->state); in add_new_disk_cancel()
1351 unlock_comm(cinfo); in add_new_disk_cancel()
1356 struct md_cluster_info *cinfo = mddev->cluster_info; in new_disk_ack() local
1358 if (!test_bit(MD_CLUSTER_WAITING_FOR_NEWDISK, &cinfo->state)) { in new_disk_ack()
1364 dlm_unlock_sync(cinfo->no_new_dev_lockres); in new_disk_ack()
1365 complete(&cinfo->newdisk_completion); in new_disk_ack()
1372 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_disk() local
1375 return sendmsg(cinfo, &cmsg, 1); in remove_disk()
1382 struct md_cluster_info *cinfo = mddev->cluster_info; in lock_all_bitmaps() local
1384 cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) * in lock_all_bitmaps()
1387 if (!cinfo->other_bitmap_lockres) { in lock_all_bitmaps()
1399 cinfo->other_bitmap_lockres[i] = lockres_init(mddev, str, NULL, 1); in lock_all_bitmaps()
1400 if (!cinfo->other_bitmap_lockres[i]) in lock_all_bitmaps()
1403 cinfo->other_bitmap_lockres[i]->flags |= DLM_LKF_NOQUEUE; in lock_all_bitmaps()
1404 ret = dlm_lock_sync(cinfo->other_bitmap_lockres[i], DLM_LOCK_PW); in lock_all_bitmaps()
1415 struct md_cluster_info *cinfo = mddev->cluster_info; in unlock_all_bitmaps() local
1419 if (cinfo->other_bitmap_lockres) { in unlock_all_bitmaps()
1421 if (cinfo->other_bitmap_lockres[i]) { in unlock_all_bitmaps()
1422 lockres_free(cinfo->other_bitmap_lockres[i]); in unlock_all_bitmaps()
1425 kfree(cinfo->other_bitmap_lockres); in unlock_all_bitmaps()
1435 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_bitmaps() local
1439 err = sendmsg(cinfo, &cmsg, 1); in gather_bitmaps()
1444 if (sn == (cinfo->slot_number - 1)) in gather_bitmaps()