Print this page
XXXX introduce drv_sectohz


1457                 if (un->un_pwr_mgmt == ST_PWR_SUSPENDED) {
1458                         mutex_exit(ST_MUTEX);
1459                         return (DDI_FAILURE);
1460                 }
1461                 if (un->un_state != ST_STATE_CLOSED) {
1462                         mutex_exit(ST_MUTEX);
1463                         return (DDI_FAILURE);
1464                 }
1465 
1466                 /*
1467                  * Wait for all outstanding I/O's to complete
1468                  *
1469                  * we wait on both ncmds and the wait queue for times
1470                  * when we are flushing after persistent errors are
1471                  * flagged, which is when ncmds can be 0, and the
1472                  * queue can still have I/O's.  This way we preserve
1473                  * order of biodone's.
1474                  */
1475                 wait_cmds_complete = ddi_get_lbolt();
1476                 wait_cmds_complete +=
1477                     st_wait_cmds_complete * drv_usectohz(1000000);
1478                 while (un->un_ncmds || un->un_quef ||
1479                     (un->un_state == ST_STATE_RESOURCE_WAIT)) {
1480 
1481                         if (cv_timedwait(&un->un_tape_busy_cv, ST_MUTEX,
1482                             wait_cmds_complete) == -1) {
1483                                 /*
1484                                  * Time expired then cancel the command
1485                                  */
1486                                 if (st_reset(un, RESET_LUN) == 0) {
1487                                         if (un->un_last_throttle) {
1488                                                 un->un_throttle =
1489                                                     un->un_last_throttle;
1490                                         }
1491                                         mutex_exit(ST_MUTEX);
1492                                         return (DDI_FAILURE);
1493                                 } else {
1494                                         break;
1495                                 }
1496                         }
1497                 }


6478         ASSERT((bp->b_flags & B_DONE) == 0);
6479 
6480         /*
6481          * Don't send more than un_throttle commands to the HBA
6482          */
6483         if ((un->un_throttle <= 0) || (un->un_ncmds >= un->un_throttle)) {
6484                 /*
6485                  * if doing recovery we know there is outstanding commands.
6486                  */
6487                 if (bp != un->un_recov_buf) {
6488                         ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
6489                             "st_start returning throttle = %d or ncmds = %d\n",
6490                             un->un_throttle, un->un_ncmds);
6491                         if (un->un_ncmds == 0) {
6492                                 typedef void (*func)();
6493                                 func fnc = (func)st_runout;
6494 
6495                                 scsi_log(ST_DEVINFO, st_label, SCSI_DEBUG,
6496                                     "Sending delayed start to st_runout()\n");
6497                                 mutex_exit(ST_MUTEX);
6498                                 (void) timeout(fnc, un, drv_usectohz(1000000));
6499                                 mutex_enter(ST_MUTEX);
6500                         }
6501                         return;
6502                 }
6503         }
6504 
6505         /*
6506          * If the buf has no scsi_pkt call st_make_cmd() to get one and
6507          * build the command.
6508          */
6509         if (BP_PKT(bp) == NULL) {
6510                 ASSERT((bp->b_flags & B_DONE) == 0);
6511                 st_make_cmd(un, bp, st_runout);
6512                 ASSERT((bp->b_flags & B_DONE) == 0);
6513                 status = geterror(bp);
6514 
6515                 /*
6516                  * Some HBA's don't call bioerror() to set an error.
6517                  * And geterror() returns zero if B_ERROR is not set.
6518                  * So if we get zero we must check b_error.


17599 #endif
17600         kmem_free(current, sizeof (struct seq_mode));
17601 
17602         return (rval);
17603 }
17604 
17605 static int
17606 st_test_path_to_device(struct scsi_tape *un)
17607 {
17608         int rval = 0;
17609         int limit = st_retry_count;
17610 
17611         ST_FUNC(ST_DEVINFO, st_test_path_to_device);
17612 
17613         /*
17614          * XXX Newer drives may not RESEVATION CONFLICT a TUR.
17615          */
17616         do {
17617                 if (rval != 0) {
17618                         mutex_exit(ST_MUTEX);
17619                         delay(drv_usectohz(1000000));
17620                         mutex_enter(ST_MUTEX);
17621                 }
17622                 rval = st_rcmd(un, SCMD_TEST_UNIT_READY, 0, SYNC_CMD);
17623                 ST_RECOV(ST_DEVINFO, st_label, CE_NOTE,
17624                     "ping TUR returned 0x%x", rval);
17625                 limit--;
17626         } while (((rval == EACCES) || (rval == EBUSY)) && limit);
17627 
17628         if (un->un_status == KEY_NOT_READY || un->un_mediastate == MTIO_EJECTED)
17629                 rval = 0;
17630 
17631         return (rval);
17632 }
17633 
17634 /*
17635  * Does read position using recov_buf and doesn't update un_pos.
17636  * Does what ever kind of read position you want.
17637  */
17638 static int
17639 st_recovery_read_pos(struct scsi_tape *un, read_p_types type,




1457                 if (un->un_pwr_mgmt == ST_PWR_SUSPENDED) {
1458                         mutex_exit(ST_MUTEX);
1459                         return (DDI_FAILURE);
1460                 }
1461                 if (un->un_state != ST_STATE_CLOSED) {
1462                         mutex_exit(ST_MUTEX);
1463                         return (DDI_FAILURE);
1464                 }
1465 
1466                 /*
1467                  * Wait for all outstanding I/O's to complete
1468                  *
1469                  * we wait on both ncmds and the wait queue for times
1470                  * when we are flushing after persistent errors are
1471                  * flagged, which is when ncmds can be 0, and the
1472                  * queue can still have I/O's.  This way we preserve
1473                  * order of biodone's.
1474                  */
1475                 wait_cmds_complete = ddi_get_lbolt();
1476                 wait_cmds_complete +=
1477                     drv_sectohz(st_wait_cmds_complete);
1478                 while (un->un_ncmds || un->un_quef ||
1479                     (un->un_state == ST_STATE_RESOURCE_WAIT)) {
1480 
1481                         if (cv_timedwait(&un->un_tape_busy_cv, ST_MUTEX,
1482                             wait_cmds_complete) == -1) {
1483                                 /*
1484                                  * Time expired then cancel the command
1485                                  */
1486                                 if (st_reset(un, RESET_LUN) == 0) {
1487                                         if (un->un_last_throttle) {
1488                                                 un->un_throttle =
1489                                                     un->un_last_throttle;
1490                                         }
1491                                         mutex_exit(ST_MUTEX);
1492                                         return (DDI_FAILURE);
1493                                 } else {
1494                                         break;
1495                                 }
1496                         }
1497                 }


6478         ASSERT((bp->b_flags & B_DONE) == 0);
6479 
6480         /*
6481          * Don't send more than un_throttle commands to the HBA
6482          */
6483         if ((un->un_throttle <= 0) || (un->un_ncmds >= un->un_throttle)) {
6484                 /*
6485                  * if doing recovery we know there is outstanding commands.
6486                  */
6487                 if (bp != un->un_recov_buf) {
6488                         ST_DEBUG2(ST_DEVINFO, st_label, SCSI_DEBUG,
6489                             "st_start returning throttle = %d or ncmds = %d\n",
6490                             un->un_throttle, un->un_ncmds);
6491                         if (un->un_ncmds == 0) {
6492                                 typedef void (*func)();
6493                                 func fnc = (func)st_runout;
6494 
6495                                 scsi_log(ST_DEVINFO, st_label, SCSI_DEBUG,
6496                                     "Sending delayed start to st_runout()\n");
6497                                 mutex_exit(ST_MUTEX);
6498                                 (void) timeout(fnc, un, drv_sectohz(1));
6499                                 mutex_enter(ST_MUTEX);
6500                         }
6501                         return;
6502                 }
6503         }
6504 
6505         /*
6506          * If the buf has no scsi_pkt call st_make_cmd() to get one and
6507          * build the command.
6508          */
6509         if (BP_PKT(bp) == NULL) {
6510                 ASSERT((bp->b_flags & B_DONE) == 0);
6511                 st_make_cmd(un, bp, st_runout);
6512                 ASSERT((bp->b_flags & B_DONE) == 0);
6513                 status = geterror(bp);
6514 
6515                 /*
6516                  * Some HBA's don't call bioerror() to set an error.
6517                  * And geterror() returns zero if B_ERROR is not set.
6518                  * So if we get zero we must check b_error.


17599 #endif
17600         kmem_free(current, sizeof (struct seq_mode));
17601 
17602         return (rval);
17603 }
17604 
17605 static int
17606 st_test_path_to_device(struct scsi_tape *un)
17607 {
17608         int rval = 0;
17609         int limit = st_retry_count;
17610 
17611         ST_FUNC(ST_DEVINFO, st_test_path_to_device);
17612 
17613         /*
17614          * XXX Newer drives may not RESEVATION CONFLICT a TUR.
17615          */
17616         do {
17617                 if (rval != 0) {
17618                         mutex_exit(ST_MUTEX);
17619                         delay(drv_sectohz(1));
17620                         mutex_enter(ST_MUTEX);
17621                 }
17622                 rval = st_rcmd(un, SCMD_TEST_UNIT_READY, 0, SYNC_CMD);
17623                 ST_RECOV(ST_DEVINFO, st_label, CE_NOTE,
17624                     "ping TUR returned 0x%x", rval);
17625                 limit--;
17626         } while (((rval == EACCES) || (rval == EBUSY)) && limit);
17627 
17628         if (un->un_status == KEY_NOT_READY || un->un_mediastate == MTIO_EJECTED)
17629                 rval = 0;
17630 
17631         return (rval);
17632 }
17633 
17634 /*
17635  * Does read position using recov_buf and doesn't update un_pos.
17636  * Does what ever kind of read position you want.
17637  */
17638 static int
17639 st_recovery_read_pos(struct scsi_tape *un, read_p_types type,