Print this page
4780 comstar iSCSI target shouldn't abuse ddi_get_time(9f)
Reviewed by: Eric Diven <eric.diven@delphix.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
          +++ new/usr/src/uts/common/io/comstar/port/iscsit/iscsit.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) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   *
  24      - * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
       24 + * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
  25   25   */
  26   26  
  27   27  #include <sys/cpuvar.h>
  28   28  #include <sys/types.h>
  29   29  #include <sys/conf.h>
  30   30  #include <sys/stat.h>
  31   31  #include <sys/file.h>
  32   32  #include <sys/ddi.h>
  33   33  #include <sys/sunddi.h>
  34   34  #include <sys/modctl.h>
↓ open down ↓ 3083 lines elided ↑ open up ↑
3118 3118          }
3119 3119          if (iscsit_sna_lt(ist->ist_expcmdsn, ntohl(hdr->cmdsn))) {
3120 3120                  /*
3121 3121                   * Out-of-order commands (cmdSN higher than ExpCmdSN)
3122 3122                   * are staged on a fixed-size circular buffer until
3123 3123                   * the missing command is delivered to the SCSI layer.
3124 3124                   * Irrespective of the order of insertion into the
3125 3125                   * staging queue, the commands are processed out of the
3126 3126                   * queue in cmdSN order only.
3127 3127                   */
3128      -                rx_pdu->isp_queue_time = ddi_get_time();
     3128 +                rx_pdu->isp_queue_time = gethrtime();
3129 3129                  iscsit_add_pdu_to_queue(ist, rx_pdu);
3130 3130                  mutex_exit(&ist->ist_sn_mutex);
3131 3131                  return (ISCSIT_CMDSN_GT_EXPCMDSN);
3132 3132          } else if (iscsit_sna_lt(ntohl(hdr->cmdsn), ist->ist_expcmdsn)) {
3133 3133                  DTRACE_PROBE3(cmdsn__lt__expcmdsn, iscsit_sess_t *, ist,
3134 3134                      iscsit_conn_t *, ict, idm_pdu_t *, rx_pdu);
3135 3135                  mutex_exit(&ist->ist_sn_mutex);
3136 3136                  return (ISCSIT_CMDSN_LT_EXPCMDSN);
3137 3137          } else {
3138 3138                  mutex_exit(&ist->ist_sn_mutex);
↓ open down ↓ 249 lines elided ↑ open up ↑
3388 3388          }
3389 3389          for (next_pdu = NULL, i = 0; ; i++) {
3390 3390                  next_cmdsn = ist->ist_expcmdsn + i; /* start at expcmdsn */
3391 3391                  index = next_cmdsn % ISCSIT_RXPDU_QUEUE_LEN;
3392 3392                  if ((next_pdu = cbuf->cb_buffer[index]) != NULL) {
3393 3393                          /*
3394 3394                           * If the PDU wait time has not exceeded threshold
3395 3395                           * stop scanning the staging queue until the timer
3396 3396                           * fires again
3397 3397                           */
3398      -                        if ((ddi_get_time() - next_pdu->isp_queue_time)
3399      -                            < rxpdu_queue_threshold) {
     3398 +                        if ((gethrtime() - next_pdu->isp_queue_time)
     3399 +                            < (rxpdu_queue_threshold * NANOSEC)) {
3400 3400                                  mutex_exit(&ist->ist_sn_mutex);
3401 3401                                  return;
3402 3402                          }
3403 3403                          /*
3404 3404                           * Remove the next PDU from the queue and post it
3405 3405                           * to the SCSI layer, skipping over the missing
3406 3406                           * PDU. Stop scanning the staging queue until
3407 3407                           * the monitor timer fires again
3408 3408                           */
3409 3409                          (void) iscsit_remove_pdu_from_queue(ist, next_cmdsn);
↓ open down ↓ 22 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX