Print this page
4781 sd shouldn't abuse ddi_get_time(9f)
Reviewed by: Richard Elling <richard.elling@gmail.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

@@ -23,11 +23,11 @@
  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 /*
  * Copyright (c) 2011 Bayard G. Bell.  All rights reserved.
  * Copyright (c) 2012 by Delphix. All rights reserved.
- * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  */
 /*
  * Copyright 2011 cyril.galibern@opensvc.com
  */

@@ -6539,30 +6539,28 @@
  */
 
 static void
 sd_pm_idletimeout_handler(void *arg)
 {
+        const hrtime_t idletime = sd_pm_idletime * NANOSEC;
         struct sd_lun *un = arg;
 
-        time_t  now;
-
         mutex_enter(&sd_detach_mutex);
         if (un->un_detach_count != 0) {
                 /* Abort if the instance is detaching */
                 mutex_exit(&sd_detach_mutex);
                 return;
         }
         mutex_exit(&sd_detach_mutex);
 
-        now = ddi_get_time();
         /*
          * Grab both mutexes, in the proper order, since we're accessing
          * both PM and softstate variables.
          */
         mutex_enter(SD_MUTEX(un));
         mutex_enter(&un->un_pm_mutex);
-        if (((now - un->un_pm_idle_time) > sd_pm_idletime) &&
+        if (((gethrtime() - un->un_pm_idle_time) > idletime) &&
             (un->un_ncmds_in_driver == 0) && (un->un_pm_count == 0)) {
                 /*
                  * Update the chain types.
                  * This takes affect on the next new command received.
                  */

@@ -12459,11 +12457,11 @@
                  * This is used for determining if the system has been
                  * idle long enough to make it idle to the PM framework.
                  * This is for lowering the overhead, and therefore improving
                  * performance per I/O operation.
                  */
-                un->un_pm_idle_time = ddi_get_time();
+                un->un_pm_idle_time = gethrtime();
 
                 un->un_ncmds_in_driver--;
                 ASSERT(un->un_ncmds_in_driver >= 0);
                 SD_INFO(SD_LOG_IO, un,
                     "sd_buf_iodone: un_ncmds_in_driver = %ld\n",

@@ -12509,11 +12507,11 @@
          * This is used for determining if the system has been
          * idle long enough to make it idle to the PM framework.
          * This is for lowering the overhead, and therefore improving
          * performance per I/O operation.
          */
-        un->un_pm_idle_time = ddi_get_time();
+        un->un_pm_idle_time = gethrtime();
 
         un->un_ncmds_in_driver--;
         ASSERT(un->un_ncmds_in_driver >= 0);
         SD_INFO(SD_LOG_IO, un, "sd_uscsi_iodone: un_ncmds_in_driver = %ld\n",
             un->un_ncmds_in_driver);