Print this page
XXXX introduce drv_sectohz


 368 
 369         /* set up as alua participating port */
 370         stmf_set_port_alua(lport);
 371 
 372         SRPT_DPRINTF_L3("stp_alloc_port, register STMF LPORT");
 373 
 374 retry_registration:
 375         status = stmf_register_local_port(lport);
 376         if (status == STMF_SUCCESS) {
 377                 SRPT_DPRINTF_L3("stp_alloc_port, LPORT successfully"
 378                     " registered");
 379                 return (tgt);
 380         }
 381 
 382         if (status == STMF_BUSY) {
 383                 /*
 384                  * This is only done on an administrative thread of
 385                  * execution so it is ok to take a while.
 386                  */
 387                 SRPT_DPRINTF_L3("stp_alloc_port, delaying");
 388                 delay(2 * drv_usectohz(1000000));
 389                 goto retry_registration;
 390         }
 391         SRPT_DPRINTF_L1("stp_alloc_port, STMF register local port err(0x%llx)",
 392             (u_longlong_t)status);
 393 
 394         SRPT_DPRINTF_L3("stp_alloc_port, free STMF local port");
 395         cv_destroy(&tgt->tp_offline_complete);
 396         mutex_destroy(&tgt->tp_ch_list_lock);
 397         mutex_destroy(&tgt->tp_lock);
 398         if (tgt->tp_hw_port) {
 399                 kmem_free(tgt->tp_hw_port,
 400                     sizeof (srpt_hw_port_t) * tgt->tp_nports);
 401         }
 402         if (tgt->tp_scsi_devid) {
 403                 srpt_stp_free_scsi_devid_desc(tgt->tp_scsi_devid);
 404         }
 405 
 406         stmf_free(lport);
 407 
 408         return (NULL);


 479         status = stmf_ctl(STMF_CMD_LPORT_OFFLINE, tgt->tp_lport, &cstatus);
 480 
 481         /*
 482          * Wait for asynchronous target off-line operation
 483          * to complete and then deregister the target
 484          * port.
 485          */
 486         mutex_enter(&tgt->tp_lock);
 487         while (tgt->tp_state != SRPT_TGT_STATE_OFFLINE) {
 488                 cv_wait(&tgt->tp_offline_complete, &tgt->tp_lock);
 489         }
 490         mutex_exit(&tgt->tp_lock);
 491 
 492         SRPT_DPRINTF_L3("stp_destroy_port: IOC (0x%016llx) Target"
 493             " SRP off-line complete", (u_longlong_t)guid);
 494 
 495         /* loop waiting for all I/O to drain */
 496         for (;;) {
 497                 status = stmf_deregister_local_port(tgt->tp_lport);
 498                 if (status == STMF_BUSY) {
 499                         delay(drv_usectohz(1000000));
 500                 } else {
 501                         break;
 502                 }
 503         }
 504 
 505         if (status == STMF_SUCCESS) {
 506                 SRPT_DPRINTF_L3("stp_destroy_port, LPORT de-register"
 507                     " complete");
 508         } else {
 509                 /*
 510                  * Something other than a BUSY error, this should not happen.
 511                  */
 512                 SRPT_DPRINTF_L1(
 513                     "stp_destroy_port, de-register STMF error(0x%llx)",
 514                     (u_longlong_t)status);
 515         }
 516 
 517         return (status);
 518 }
 519 




 368 
 369         /* set up as alua participating port */
 370         stmf_set_port_alua(lport);
 371 
 372         SRPT_DPRINTF_L3("stp_alloc_port, register STMF LPORT");
 373 
 374 retry_registration:
 375         status = stmf_register_local_port(lport);
 376         if (status == STMF_SUCCESS) {
 377                 SRPT_DPRINTF_L3("stp_alloc_port, LPORT successfully"
 378                     " registered");
 379                 return (tgt);
 380         }
 381 
 382         if (status == STMF_BUSY) {
 383                 /*
 384                  * This is only done on an administrative thread of
 385                  * execution so it is ok to take a while.
 386                  */
 387                 SRPT_DPRINTF_L3("stp_alloc_port, delaying");
 388                 delay(drv_sectohz(2));
 389                 goto retry_registration;
 390         }
 391         SRPT_DPRINTF_L1("stp_alloc_port, STMF register local port err(0x%llx)",
 392             (u_longlong_t)status);
 393 
 394         SRPT_DPRINTF_L3("stp_alloc_port, free STMF local port");
 395         cv_destroy(&tgt->tp_offline_complete);
 396         mutex_destroy(&tgt->tp_ch_list_lock);
 397         mutex_destroy(&tgt->tp_lock);
 398         if (tgt->tp_hw_port) {
 399                 kmem_free(tgt->tp_hw_port,
 400                     sizeof (srpt_hw_port_t) * tgt->tp_nports);
 401         }
 402         if (tgt->tp_scsi_devid) {
 403                 srpt_stp_free_scsi_devid_desc(tgt->tp_scsi_devid);
 404         }
 405 
 406         stmf_free(lport);
 407 
 408         return (NULL);


 479         status = stmf_ctl(STMF_CMD_LPORT_OFFLINE, tgt->tp_lport, &cstatus);
 480 
 481         /*
 482          * Wait for asynchronous target off-line operation
 483          * to complete and then deregister the target
 484          * port.
 485          */
 486         mutex_enter(&tgt->tp_lock);
 487         while (tgt->tp_state != SRPT_TGT_STATE_OFFLINE) {
 488                 cv_wait(&tgt->tp_offline_complete, &tgt->tp_lock);
 489         }
 490         mutex_exit(&tgt->tp_lock);
 491 
 492         SRPT_DPRINTF_L3("stp_destroy_port: IOC (0x%016llx) Target"
 493             " SRP off-line complete", (u_longlong_t)guid);
 494 
 495         /* loop waiting for all I/O to drain */
 496         for (;;) {
 497                 status = stmf_deregister_local_port(tgt->tp_lport);
 498                 if (status == STMF_BUSY) {
 499                         delay(drv_sectohz(1));
 500                 } else {
 501                         break;
 502                 }
 503         }
 504 
 505         if (status == STMF_SUCCESS) {
 506                 SRPT_DPRINTF_L3("stp_destroy_port, LPORT de-register"
 507                     " complete");
 508         } else {
 509                 /*
 510                  * Something other than a BUSY error, this should not happen.
 511                  */
 512                 SRPT_DPRINTF_L1(
 513                     "stp_destroy_port, de-register STMF error(0x%llx)",
 514                     (u_longlong_t)status);
 515         }
 516 
 517         return (status);
 518 }
 519