Lines Matching refs:mddev
27 struct mddev *mddev; /* pointing back to mddev. */ member
61 struct mddev *mddev; /* the md device which md_cluster_info belongs to */ member
150 struct mddev *mddev) in dlm_lock_sync_interruptible() argument
162 || test_bit(MD_CLOSING, &mddev->flags)); in dlm_lock_sync_interruptible()
183 static struct dlm_lock_resource *lockres_init(struct mddev *mddev, in lockres_init() argument
188 struct md_cluster_info *cinfo = mddev->cluster_info; in lockres_init()
196 res->mddev = mddev; in lockres_init()
268 static int read_resync_info(struct mddev *mddev, in read_resync_info() argument
272 struct md_cluster_info *cinfo = mddev->cluster_info; in read_resync_info()
288 struct mddev *mddev = thread->mddev; in recover_bitmaps() local
289 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_bitmaps()
299 bm_lockres = lockres_init(mddev, str, NULL, 1); in recover_bitmaps()
305 ret = dlm_lock_sync_interruptible(bm_lockres, DLM_LOCK_PW, mddev); in recover_bitmaps()
311 ret = md_bitmap_copy_from_slot(mddev, slot, &lo, &hi, true); in recover_bitmaps()
325 if (test_bit(MD_RESYNCING_REMOTE, &mddev->recovery) && in recover_bitmaps()
326 test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && in recover_bitmaps()
327 mddev->reshape_position != MaxSector) in recover_bitmaps()
328 md_wakeup_thread(mddev->sync_thread); in recover_bitmaps()
331 if (lo < mddev->recovery_cp) in recover_bitmaps()
332 mddev->recovery_cp = lo; in recover_bitmaps()
335 if (mddev->recovery_cp != MaxSector) { in recover_bitmaps()
341 &mddev->recovery); in recover_bitmaps()
342 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in recover_bitmaps()
343 md_wakeup_thread(mddev->thread); in recover_bitmaps()
354 struct mddev *mddev = arg; in recover_prep() local
355 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_prep()
359 static void __recover_slot(struct mddev *mddev, int slot) in __recover_slot() argument
361 struct md_cluster_info *cinfo = mddev->cluster_info; in __recover_slot()
366 mddev, "recover"); in __recover_slot()
377 struct mddev *mddev = arg; in recover_slot() local
378 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_slot()
381 mddev->bitmap_info.cluster_name, in recover_slot()
386 __recover_slot(mddev, slot->slot - 1); in recover_slot()
393 struct mddev *mddev = arg; in recover_done() local
394 struct md_cluster_info *cinfo = mddev->cluster_info; in recover_done()
422 struct md_cluster_info *cinfo = res->mddev->cluster_info; in ack_bast()
432 static void remove_suspend_info(struct mddev *mddev, int slot) in remove_suspend_info() argument
434 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_suspend_info()
435 mddev->pers->quiesce(mddev, 1); in remove_suspend_info()
440 mddev->pers->quiesce(mddev, 0); in remove_suspend_info()
443 static void process_suspend_info(struct mddev *mddev, in process_suspend_info() argument
446 struct md_cluster_info *cinfo = mddev->cluster_info; in process_suspend_info()
455 clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery); in process_suspend_info()
456 remove_suspend_info(mddev, slot); in process_suspend_info()
457 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in process_suspend_info()
458 md_wakeup_thread(mddev->thread); in process_suspend_info()
462 rdev_for_each(rdev, mddev) in process_suspend_info()
490 md_bitmap_sync_with_cluster(mddev, cinfo->sync_low, in process_suspend_info()
495 mddev->pers->quiesce(mddev, 1); in process_suspend_info()
501 mddev->pers->quiesce(mddev, 0); in process_suspend_info()
504 static void process_add_new_disk(struct mddev *mddev, struct cluster_msg *cmsg) in process_add_new_disk() argument
507 struct md_cluster_info *cinfo = mddev->cluster_info; in process_add_new_disk()
519 kobject_uevent_env(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE, envp); in process_add_new_disk()
526 static void process_metadata_update(struct mddev *mddev, struct cluster_msg *msg) in process_metadata_update() argument
529 struct md_cluster_info *cinfo = mddev->cluster_info; in process_metadata_update()
530 mddev->good_device_nr = le32_to_cpu(msg->raid_slot); in process_metadata_update()
533 wait_event(mddev->thread->wqueue, in process_metadata_update()
534 (got_lock = mddev_trylock(mddev)) || in process_metadata_update()
536 md_reload_sb(mddev, mddev->good_device_nr); in process_metadata_update()
538 mddev_unlock(mddev); in process_metadata_update()
541 static void process_remove_disk(struct mddev *mddev, struct cluster_msg *msg) in process_remove_disk() argument
546 rdev = md_find_rdev_nr_rcu(mddev, le32_to_cpu(msg->raid_slot)); in process_remove_disk()
549 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in process_remove_disk()
550 md_wakeup_thread(mddev->thread); in process_remove_disk()
558 static void process_readd_disk(struct mddev *mddev, struct cluster_msg *msg) in process_readd_disk() argument
563 rdev = md_find_rdev_nr_rcu(mddev, le32_to_cpu(msg->raid_slot)); in process_readd_disk()
572 static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) in process_recvd_msg() argument
576 if (WARN(mddev->cluster_info->slot_number - 1 == le32_to_cpu(msg->slot), in process_recvd_msg()
581 process_metadata_update(mddev, msg); in process_recvd_msg()
584 set_capacity_and_notify(mddev->gendisk, mddev->array_sectors); in process_recvd_msg()
587 set_bit(MD_RESYNCING_REMOTE, &mddev->recovery); in process_recvd_msg()
588 process_suspend_info(mddev, le32_to_cpu(msg->slot), in process_recvd_msg()
593 process_add_new_disk(mddev, msg); in process_recvd_msg()
596 process_remove_disk(mddev, msg); in process_recvd_msg()
599 process_readd_disk(mddev, msg); in process_recvd_msg()
602 __recover_slot(mddev, le32_to_cpu(msg->slot)); in process_recvd_msg()
605 if (le64_to_cpu(msg->high) != mddev->pers->size(mddev, 0, 0)) in process_recvd_msg()
606 ret = md_bitmap_resize(mddev->bitmap, in process_recvd_msg()
622 struct md_cluster_info *cinfo = thread->mddev->cluster_info; in recv_daemon()
638 ret = process_recvd_msg(thread->mddev, &msg); in recv_daemon()
687 struct mddev *mddev = cinfo->mddev; in lock_comm() local
700 md_wakeup_thread(mddev->thread); in lock_comm()
797 static int gather_all_resync_info(struct mddev *mddev, int total_slots) in gather_all_resync_info() argument
799 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_all_resync_info()
809 bm_lockres = lockres_init(mddev, str, NULL, 1); in gather_all_resync_info()
820 if (read_resync_info(mddev, bm_lockres)) { in gather_all_resync_info()
838 ret = md_bitmap_copy_from_slot(mddev, i, &lo, &hi, false); in gather_all_resync_info()
844 if ((hi > 0) && (lo < mddev->recovery_cp)) { in gather_all_resync_info()
845 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in gather_all_resync_info()
846 mddev->recovery_cp = lo; in gather_all_resync_info()
847 md_check_recovery(mddev); in gather_all_resync_info()
856 static int join(struct mddev *mddev, int nodes) in join() argument
873 mddev->cluster_info = cinfo; in join()
874 cinfo->mddev = mddev; in join()
877 sprintf(str, "%pU", mddev->uuid); in join()
878 ret = dlm_new_lockspace(str, mddev->bitmap_info.cluster_name, in join()
879 0, LVB_SIZE, &md_ls_ops, mddev, in join()
892 cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv"); in join()
897 cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1); in join()
900 cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0); in join()
903 cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0); in join()
913 cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0); in join()
930 cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1); in join()
941 cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0); in join()
960 mddev->cluster_info = NULL; in join()
965 static void load_bitmaps(struct mddev *mddev, int total_slots) in load_bitmaps() argument
967 struct md_cluster_info *cinfo = mddev->cluster_info; in load_bitmaps()
970 if (gather_all_resync_info(mddev, total_slots)) in load_bitmaps()
978 static void resync_bitmap(struct mddev *mddev) in resync_bitmap() argument
980 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_bitmap()
991 static void unlock_all_bitmaps(struct mddev *mddev);
992 static int leave(struct mddev *mddev) in leave() argument
994 struct md_cluster_info *cinfo = mddev->cluster_info; in leave()
1007 if ((cinfo->slot_number > 0 && mddev->recovery_cp != MaxSector) || in leave()
1008 (mddev->reshape_position != MaxSector && in leave()
1009 test_bit(MD_CLOSING, &mddev->flags))) in leave()
1010 resync_bitmap(mddev); in leave()
1021 unlock_all_bitmaps(mddev); in leave()
1031 static int slot_number(struct mddev *mddev) in slot_number() argument
1033 struct md_cluster_info *cinfo = mddev->cluster_info; in slot_number()
1044 static int metadata_update_start(struct mddev *mddev) in metadata_update_start() argument
1046 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_start()
1056 md_wakeup_thread(mddev->thread); in metadata_update_start()
1073 static int metadata_update_finish(struct mddev *mddev) in metadata_update_finish() argument
1075 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_finish()
1085 rdev_for_each(rdev, mddev) in metadata_update_finish()
1100 static void metadata_update_cancel(struct mddev *mddev) in metadata_update_cancel() argument
1102 struct md_cluster_info *cinfo = mddev->cluster_info; in metadata_update_cancel()
1107 static int update_bitmap_size(struct mddev *mddev, sector_t size) in update_bitmap_size() argument
1109 struct md_cluster_info *cinfo = mddev->cluster_info; in update_bitmap_size()
1122 static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize) in resize_bitmaps() argument
1127 struct bitmap *bitmap = mddev->bitmap; in resize_bitmaps()
1135 rv = update_bitmap_size(mddev, newsize); in resize_bitmaps()
1139 for (i = 0; i < mddev->bitmap_info.nodes; i++) { in resize_bitmaps()
1140 if (i == md_cluster_ops->slot_number(mddev)) in resize_bitmaps()
1143 bitmap = get_bitmap_from_slot(mddev, i); in resize_bitmaps()
1156 bm_lockres = lockres_init(mddev, str, NULL, 1); in resize_bitmaps()
1179 update_bitmap_size(mddev, oldsize); in resize_bitmaps()
1186 static int cluster_check_sync_size(struct mddev *mddev) in cluster_check_sync_size() argument
1191 int node_num = mddev->bitmap_info.nodes; in cluster_check_sync_size()
1192 int current_slot = md_cluster_ops->slot_number(mddev); in cluster_check_sync_size()
1193 struct bitmap *bitmap = mddev->bitmap; in cluster_check_sync_size()
1205 bitmap = get_bitmap_from_slot(mddev, i); in cluster_check_sync_size()
1216 bm_lockres = lockres_init(mddev, str, NULL, 1); in cluster_check_sync_size()
1253 static void update_size(struct mddev *mddev, sector_t old_dev_sectors) in update_size() argument
1255 struct md_cluster_info *cinfo = mddev->cluster_info; in update_size()
1261 md_update_sb(mddev, 1); in update_size()
1269 rdev_for_each(rdev, mddev) in update_size()
1299 if (cluster_check_sync_size(mddev) == 0) { in update_size()
1306 set_capacity_and_notify(mddev->gendisk, mddev->array_sectors); in update_size()
1309 ret = mddev->pers->resize(mddev, old_dev_sectors); in update_size()
1318 static int resync_start(struct mddev *mddev) in resync_start() argument
1320 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_start()
1321 return dlm_lock_sync_interruptible(cinfo->resync_lockres, DLM_LOCK_EX, mddev); in resync_start()
1324 static void resync_info_get(struct mddev *mddev, sector_t *lo, sector_t *hi) in resync_info_get() argument
1326 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_get()
1334 static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi) in resync_info_update() argument
1336 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_info_update()
1364 static int resync_finish(struct mddev *mddev) in resync_finish() argument
1366 struct md_cluster_info *cinfo = mddev->cluster_info; in resync_finish()
1369 clear_bit(MD_RESYNCING_REMOTE, &mddev->recovery); in resync_finish()
1375 if (!test_bit(MD_CLOSING, &mddev->flags)) in resync_finish()
1376 ret = resync_info_update(mddev, 0, 0); in resync_finish()
1381 static int area_resyncing(struct mddev *mddev, int direction, in area_resyncing() argument
1384 struct md_cluster_info *cinfo = mddev->cluster_info; in area_resyncing()
1402 static int add_new_disk(struct mddev *mddev, struct md_rdev *rdev) in add_new_disk() argument
1404 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk()
1449 static void add_new_disk_cancel(struct mddev *mddev) in add_new_disk_cancel() argument
1451 struct md_cluster_info *cinfo = mddev->cluster_info; in add_new_disk_cancel()
1456 static int new_disk_ack(struct mddev *mddev, bool ack) in new_disk_ack() argument
1458 struct md_cluster_info *cinfo = mddev->cluster_info; in new_disk_ack()
1461 pr_warn("md-cluster(%s): Spurious cluster confirmation\n", mdname(mddev)); in new_disk_ack()
1471 static int remove_disk(struct mddev *mddev, struct md_rdev *rdev) in remove_disk() argument
1474 struct md_cluster_info *cinfo = mddev->cluster_info; in remove_disk()
1480 static int lock_all_bitmaps(struct mddev *mddev) in lock_all_bitmaps() argument
1484 struct md_cluster_info *cinfo = mddev->cluster_info; in lock_all_bitmaps()
1487 kcalloc(mddev->bitmap_info.nodes - 1, in lock_all_bitmaps()
1494 my_slot = slot_number(mddev); in lock_all_bitmaps()
1495 for (slot = 0; slot < mddev->bitmap_info.nodes; slot++) { in lock_all_bitmaps()
1501 cinfo->other_bitmap_lockres[i] = lockres_init(mddev, str, NULL, 1); in lock_all_bitmaps()
1515 static void unlock_all_bitmaps(struct mddev *mddev) in unlock_all_bitmaps() argument
1517 struct md_cluster_info *cinfo = mddev->cluster_info; in unlock_all_bitmaps()
1522 for (i = 0; i < mddev->bitmap_info.nodes - 1; i++) { in unlock_all_bitmaps()
1537 struct mddev *mddev = rdev->mddev; in gather_bitmaps() local
1538 struct md_cluster_info *cinfo = mddev->cluster_info; in gather_bitmaps()
1546 for (sn = 0; sn < mddev->bitmap_info.nodes; sn++) { in gather_bitmaps()
1549 err = md_bitmap_copy_from_slot(mddev, sn, &lo, &hi, false); in gather_bitmaps()
1554 if ((hi > 0) && (lo < mddev->recovery_cp)) in gather_bitmaps()
1555 mddev->recovery_cp = lo; in gather_bitmaps()