delay transition requeues for 2 seconds - alua
PATCH 1/1 delay transition requeues for 2 seconds - alua
When alua targets are transitioning, the scsi midlayer retry mechanism continuously retries the scsi commands that are returning with not ready transitioning status. The target is not capable of handling the commands for time on the order of several seconds during these transistions.
This patch delays the device queue for 2 seconds, which is in the same order of aas transition time.
Also, handle all other cases where ADD_TO_MLQUEUE_DELAY could be returned instead of ADD_TO_MLQUEUE as if ADD_TO_MLQUEUE were being returned.
Problem found by array partner testing
--- drivers/scsi/device_handler/scsi_dh_alua.c | 7 ++++--- drivers/scsi/scsi.c | 3 +++ drivers/scsi/scsi_error.c | 1 + drivers/scsi/scsi_lib.c | 9 ++++++++- include/scsi/scsi.h | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +4 -3
@@ -233,7 +233,7 @@ static void stpg_endio(struct request *req, int error) goto done; } err =alua_check_sense (h->sdev, &sense_hdr); -if (err ==ADD_TO_MLQUEUE ) { +if (err ==ADD_TO_MLQUEUE || err ==ADD_TO_MLQUEUE_DELAY ) { err =SCSI_DH_RETRY ; goto done; }
@@ -443,7 +443,7 @@ static int alua_check_sense(struct scsi_device *sdev,/* * LUN Not Accessible - ALUA state transition */ -return ADD_TO_MLQUEUE ; +return ADD_TO_MLQUEUE_DELAY ;if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x0b )/* * LUN Not Accessible -- Target port in standby state
@@ -521,7 +521,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)return SCSI_DH_IO ; err =alua_check_sense (sdev, &sense_hdr); -if (err ==ADD_TO_MLQUEUE &&time_before (jiffies, expiry)) +if ((err ==ADD_TO_MLQUEUE || err ==ADD_TO_MLQUEUE_DELAY ) && +time_before (jiffies, expiry)) goto retry; sdev_printk(KERN_INFO, sdev, "%s: rtpg sense code %02x/%02x/%02x\n",
drivers/scsi/scsi.c +3 -0
@@ -600,6 +600,9 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)case ADD_TO_MLQUEUE :printk ("MLQUEUE\n" );break ; +case ADD_TO_MLQUEUE_DELAY : +printk ("MLQUEUE_DELAY\n" ); +break ;case FAILED :printk ("FAILED\n" );break ;
drivers/scsi/scsi_error.c +1 -0
@@ -812,6 +812,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,case TARGET_ERROR :break ;case ADD_TO_MLQUEUE : +case ADD_TO_MLQUEUE_DELAY : rtn =NEEDS_RETRY ;break ;default :
drivers/scsi/scsi_lib.c +8 -1
@@ -139,6 +139,7 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)break ;case SCSI_MLQUEUE_DEVICE_BUSY :case SCSI_MLQUEUE_EH_RETRY : +case SCSI_MLQUEUE_DEV_DLY_RTY : device->device_blocked = device->max_device_blocked;break ;case SCSI_MLQUEUE_TARGET_BUSY :
@@ -161,7 +162,10 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)blk_requeue_request (q, cmd->request);spin_unlock_irqrestore (q->queue_lock, flags); -kblockd_schedule_work (q, &device->requeue_work); +if (reason ==SCSI_MLQUEUE_DEV_DLY_RTY ) +blk_delay_queue (q,2000 ); +else +kblockd_schedule_work (q, &device->requeue_work);return 0 ; }
@@ -1465,6 +1469,9 @@ static void scsi_softirq_done(struct request *rq)case ADD_TO_MLQUEUE :scsi_queue_insert (cmd,SCSI_MLQUEUE_DEVICE_BUSY );break ; +case ADD_TO_MLQUEUE_DELAY : +scsi_queue_insert (cmd,SCSI_MLQUEUE_DEV_DLY_RTY ); +break ;default :if (!scsi_eh_scmd_add (cmd,0 ))scsi_finish_command (cmd);
include/scsi/scsi.h +3 -1
@@ -466,9 +466,10 @@ static inline int scsi_is_wlun(unsigned int lun)#define SOFT_ERROR 0x2005#define ADD_TO_MLQUEUE 0x2006#define TIMEOUT_ERROR 0x2007 -#define SCSI_RETURN_NOT_HANDLED 0x2008 +#define SCSI_RETURN_NOT_HANDLED 0x2008#define FAST_IO_FAIL 0x2009#define TARGET_ERROR 0x200A +#define ADD_TO_MLQUEUE_DELAY 0x200B/* * Midlevel queue return values.
@@ -477,6 +478,7 @@ static inline int scsi_is_wlun(unsigned int lun)#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056#define SCSI_MLQUEUE_EH_RETRY 0x1057#define SCSI_MLQUEUE_TARGET_BUSY 0x1058 +#define SCSI_MLQUEUE_DEV_DLY_RTY 0x1059/* * Use these to separate status msg and our bytes
Signature · 1 line
1.7.4.2
Quoted 131 lines · Rob Evers
When alua targets are transitioning, the scsi midlayer retry mechanism continuously retries the scsi commands that are returning with not ready transitioning status. The target is not capable of handling the commands for time on the order of several seconds during these transistions.
This patch delays the device queue for 2 seconds, which is in the same order of aas transition time.
Also, handle all other cases where
ADD_TO_MLQUEUE_DELAYcould be returned instead ofADD_TO_MLQUEUEas ifADD_TO_MLQUEUEwere being returned.Problem found by array partner testing
Signed-off-by Rob Evers <[email protected]>--- drivers/scsi/device_handler/scsi_dh_alua.c | 7 ++++--- drivers/scsi/scsi.c | 3 +++ drivers/scsi/scsi_error.c | 1 + drivers/scsi/scsi_lib.c | 9 ++++++++- include/scsi/scsi.h | 4 +++- 5 files changed, 19 insertions(+), 5 deletions(-)drivers/scsi/device_handler/scsi_dh_alua.c +4
-3@@ -233,7 +233,7 @@ static void stpg_endio(struct request *req, int error) goto done; } err =alua_check_sense (h->sdev, &sense_hdr); -if (err ==ADD_TO_MLQUEUE ) { +if (err ==ADD_TO_MLQUEUE || err ==ADD_TO_MLQUEUE_DELAY ) { err =SCSI_DH_RETRY ; goto done; }@@ -443,7 +443,7 @@ static int alua_check_sense(struct scsi_device *sdev,/* * LUN Not Accessible - ALUA state transition */ -return ADD_TO_MLQUEUE ; +return ADD_TO_MLQUEUE_DELAY ;if (sense_hdr->asc ==0x04 && sense_hdr->ascq ==0x0b )/* * LUN Not Accessible -- Target port in standby state @@ -521,7 +521,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_dh_data *h)return SCSI_DH_IO ; err =alua_check_sense (sdev, &sense_hdr); -if (err ==ADD_TO_MLQUEUE &&time_before (jiffies, expiry)) +if ((err ==ADD_TO_MLQUEUE || err ==ADD_TO_MLQUEUE_DELAY ) && +time_before (jiffies, expiry)) goto retry; sdev_printk(KERN_INFO, sdev, "%s: rtpg sense code %02x/%02x/%02x\n",drivers/scsi/scsi.c +3
-0@@ -600,6 +600,9 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)case ADD_TO_MLQUEUE :printk ("MLQUEUE\n" );break ; +case ADD_TO_MLQUEUE_DELAY : +printk ("MLQUEUE_DELAY\n" ); +break ;case FAILED :printk ("FAILED\n" );break ;drivers/scsi/scsi_error.c +1
-0@@ -812,6 +812,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,case TARGET_ERROR :break ;case ADD_TO_MLQUEUE : +case ADD_TO_MLQUEUE_DELAY : rtn =NEEDS_RETRY ;break ;default :drivers/scsi/scsi_lib.c +8
-1@@ -139,6 +139,7 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)break ;case SCSI_MLQUEUE_DEVICE_BUSY :case SCSI_MLQUEUE_EH_RETRY : +case SCSI_MLQUEUE_DEV_DLY_RTY : device->device_blocked = device->max_device_blocked;break ;case SCSI_MLQUEUE_TARGET_BUSY :@@ -161,7 +162,10 @@ static int __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, int unbusy)blk_requeue_request (q, cmd->request);spin_unlock_irqrestore (q->queue_lock, flags); -kblockd_schedule_work (q, &device->requeue_work); +if (reason ==SCSI_MLQUEUE_DEV_DLY_RTY ) +blk_delay_queue (q,2000 ); +else +kblockd_schedule_work (q, &device->requeue_work);return 0 ; }@@ -1465,6 +1469,9 @@ static void scsi_softirq_done(struct request *rq)case ADD_TO_MLQUEUE :scsi_queue_insert (cmd,SCSI_MLQUEUE_DEVICE_BUSY );break ; +case ADD_TO_MLQUEUE_DELAY : +scsi_queue_insert (cmd,SCSI_MLQUEUE_DEV_DLY_RTY ); +break ;default :if (!scsi_eh_scmd_add (cmd,0 ))scsi_finish_command (cmd);include/scsi/scsi.h +2
-1@@ -466,9 +466,10 @@ static inline int scsi_is_wlun(unsigned int lun)#define SOFT_ERROR 0x2005#define ADD_TO_MLQUEUE 0x2006#define TIMEOUT_ERROR 0x2007 -#define SCSI_RETURN_NOT_HANDLED 0x2008 +#define SCSI_RETURN_NOT_HANDLED 0x2008#define FAST_IO_FAIL 0x2009#define TARGET_ERROR 0x200A +#define ADD_TO_MLQUEUE_DELAY 0x200B/* * Midlevel queue return values.
include/scsi/scsi.h static inline int scsi_is_wlun(unsigned int lun) · line 482
Quoted 5 lines
include/scsi/scsi.h +1
-0@@ -477,6 +478,7 @@ static inline int scsi_is_wlun(unsigned int lun)#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056#define SCSI_MLQUEUE_EH_RETRY 0x1057#define SCSI_MLQUEUE_TARGET_BUSY 0x1058 +#define SCSI_MLQUEUE_DEV_DLY_RTY 0x1059
Can't we just name it 'MLQUEUE_DELAYED_RETRY'?
'MLQUEUE_DEV_DLY_RTY' is a bit unwieldy ...
Other than that: Looks good.
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html