static int gather_all_resync_info(struct mddev *mddev, int total_slots) { struct md_cluster_info *cinfo = mddev->cluster_info; int i, ret = 0; struct dlm_lock_resource *bm_lockres; struct suspend_info *s; char str[64]; for (i = 0; i < total_slots; i++) { memset(str, '\0', 64); snprintf(str, 64, "bitmap%04d", i); bm_lockres = lockres_init(mddev, str, NULL, 1); if (!bm_lockres) return -ENOMEM; if (i == (cinfo->slot_number - 1)) continue; bm_lockres->flags |= DLM_LKF_NOQUEUE; ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); if (ret == -EAGAIN) { memset(bm_lockres->lksb.sb_lvbptr, '\0', LVB_SIZE); s = read_resync_info(mddev, bm_lockres); if (s) { pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n", __func__, __LINE__, (unsigned long long) s->lo, (unsigned long long) s->hi, i); spin_lock_irq(&cinfo->suspend_lock); s->slot = i; list_add(&s->list, &cinfo->suspend_list); spin_unlock_irq(&cinfo->suspend_lock); } ret = 0; lockres_free(bm_lockres); continue; } if (ret) goto out; /* TODO: Read the disk bitmap sb and check if it needs recovery */ dlm_unlock_sync(bm_lockres); lockres_free(bm_lockres); } out: return ret; }
static int gather_all_resync_info(struct mddev *mddev, int total_slots) { struct md_cluster_info *cinfo = mddev->cluster_info; int i, ret = 0; struct dlm_lock_resource *bm_lockres; struct suspend_info *s; char str[64]; sector_t lo, hi; for (i = 0; i < total_slots; i++) { memset(str, '\0', 64); snprintf(str, 64, "bitmap%04d", i); bm_lockres = lockres_init(mddev, str, NULL, 1); if (!bm_lockres) return -ENOMEM; if (i == (cinfo->slot_number - 1)) continue; bm_lockres->flags |= DLM_LKF_NOQUEUE; ret = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); if (ret == -EAGAIN) { memset(bm_lockres->lksb.sb_lvbptr, '\0', LVB_SIZE); s = read_resync_info(mddev, bm_lockres); if (s) { pr_info("%s:%d Resync[%llu..%llu] in progress on %d\n", __func__, __LINE__, (unsigned long long) s->lo, (unsigned long long) s->hi, i); spin_lock_irq(&cinfo->suspend_lock); s->slot = i; list_add(&s->list, &cinfo->suspend_list); spin_unlock_irq(&cinfo->suspend_lock); } ret = 0; lockres_free(bm_lockres); continue; } if (ret) { lockres_free(bm_lockres); goto out; } /* Read the disk bitmap sb and check if it needs recovery */ ret = bitmap_copy_from_slot(mddev, i, &lo, &hi, false); if (ret) { pr_warn("md-cluster: Could not gather bitmaps from slot %d", i); lockres_free(bm_lockres); continue; } if ((hi > 0) && (lo < mddev->recovery_cp)) { set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); mddev->recovery_cp = lo; md_check_recovery(mddev); } dlm_unlock_sync(bm_lockres); lockres_free(bm_lockres); } out: return ret; }