Skip to contentSkip to conversation

Allow LLDs to modify disk r/w timeout

PATCH New Brian King 1 participant 1 message Apr 1, 2004 SCSI

lore
Share & tools
lore

Brian King

author
#0 lore raw

PATCH 1/1 Allow LLDs to modify disk r/w timeout

Attached is a patch that adds a rw_timeout field to the scsi_device struct which LLDs can setup in their slave_configure routines to override the read/write timeout used by sd. Various disk device types (i.e. RAID array devices) need longer timeout values than regular scsi disks, and this patch allows for this. This would get remove one of the reasons the ipr driver modifies the scsi timer today.

Brian King
eServer Storage I/O
IBM Linux Technology Center

This patch adds a r/w timeout field to the scsi_device struct to allow LLDs to modify the r/w timeout used by the scsi disk driver. LLDs may setup this field in their slave_configure routines if they require a different timeout to be used for certain devices, such as RAID arrays.

---

 linux-2.6.5-rc3-bjking1/drivers/scsi/sd.c          |   11 ++++++++---
 linux-2.6.5-rc3-bjking1/include/scsi/scsi_device.h |    2 ++
 2 files changed, 10 insertions(+), 3 deletions(-)
drivers/scsi/sd.c renamed from drivers/scsi/sd.c~sd_timeout_mod +8 -3
diff -puN drivers/scsi/sd.c~sd_timeout_mod drivers/scsi/sd.c
@@ -203,9 +203,7 @@ static int sd_init_command(struct scsi_c
 	sector_t block;
 	struct scsi_device *sdp = SCpnt->device;
 
-	timeout = SD_TIMEOUT;
-	if (SCpnt->device->type != TYPE_DISK)
-		timeout = SD_MOD_TIMEOUT;
+	timeout = sdp->rw_timeout;
 
 	/*
 	 * these are already setup, just copy cdb basically
@@ -1370,6 +1368,13 @@ static int sd_probe(struct device *dev)
 	sdkp->index = index;
 	sdkp->openers = 0;
 
+	if (!sdp->rw_timeout) {
+		if (sdp->type == TYPE_DISK)
+			sdp->rw_timeout = SD_TIMEOUT;
+		else
+			sdp->rw_timeout = SD_MOD_TIMEOUT;
+	}
+
 	devno = make_sd_dev(index, 0);
 	gd->major = MAJOR(devno);
 	gd->first_minor = MINOR(devno);
include/scsi/scsi_device.h renamed from include/scsi/scsi_device.h~sd_timeout_mod +2 -0
diff -puN include/scsi/scsi_device.h~sd_timeout_mod include/scsi/scsi_device.h
@@ -104,6 +104,8 @@ struct scsi_device {
 	unsigned int max_device_blocked; /* what device_blocked counts down from  */
 #define SCSI_DEFAULT_DEVICE_BLOCKED	3
 
+	int rw_timeout;
+
 	struct device		sdev_gendev;
 	struct class_device	sdev_classdev;
 

_