|
21 | 21 |
|
22 | 22 | /* |
23 | 23 | * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. |
24 | | - */ |
25 | | -/* |
| 24 | + * |
| 25 | + * |
26 | 26 | * Copyright (c) 2011 Bayard G. Bell. All rights reserved. |
27 | 27 | * Copyright (c) 2012 by Delphix. All rights reserved. |
28 | 28 | * Copyright 2013 Nexenta Systems, Inc. All rights reserved. |
29 | | - */ |
30 | | -/* |
| 29 | + * |
| 30 | + * |
31 | 31 | * Copyright 2011 cyril.galibern@opensvc.com |
| 32 | + * |
32 | 33 | */ |
33 | 34 |
|
34 | 35 | /* |
@@ -241,6 +242,14 @@ int sd_qfull_throttle_enable = TRUE; |
241 | 242 |
|
242 | 243 | int sd_retry_on_reservation_conflict = 1; |
243 | 244 | int sd_reinstate_resv_delay = SD_REINSTATE_RESV_DELAY; |
| 245 | + |
| 246 | +/* |
| 247 | + * Default safe I/O delay threshold of 2s for all devices. |
| 248 | + * Can be overriden for vendor/device id in sd.conf |
| 249 | + */ |
| 250 | + |
| 251 | +hrtime_t sd_g_slow_io_threshold = 2 * NANOSEC; |
| 252 | + |
244 | 253 | _NOTE(SCHEME_PROTECTS_DATA("safe sharing", sd_reinstate_resv_delay)) |
245 | 254 |
|
246 | 255 | static int sd_dtype_optical_bind = -1; |
@@ -4231,6 +4240,23 @@ sd_set_properties(struct sd_lun *un, char *name, char *value) |
4231 | 4240 | "physical block size set to %d\n", un->un_phy_blocksize); |
4232 | 4241 | } |
4233 | 4242 |
|
| 4243 | + if (strcasecmp(name, "slow-io-threshold") == 0) { |
| 4244 | + if (ddi_strtol(value, &endptr, 0, &val) == 0) { |
| 4245 | + un->un_slow_io_threshold = (hrtime_t)val * NANOSEC; |
| 4246 | + } else { |
| 4247 | + un->un_slow_io_threshold = |
| 4248 | + (hrtime_t)sd_g_slow_io_threshold; |
| 4249 | + goto value_invalid; |
| 4250 | + } |
| 4251 | + SD_INFO(SD_LOG_ATTACH_DETACH, un, "sd_set_properties: " |
| 4252 | + "slow IO threshold set to %llu\n", |
| 4253 | + un->un_slow_io_threshold); |
| 4254 | +#ifdef SDDEBUG |
| 4255 | + cmn_err(CE_NOTE, "slow IO set to %llu", |
| 4256 | + un->un_slow_io_threshold); |
| 4257 | +#endif |
| 4258 | + } |
| 4259 | + |
4234 | 4260 | if (strcasecmp(name, "retries-victim") == 0) { |
4235 | 4261 | if (ddi_strtol(value, &endptr, 0, &val) == 0) { |
4236 | 4262 | un->un_victim_retry_count = val; |
@@ -7534,6 +7560,8 @@ sd_unit_attach(dev_info_t *devi) |
7534 | 7560 | */ |
7535 | 7561 | un->un_reserve_release_time = 5; |
7536 | 7562 |
|
| 7563 | + un->un_slow_io_threshold = sd_g_slow_io_threshold; |
| 7564 | + |
7537 | 7565 | /* |
7538 | 7566 | * Set up the default maximum transfer size. Note that this may |
7539 | 7567 | * get updated later in the attach, when setting up default wide |
@@ -16825,6 +16853,29 @@ sdrunout(caddr_t arg) |
16825 | 16853 | return (1); |
16826 | 16854 | } |
16827 | 16855 |
|
| 16856 | +static void |
| 16857 | +sd_slow_io_ereport(struct scsi_pkt *pktp) |
| 16858 | +{ |
| 16859 | + struct buf *bp; |
| 16860 | + struct sd_lun *un; |
| 16861 | + char *devid; |
| 16862 | + |
| 16863 | + ASSERT(pktp != NULL); |
| 16864 | + bp = (struct buf *)pktp->pkt_private; |
| 16865 | + ASSERT(bp != NULL); |
| 16866 | + un = SD_GET_UN(bp); |
| 16867 | + ASSERT(un != NULL); |
| 16868 | + |
| 16869 | + devid = DEVI(un->un_sd->sd_dev)->devi_devid_str; |
| 16870 | + scsi_fm_ereport_post(un->un_sd, 0, NULL, "cmd.disk.slow-io", |
| 16871 | + fm_ena_generate(0, FM_ENA_FMT1), devid, NULL, DDI_NOSLEEP, NULL, |
| 16872 | + FM_VERSION, DATA_TYPE_UINT8, FM_EREPORT_VERS0, |
| 16873 | + "start", DATA_TYPE_UINT64, pktp->pkt_start, |
| 16874 | + "stop", DATA_TYPE_UINT64, pktp->pkt_stop, |
| 16875 | + "delta", DATA_TYPE_UINT64, pktp->pkt_stop - pktp->pkt_start, |
| 16876 | + "threshold", DATA_TYPE_UINT64, un->un_slow_io_threshold, |
| 16877 | + NULL); |
| 16878 | +} |
16828 | 16879 |
|
16829 | 16880 | /* |
16830 | 16881 | * Function: sdintr |
@@ -16879,6 +16930,14 @@ sdintr(struct scsi_pkt *pktp) |
16879 | 16930 | un->un_in_callback++; |
16880 | 16931 |
|
16881 | 16932 | SD_UPDATE_KSTATS(un, kstat_runq_exit, bp); |
| 16933 | + if ((pktp->pkt_stop - pktp->pkt_start) > un->un_slow_io_threshold) { |
| 16934 | + sd_slow_io_ereport(pktp); |
| 16935 | +#ifdef SDDEBUG |
| 16936 | + cmn_err(CE_WARN, "Slow IO detected SD: 0x%p delta in nsec: %llu", |
| 16937 | + un, pktp->pkt_stop - pktp->pkt_start); |
| 16938 | +#endif |
| 16939 | + } |
| 16940 | + |
16882 | 16941 |
|
16883 | 16942 | #ifdef SDDEBUG |
16884 | 16943 | if (bp == un->un_retry_bp) { |
|
0 commit comments