4462 * specified delay. If the timeout expires, we
4463 * will cancel any pending request.
4464 *
4465 * If some reset have occurred while establishing
4466 * the connection, we already have a timeout armed
4467 * and in that case we don't need to arm a new one.
4468 *
4469 * The same rule applies when there are multiple vds'.
4470 * If either a connection cannot be established or
4471 * the handshake times out, the connection thread will
4472 * try another server. The 'ctimeout' will report
4473 * back an error after it expires irrespective of
4474 * whether the vdisk is trying to connect to just
4475 * one or multiple servers.
4476 */
4477 ctimeout = (vdc_timeout != 0)?
4478 vdc_timeout : vdcp->curr_server->ctimeout;
4479
4480 if (ctimeout != 0 && tmid == 0) {
4481 tmid = timeout(vdc_connection_timeout, vdcp,
4482 ctimeout * drv_usectohz(MICROSEC));
4483 }
4484
4485 /* Switch to STATE_DETACH if drv is detaching */
4486 if (vdcp->lifecycle == VDC_LC_DETACHING) {
4487 vdcp->state = VDC_STATE_DETACH;
4488 break;
4489 }
4490
4491 /* Check if the timeout has been reached */
4492 if (vdcp->ctimeout_reached) {
4493 ASSERT(tmid != 0);
4494 tmid = 0;
4495 vdcp->state = VDC_STATE_FAILED;
4496 break;
4497 }
4498
4499 /*
4500 * Switch to another server when we reach the limit of
4501 * the number of handshake per server or if we have done
4502 * an attribute negotiation.
4525 vdcp->state = VDC_STATE_INIT_WAITING;
4526 } else {
4527 vdcp->curr_server->svc_state =
4528 VDC_SERVICE_FAILED;
4529 vdc_print_svc_status(vdcp);
4530 }
4531 break;
4532
4533 case VDC_STATE_INIT_WAITING:
4534
4535 /* if channel is UP, start negotiation */
4536 if (vdcp->curr_server->ldc_state == LDC_UP) {
4537 vdcp->state = VDC_STATE_NEGOTIATE;
4538 break;
4539 }
4540
4541 /*
4542 * Wait for LDC_UP. If it times out and we have multiple
4543 * servers then we will retry using a different server.
4544 */
4545 ldcup_timeout = ddi_get_lbolt() + (vdc_ldcup_timeout *
4546 drv_usectohz(MICROSEC));
4547 status = cv_timedwait(&vdcp->initwait_cv, &vdcp->lock,
4548 ldcup_timeout);
4549 if (status == -1 &&
4550 vdcp->state == VDC_STATE_INIT_WAITING &&
4551 vdcp->curr_server->ldc_state != LDC_UP) {
4552 /* timed out & still waiting */
4553 vdcp->curr_server->svc_state =
4554 VDC_SERVICE_FAILED;
4555 vdc_print_svc_status(vdcp);
4556 vdcp->state = VDC_STATE_INIT;
4557 break;
4558 }
4559
4560 if (vdcp->state != VDC_STATE_INIT_WAITING) {
4561 DMSG(vdcp, 0,
4562 "state moved to %d out from under us...\n",
4563 vdcp->state);
4564 }
4565 break;
4566
|
4462 * specified delay. If the timeout expires, we
4463 * will cancel any pending request.
4464 *
4465 * If some reset have occurred while establishing
4466 * the connection, we already have a timeout armed
4467 * and in that case we don't need to arm a new one.
4468 *
4469 * The same rule applies when there are multiple vds'.
4470 * If either a connection cannot be established or
4471 * the handshake times out, the connection thread will
4472 * try another server. The 'ctimeout' will report
4473 * back an error after it expires irrespective of
4474 * whether the vdisk is trying to connect to just
4475 * one or multiple servers.
4476 */
4477 ctimeout = (vdc_timeout != 0)?
4478 vdc_timeout : vdcp->curr_server->ctimeout;
4479
4480 if (ctimeout != 0 && tmid == 0) {
4481 tmid = timeout(vdc_connection_timeout, vdcp,
4482 drv_sectohz(ctimeout));
4483 }
4484
4485 /* Switch to STATE_DETACH if drv is detaching */
4486 if (vdcp->lifecycle == VDC_LC_DETACHING) {
4487 vdcp->state = VDC_STATE_DETACH;
4488 break;
4489 }
4490
4491 /* Check if the timeout has been reached */
4492 if (vdcp->ctimeout_reached) {
4493 ASSERT(tmid != 0);
4494 tmid = 0;
4495 vdcp->state = VDC_STATE_FAILED;
4496 break;
4497 }
4498
4499 /*
4500 * Switch to another server when we reach the limit of
4501 * the number of handshake per server or if we have done
4502 * an attribute negotiation.
4525 vdcp->state = VDC_STATE_INIT_WAITING;
4526 } else {
4527 vdcp->curr_server->svc_state =
4528 VDC_SERVICE_FAILED;
4529 vdc_print_svc_status(vdcp);
4530 }
4531 break;
4532
4533 case VDC_STATE_INIT_WAITING:
4534
4535 /* if channel is UP, start negotiation */
4536 if (vdcp->curr_server->ldc_state == LDC_UP) {
4537 vdcp->state = VDC_STATE_NEGOTIATE;
4538 break;
4539 }
4540
4541 /*
4542 * Wait for LDC_UP. If it times out and we have multiple
4543 * servers then we will retry using a different server.
4544 */
4545 ldcup_timeout = ddi_get_lbolt() + drv_sectohz(vdc_ldcup_timeout);
4546 status = cv_timedwait(&vdcp->initwait_cv, &vdcp->lock,
4547 ldcup_timeout);
4548 if (status == -1 &&
4549 vdcp->state == VDC_STATE_INIT_WAITING &&
4550 vdcp->curr_server->ldc_state != LDC_UP) {
4551 /* timed out & still waiting */
4552 vdcp->curr_server->svc_state =
4553 VDC_SERVICE_FAILED;
4554 vdc_print_svc_status(vdcp);
4555 vdcp->state = VDC_STATE_INIT;
4556 break;
4557 }
4558
4559 if (vdcp->state != VDC_STATE_INIT_WAITING) {
4560 DMSG(vdcp, 0,
4561 "state moved to %d out from under us...\n",
4562 vdcp->state);
4563 }
4564 break;
4565
|