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,33 **** * 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 2012 DEY Storage Systems, Inc. All rights reserved. */ /* * Copyright 2011 cyril.galibern@opensvc.com */ --- 23,33 ---- * 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 2014 Nexenta Systems, Inc. All rights reserved. * Copyright 2012 DEY Storage Systems, Inc. All rights reserved. */ /* * Copyright 2011 cyril.galibern@opensvc.com */
*** 6539,6568 **** */ static void sd_pm_idletimeout_handler(void *arg) { 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) && (un->un_ncmds_in_driver == 0) && (un->un_pm_count == 0)) { /* * Update the chain types. * This takes affect on the next new command received. */ --- 6539,6566 ---- */ static void sd_pm_idletimeout_handler(void *arg) { + const hrtime_t idletime = sd_pm_idletime * NANOSEC; struct sd_lun *un = arg; 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); /* * 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 (((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,12469 **** * 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_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", --- 12457,12467 ---- * 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 = 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,12519 **** * 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_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); --- 12507,12517 ---- * 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 = 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);