Commit 19101a34 authored by Brian King's avatar Brian King Committed by James Bottomley

[PATCH] Make SCSI timeout modifiable

add a timeout field to struct scsi_device and expose it in in sysfs.

This patch allows LLDs to override the default timeout used for scsi devices
and exposes it in sysfs. The default timeout value used is too short for
many RAID array devices, such as those created by the ipr driver.
parent 0b4e43b0
...@@ -302,6 +302,26 @@ sdev_rd_attr (vendor, "%.8s\n"); ...@@ -302,6 +302,26 @@ sdev_rd_attr (vendor, "%.8s\n");
sdev_rd_attr (model, "%.16s\n"); sdev_rd_attr (model, "%.16s\n");
sdev_rd_attr (rev, "%.4s\n"); sdev_rd_attr (rev, "%.4s\n");
static ssize_t
sdev_show_timeout (struct device *dev, char *buf)
{
struct scsi_device *sdev;
sdev = to_scsi_device(dev);
return snprintf (buf, 20, "%d\n", sdev->timeout / HZ);
}
static ssize_t
sdev_store_timeout (struct device *dev, const char *buf, size_t count)
{
struct scsi_device *sdev;
int timeout;
sdev = to_scsi_device(dev);
sscanf (buf, "%d\n", &timeout);
sdev->timeout = timeout * HZ;
return count;
}
static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout)
static ssize_t static ssize_t
store_rescan_field (struct device *dev, const char *buf, size_t count) store_rescan_field (struct device *dev, const char *buf, size_t count)
{ {
...@@ -368,6 +388,7 @@ static struct device_attribute *scsi_sysfs_sdev_attrs[] = { ...@@ -368,6 +388,7 @@ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
&dev_attr_rescan, &dev_attr_rescan,
&dev_attr_delete, &dev_attr_delete,
&dev_attr_state, &dev_attr_state,
&dev_attr_timeout,
NULL NULL
}; };
......
...@@ -217,9 +217,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt) ...@@ -217,9 +217,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
sector_t block; sector_t block;
struct scsi_device *sdp = SCpnt->device; struct scsi_device *sdp = SCpnt->device;
timeout = SD_TIMEOUT; timeout = sdp->timeout;
if (SCpnt->device->type != TYPE_DISK)
timeout = SD_MOD_TIMEOUT;
/* /*
* these are already setup, just copy cdb basically * these are already setup, just copy cdb basically
...@@ -1389,6 +1387,13 @@ static int sd_probe(struct device *dev) ...@@ -1389,6 +1387,13 @@ static int sd_probe(struct device *dev)
sdkp->index = index; sdkp->index = index;
sdkp->openers = 0; sdkp->openers = 0;
if (!sdp->timeout) {
if (sdp->type == TYPE_DISK)
sdp->timeout = SD_TIMEOUT;
else
sdp->timeout = SD_MOD_TIMEOUT;
}
devno = make_sd_dev(index, 0); devno = make_sd_dev(index, 0);
gd->major = MAJOR(devno); gd->major = MAJOR(devno);
gd->first_minor = MINOR(devno); gd->first_minor = MINOR(devno);
......
...@@ -112,6 +112,8 @@ struct scsi_device { ...@@ -112,6 +112,8 @@ struct scsi_device {
unsigned int max_device_blocked; /* what device_blocked counts down from */ unsigned int max_device_blocked; /* what device_blocked counts down from */
#define SCSI_DEFAULT_DEVICE_BLOCKED 3 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
int timeout;
struct device sdev_gendev; struct device sdev_gendev;
struct class_device sdev_classdev; struct class_device sdev_classdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment