diff options
-rw-r--r-- | drivers/scsi/scsi_error.c | 7 | ||||
-rw-r--r-- | drivers/scsi/scsi_scan.c | 2 | ||||
-rw-r--r-- | drivers/scsi/scsi_sysfs.c | 30 | ||||
-rw-r--r-- | include/scsi/scsi.h | 5 | ||||
-rw-r--r-- | include/scsi/scsi_device.h | 1 |
5 files changed, 41 insertions, 4 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index f43de1e56420..562474499942 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -45,8 +45,6 @@ | |||
45 | 45 | ||
46 | static void scsi_eh_done(struct scsi_cmnd *scmd); | 46 | static void scsi_eh_done(struct scsi_cmnd *scmd); |
47 | 47 | ||
48 | #define SENSE_TIMEOUT (10*HZ) | ||
49 | |||
50 | /* | 48 | /* |
51 | * These should *probably* be handled by the host itself. | 49 | * These should *probably* be handled by the host itself. |
52 | * Since it is allowed to sleep, it probably should. | 50 | * Since it is allowed to sleep, it probably should. |
@@ -881,7 +879,7 @@ retry: | |||
881 | */ | 879 | */ |
882 | static int scsi_request_sense(struct scsi_cmnd *scmd) | 880 | static int scsi_request_sense(struct scsi_cmnd *scmd) |
883 | { | 881 | { |
884 | return scsi_send_eh_cmnd(scmd, NULL, 0, SENSE_TIMEOUT, ~0); | 882 | return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0); |
885 | } | 883 | } |
886 | 884 | ||
887 | /** | 885 | /** |
@@ -982,7 +980,8 @@ static int scsi_eh_tur(struct scsi_cmnd *scmd) | |||
982 | int retry_cnt = 1, rtn; | 980 | int retry_cnt = 1, rtn; |
983 | 981 | ||
984 | retry_tur: | 982 | retry_tur: |
985 | rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0); | 983 | rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, |
984 | scmd->device->eh_timeout, 0); | ||
986 | 985 | ||
987 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n", | 986 | SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n", |
988 | __func__, scmd, rtn)); | 987 | __func__, scmd, rtn)); |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 3e58b2245f1f..852915a08465 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -924,6 +924,8 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result, | |||
924 | if (*bflags & BLIST_NO_DIF) | 924 | if (*bflags & BLIST_NO_DIF) |
925 | sdev->no_dif = 1; | 925 | sdev->no_dif = 1; |
926 | 926 | ||
927 | sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT; | ||
928 | |||
927 | transport_configure_device(&sdev->sdev_gendev); | 929 | transport_configure_device(&sdev->sdev_gendev); |
928 | 930 | ||
929 | if (sdev->host->hostt->slave_configure) { | 931 | if (sdev->host->hostt->slave_configure) { |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 931a7d954203..7e50061e9ef6 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -560,6 +560,35 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr, | |||
560 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); | 560 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); |
561 | 561 | ||
562 | static ssize_t | 562 | static ssize_t |
563 | sdev_show_eh_timeout(struct device *dev, struct device_attribute *attr, char *buf) | ||
564 | { | ||
565 | struct scsi_device *sdev; | ||
566 | sdev = to_scsi_device(dev); | ||
567 | return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ); | ||
568 | } | ||
569 | |||
570 | static ssize_t | ||
571 | sdev_store_eh_timeout(struct device *dev, struct device_attribute *attr, | ||
572 | const char *buf, size_t count) | ||
573 | { | ||
574 | struct scsi_device *sdev; | ||
575 | unsigned int eh_timeout; | ||
576 | int err; | ||
577 | |||
578 | if (!capable(CAP_SYS_ADMIN)) | ||
579 | return -EACCES; | ||
580 | |||
581 | sdev = to_scsi_device(dev); | ||
582 | err = kstrtouint(buf, 10, &eh_timeout); | ||
583 | if (err) | ||
584 | return err; | ||
585 | sdev->eh_timeout = eh_timeout * HZ; | ||
586 | |||
587 | return count; | ||
588 | } | ||
589 | static DEVICE_ATTR(eh_timeout, S_IRUGO | S_IWUSR, sdev_show_eh_timeout, sdev_store_eh_timeout); | ||
590 | |||
591 | static ssize_t | ||
563 | store_rescan_field (struct device *dev, struct device_attribute *attr, | 592 | store_rescan_field (struct device *dev, struct device_attribute *attr, |
564 | const char *buf, size_t count) | 593 | const char *buf, size_t count) |
565 | { | 594 | { |
@@ -723,6 +752,7 @@ static struct attribute *scsi_sdev_attrs[] = { | |||
723 | &dev_attr_delete.attr, | 752 | &dev_attr_delete.attr, |
724 | &dev_attr_state.attr, | 753 | &dev_attr_state.attr, |
725 | &dev_attr_timeout.attr, | 754 | &dev_attr_timeout.attr, |
755 | &dev_attr_eh_timeout.attr, | ||
726 | &dev_attr_iocounterbits.attr, | 756 | &dev_attr_iocounterbits.attr, |
727 | &dev_attr_iorequest_cnt.attr, | 757 | &dev_attr_iorequest_cnt.attr, |
728 | &dev_attr_iodone_cnt.attr, | 758 | &dev_attr_iodone_cnt.attr, |
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h index 66216c1acb48..4b87d99e7fa1 100644 --- a/include/scsi/scsi.h +++ b/include/scsi/scsi.h | |||
@@ -10,9 +10,14 @@ | |||
10 | 10 | ||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/scatterlist.h> | 12 | #include <linux/scatterlist.h> |
13 | #include <linux/kernel.h> | ||
13 | 14 | ||
14 | struct scsi_cmnd; | 15 | struct scsi_cmnd; |
15 | 16 | ||
17 | enum scsi_timeouts { | ||
18 | SCSI_DEFAULT_EH_TIMEOUT = 10 * HZ, | ||
19 | }; | ||
20 | |||
16 | /* | 21 | /* |
17 | * The maximum number of SG segments that we will put inside a | 22 | * The maximum number of SG segments that we will put inside a |
18 | * scatterlist (unless chaining is used). Should ideally fit inside a | 23 | * scatterlist (unless chaining is used). Should ideally fit inside a |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index cc645876d147..a44954c7cdc2 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -113,6 +113,7 @@ struct scsi_device { | |||
113 | * scsi_devinfo.[hc]. For now used only to | 113 | * scsi_devinfo.[hc]. For now used only to |
114 | * pass settings from slave_alloc to scsi | 114 | * pass settings from slave_alloc to scsi |
115 | * core. */ | 115 | * core. */ |
116 | unsigned int eh_timeout; /* Error handling timeout */ | ||
116 | unsigned writeable:1; | 117 | unsigned writeable:1; |
117 | unsigned removable:1; | 118 | unsigned removable:1; |
118 | unsigned changed:1; /* Data invalid due to media change */ | 119 | unsigned changed:1; /* Data invalid due to media change */ |