Print this page
4779 vhci shouldn't abuse ddi_get_time(9f)
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c
          +++ new/usr/src/uts/common/io/scsi/adapters/scsi_vhci/scsi_vhci.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   */
       24 +/*
       25 + * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
       26 + */
  24   27  
  25   28  /*
  26   29   * Multiplexed I/O SCSI vHCI implementation
  27   30   */
  28   31  
  29   32  #include <sys/conf.h>
  30   33  #include <sys/file.h>
  31   34  #include <sys/ddi.h>
  32   35  #include <sys/sunddi.h>
  33   36  #include <sys/scsi/scsi.h>
↓ open down ↓ 2185 lines elided ↑ open up ↑
2219 2222          mdi_pathinfo_t          *npip = NULL;
2220 2223          scsi_vhci_priv_t        *svp = NULL;
2221 2224          struct scsi_device      *psd = NULL;
2222 2225          struct scsi_address     *address = NULL;
2223 2226          struct scsi_pkt         *pkt = NULL;
2224 2227          int                     rval = -1;
2225 2228          int                     pgr_sema_held = 0;
2226 2229          int                     held;
2227 2230          int                     mps_flag = MDI_SELECT_ONLINE_PATH;
2228 2231          struct scsi_vhci_lun    *vlun;
2229      -        time_t                  tnow;
2230 2232          int                     path_instance = 0;
2231 2233  
2232 2234          vlun = ADDR2VLUN(ap);
2233 2235          ASSERT(vlun != 0);
2234 2236  
2235 2237          if ((vpkt->vpkt_tgt_pkt->pkt_cdbp[0] == SCMD_PROUT) &&
2236 2238              (((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) ==
2237 2239              VHCI_PROUT_REGISTER) ||
2238 2240              ((vpkt->vpkt_tgt_pkt->pkt_cdbp[1] & 0x1f) ==
2239 2241              VHCI_PROUT_R_AND_IGNORE))) {
↓ open down ↓ 117 lines elided ↑ open up ↑
2357 2359                           * Path---" comment below).
2358 2360                           */
2359 2361                          VHCI_DEBUG(1, (CE_NOTE, NULL, "!%p in onlining "
2360 2362                              "state\n", (void *)cdip));
2361 2363                          pip = NULL;
2362 2364                          rval = mdi_select_path(cdip, vpkt->vpkt_tgt_init_bp,
2363 2365                              mps_flag, NULL, &pip);
2364 2366                          if ((rval != MDI_SUCCESS) || (pip == NULL)) {
2365 2367                                  if (vlun->svl_waiting_for_activepath == 0) {
2366 2368                                          vlun->svl_waiting_for_activepath = 1;
2367      -                                        vlun->svl_wfa_time = ddi_get_time();
     2369 +                                        vlun->svl_wfa_time = gethrtime();
2368 2370                                  }
2369 2371                                  mps_flag |= MDI_SELECT_STANDBY_PATH;
2370 2372                                  rval = mdi_select_path(cdip,
2371 2373                                      vpkt->vpkt_tgt_init_bp,
2372 2374                                      mps_flag, NULL, &pip);
2373 2375                                  if ((rval != MDI_SUCCESS) || (pip == NULL)) {
2374 2376                                          if (pgr_sema_held) {
2375 2377                                                  sema_v(&vlun->svl_pgr_sema);
2376 2378                                          }
2377 2379                                          return (TRAN_FATAL_ERROR);
↓ open down ↓ 11 lines elided ↑ open up ↑
2389 2391                  if ((pip == NULL) || (rval == MDI_NOPATH)) {
2390 2392                          while (vlun->svl_waiting_for_activepath) {
2391 2393                                  /*
2392 2394                                   * ---Waiting For Active Path---
2393 2395                                   * This device was discovered across a
2394 2396                                   * passive path; lets wait for a little
2395 2397                                   * bit, hopefully an active path will
2396 2398                                   * show up obviating the need for a
2397 2399                                   * failover
2398 2400                                   */
2399      -                                tnow = ddi_get_time();
2400      -                                if (tnow - vlun->svl_wfa_time >= 60) {
     2401 +                                if ((gethrtime() - vlun->svl_wfa_time) >=
     2402 +                                    (60 * NANOSEC)) {
2401 2403                                          vlun->svl_waiting_for_activepath = 0;
2402 2404                                  } else {
2403 2405                                          drv_usecwait(1000);
2404 2406                                          if (vlun->svl_waiting_for_activepath
2405 2407                                              == 0) {
2406 2408                                                  /*
2407 2409                                                   * an active path has come
2408 2410                                                   * online!
2409 2411                                                   */
2410 2412                                                  goto try_again;
↓ open down ↓ 1206 lines elided ↑ open up ↑
3617 3619                  kmem_free(path, MAXPATHLEN);
3618 3620                  swarg = kmem_alloc(sizeof (*swarg), KM_NOSLEEP);
3619 3621                  if (swarg == NULL) {
3620 3622                          VHCI_DEBUG(1, (CE_NOTE, NULL, "!vhci_handle_ext_fo: "
3621 3623                              "request packet allocation for %s failed....\n",
3622 3624                              vlun->svl_lun_wwn));
3623 3625                          VHCI_RELEASE_LUN(vlun);
3624 3626                          return (PKT_RETURN);
3625 3627                  }
3626 3628                  swarg->svs_svp = svp;
3627      -                swarg->svs_tos = ddi_get_time();
     3629 +                swarg->svs_tos = gethrtime();
3628 3630                  swarg->svs_pi = vpkt->vpkt_path;
3629 3631                  swarg->svs_release_lun = 0;
3630 3632                  swarg->svs_done = 0;
3631 3633                  /*
3632 3634                   * place a hold on the path...we don't want it to
3633 3635                   * vanish while scsi_watch is in progress
3634 3636                   */
3635 3637                  mdi_hold_path(vpkt->vpkt_path);
3636 3638                  svp->svp_sw_token = scsi_watch_request_submit(svp->svp_psd,
3637 3639                      VHCI_FOWATCH_INTERVAL, SENSE_LENGTH, vhci_efo_watch_cb,
↓ open down ↓ 40 lines elided ↑ open up ↑
3678 3680          ASSERT(vlun != NULL);
3679 3681          ASSERT(VHCI_LUN_IS_HELD(vlun));
3680 3682          vlun->svl_efo_update_path = 0;
3681 3683          vdip = ddi_get_parent(vlun->svl_dip);
3682 3684          vhci = ddi_get_soft_state(vhci_softstate,
3683 3685              ddi_get_instance(vdip));
3684 3686  
3685 3687          updt_paths = 0;
3686 3688  
3687 3689          if (pkt->pkt_reason != CMD_CMPLT) {
3688      -                if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
     3690 +                if ((gethrtime() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
3689 3691                          swarg->svs_release_lun = 1;
3690 3692                          goto done;
3691 3693                  }
3692 3694                  return (0);
3693 3695          }
3694 3696          if (*((unsigned char *)statusp) == STATUS_CHECK) {
3695 3697                  rval = vlun->svl_fops->sfo_analyze_sense(svp->svp_psd, sensep,
3696 3698                      vlun->svl_fops_ctpriv);
3697 3699                  switch (rval) {
3698 3700                          /*
↓ open down ↓ 1 lines elided ↑ open up ↑
3700 3702                           * inactive, or no failover occurred.  For all other
3701 3703                           * check conditions continue pinging.  A unexpected
3702 3704                           * check condition shouldn't cause pinging to complete
3703 3705                           * prematurely.
3704 3706                           */
3705 3707                          case SCSI_SENSE_INACTIVE:
3706 3708                          case SCSI_SENSE_NOFAILOVER:
3707 3709                                  updt_paths = 1;
3708 3710                                  break;
3709 3711                          default:
3710      -                                if ((ddi_get_time() - swarg->svs_tos)
     3712 +                                if ((gethrtime() - swarg->svs_tos)
3711 3713                                      >= VHCI_EXTFO_TIMEOUT) {
3712 3714                                          swarg->svs_release_lun = 1;
3713 3715                                          goto done;
3714 3716                                  }
3715 3717                                  return (0);
3716 3718                  }
3717 3719          } else if (*((unsigned char *)statusp) ==
3718 3720              STATUS_RESERVATION_CONFLICT) {
3719 3721                  updt_paths = 1;
3720 3722          } else if ((*((unsigned char *)statusp)) &
↓ open down ↓ 11 lines elided ↑ open up ↑
3732 3734                   */
3733 3735                  vlun->svl_efo_update_path = 1;
3734 3736                  swarg->svs_done = 1;
3735 3737                  vlun->svl_swarg = swarg;
3736 3738                  vlun->svl_flags |= VLUN_UPDATE_TPG;
3737 3739                  (void) taskq_dispatch(vhci->vhci_update_pathstates_taskq,
3738 3740                      vhci_update_pathstates, (void *)vlun,
3739 3741                      KM_SLEEP);
3740 3742                  return (0);
3741 3743          }
3742      -        if ((ddi_get_time() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
     3744 +        if ((gethrtime() - swarg->svs_tos) >= VHCI_EXTFO_TIMEOUT) {
3743 3745                  swarg->svs_release_lun = 1;
3744 3746                  goto done;
3745 3747          }
3746 3748          return (0);
3747 3749  done:
3748 3750          swarg->svs_done = 1;
3749 3751          (void) taskq_dispatch(vhci->vhci_taskq,
3750 3752              vhci_efo_done, (void *)swarg, KM_SLEEP);
3751 3753          return (0);
3752 3754  }
↓ open down ↓ 5066 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX