Commit b443d3ea authored by Don Brace's avatar Don Brace Committed by Martin K. Petersen
Browse files

scsi: hpsa: wait longer for ptraid commands



Wait longer for outstanding commands before removing a multipath
device. Increase the timeout value for ptraid commands.

Reviewed-by: default avatarJustin Lindley <justin.lindley@microsemi.com>
Reviewed-by: default avatarDavid Carroll <david.carroll@microsemi.com>
Reviewed-by: default avatarScott Teel <scott.teel@microsemi.com>
Signed-off-by: default avatarDon Brace <don.brace@microsemi.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 4770e68d
Loading
Loading
Loading
Loading
+20 −6
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@

/*define how many times we will try a command because of bus resets */
#define MAX_CMD_RETRIES 3
/* How long to wait before giving up on a command */
#define HPSA_EH_PTRAID_TIMEOUT (240 * HZ)

/* Embedded module documentation macros - see modules.h */
MODULE_AUTHOR("Hewlett-Packard Company");
@@ -1842,25 +1844,33 @@ static int hpsa_find_outstanding_commands_for_dev(struct ctlr_info *h,
	return count;
}

#define NUM_WAIT 20
static void hpsa_wait_for_outstanding_commands_for_dev(struct ctlr_info *h,
						struct hpsa_scsi_dev_t *device)
{
	int cmds = 0;
	int waits = 0;
	int num_wait = NUM_WAIT;

	if (device->external)
		num_wait = HPSA_EH_PTRAID_TIMEOUT;

	while (1) {
		cmds = hpsa_find_outstanding_commands_for_dev(h, device);
		if (cmds == 0)
			break;
		if (++waits > 20)
		if (++waits > num_wait)
			break;
		msleep(1000);
	}

	if (waits > 20)
	if (waits > num_wait) {
		dev_warn(&h->pdev->dev,
			"%s: removing device with %d outstanding commands!\n",
			__func__, cmds);
			"%s: removing device [%d:%d:%d:%d] with %d outstanding commands!\n",
			__func__,
			h->scsi_host->host_no,
			device->bus, device->target, device->lun, cmds);
	}
}

static void hpsa_remove_device(struct ctlr_info *h,
@@ -2131,11 +2141,15 @@ static int hpsa_slave_configure(struct scsi_device *sdev)
	sdev->no_uld_attach = !sd || !sd->expose_device;

	if (sd) {
		if (sd->external)
		if (sd->external) {
			queue_depth = EXTERNAL_QD;
		else
			sdev->eh_timeout = HPSA_EH_PTRAID_TIMEOUT;
			blk_queue_rq_timeout(sdev->request_queue,
						HPSA_EH_PTRAID_TIMEOUT);
		} else {
			queue_depth = sd->queue_depth != 0 ?
					sd->queue_depth : sdev->host->can_queue;
		}
	} else
		queue_depth = sdev->host->can_queue;