Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0816c925 authored by Martin K. Petersen's avatar Martin K. Petersen Committed by James Bottomley
Browse files

[SCSI] Allow error handling timeout to be specified



Introduce eh_timeout which can be used for error handling purposes. This
was previously hardcoded to 10 seconds in the SCSI error handling
code. However, for some fast-fail scenarios it is necessary to be able
to tune this as it can take several iterations (bus device, target, bus,
controller) before we give up.

Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 0761df9c
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -45,8 +45,6 @@


static void scsi_eh_done(struct scsi_cmnd *scmd);
static void scsi_eh_done(struct scsi_cmnd *scmd);


#define SENSE_TIMEOUT		(10*HZ)

/*
/*
 * These should *probably* be handled by the host itself.
 * These should *probably* be handled by the host itself.
 * Since it is allowed to sleep, it probably should.
 * Since it is allowed to sleep, it probably should.
@@ -881,7 +879,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
 */
 */
static int scsi_request_sense(struct scsi_cmnd *scmd)
static int scsi_request_sense(struct scsi_cmnd *scmd)
{
{
	return scsi_send_eh_cmnd(scmd, NULL, 0, SENSE_TIMEOUT, ~0);
	return scsi_send_eh_cmnd(scmd, NULL, 0, scmd->device->eh_timeout, ~0);
}
}


/**
/**
@@ -982,7 +980,8 @@ static int scsi_eh_tur(struct scsi_cmnd *scmd)
	int retry_cnt = 1, rtn;
	int retry_cnt = 1, rtn;


retry_tur:
retry_tur:
	rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0);
	rtn = scsi_send_eh_cmnd(scmd, tur_command, 6,
				scmd->device->eh_timeout, 0);


	SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
	SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",
		__func__, scmd, rtn));
		__func__, scmd, rtn));
+2 −0
Original line number Original line Diff line number Diff line
@@ -924,6 +924,8 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
	if (*bflags & BLIST_NO_DIF)
	if (*bflags & BLIST_NO_DIF)
		sdev->no_dif = 1;
		sdev->no_dif = 1;


	sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;

	transport_configure_device(&sdev->sdev_gendev);
	transport_configure_device(&sdev->sdev_gendev);


	if (sdev->host->hostt->slave_configure) {
	if (sdev->host->hostt->slave_configure) {
+30 −0
Original line number Original line Diff line number Diff line
@@ -559,6 +559,35 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr,
}
}
static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);


static ssize_t
sdev_show_eh_timeout(struct device *dev, struct device_attribute *attr, char *buf)
{
	struct scsi_device *sdev;
	sdev = to_scsi_device(dev);
	return snprintf(buf, 20, "%u\n", sdev->eh_timeout / HZ);
}

static ssize_t
sdev_store_eh_timeout(struct device *dev, struct device_attribute *attr,
		    const char *buf, size_t count)
{
	struct scsi_device *sdev;
	unsigned int eh_timeout;
	int err;

	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;

	sdev = to_scsi_device(dev);
	err = kstrtouint(buf, 10, &eh_timeout);
	if (err)
		return err;
	sdev->eh_timeout = eh_timeout * HZ;

	return count;
}
static DEVICE_ATTR(eh_timeout, S_IRUGO | S_IWUSR, sdev_show_eh_timeout, sdev_store_eh_timeout);

static ssize_t
static ssize_t
store_rescan_field (struct device *dev, struct device_attribute *attr,
store_rescan_field (struct device *dev, struct device_attribute *attr,
		    const char *buf, size_t count)
		    const char *buf, size_t count)
@@ -723,6 +752,7 @@ static struct attribute *scsi_sdev_attrs[] = {
	&dev_attr_delete.attr,
	&dev_attr_delete.attr,
	&dev_attr_state.attr,
	&dev_attr_state.attr,
	&dev_attr_timeout.attr,
	&dev_attr_timeout.attr,
	&dev_attr_eh_timeout.attr,
	&dev_attr_iocounterbits.attr,
	&dev_attr_iocounterbits.attr,
	&dev_attr_iorequest_cnt.attr,
	&dev_attr_iorequest_cnt.attr,
	&dev_attr_iodone_cnt.attr,
	&dev_attr_iodone_cnt.attr,
+5 −0
Original line number Original line Diff line number Diff line
@@ -10,9 +10,14 @@


#include <linux/types.h>
#include <linux/types.h>
#include <linux/scatterlist.h>
#include <linux/scatterlist.h>
#include <linux/kernel.h>


struct scsi_cmnd;
struct scsi_cmnd;


enum scsi_timeouts {
	SCSI_DEFAULT_EH_TIMEOUT		= 10 * HZ,
};

/*
/*
 * The maximum number of SG segments that we will put inside a
 * The maximum number of SG segments that we will put inside a
 * scatterlist (unless chaining is used). Should ideally fit inside a
 * scatterlist (unless chaining is used). Should ideally fit inside a
+1 −0
Original line number Original line Diff line number Diff line
@@ -113,6 +113,7 @@ struct scsi_device {
				 * scsi_devinfo.[hc]. For now used only to
				 * scsi_devinfo.[hc]. For now used only to
				 * pass settings from slave_alloc to scsi
				 * pass settings from slave_alloc to scsi
				 * core. */
				 * core. */
	unsigned int eh_timeout; /* Error handling timeout */
	unsigned writeable:1;
	unsigned writeable:1;
	unsigned removable:1;
	unsigned removable:1;
	unsigned changed:1;	/* Data invalid due to media change */
	unsigned changed:1;	/* Data invalid due to media change */