From 547ca674cb892c1f64746ea1f68f5ef6b2361d49 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Mon, 25 Oct 2010 15:53:41 -0500 Subject: [PATCH] --- yaml --- r: 226751 b: refs/heads/master c: 98db519573e805f9f7e988fb5661da951fcb16b1 h: refs/heads/master i: 226749: d137f81610ea838289bd55f1eef55f816fb7f438 226747: cbc11701dd96e649bafade02ade896df3f4d04a6 226743: 827f11aa5ba9f16c9a64ea5f52720c4701a8d484 226735: 8bb742187541bc50f8e17801979076a41db82904 226719: 8eafdf85fa80177a2d015d927016f7a07569ea0b 226687: 9759ab0798c3d956d6afacb84b1b2a864267f2e2 v: v3 --- [refs] | 2 +- trunk/drivers/scsi/scsi_error.c | 61 ++++++++++++++------------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/[refs] b/[refs] index bcd2a33775d6..e619b42acaba 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 110def851fc823bb1a4584cb6308e30e5ffb3e05 +refs/heads/master: 98db519573e805f9f7e988fb5661da951fcb16b1 diff --git a/trunk/drivers/scsi/scsi_error.c b/trunk/drivers/scsi/scsi_error.c index 30ac116186f5..45c75649b9e0 100644 --- a/trunk/drivers/scsi/scsi_error.c +++ b/trunk/drivers/scsi/scsi_error.c @@ -1124,51 +1124,40 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost, struct list_head *work_q, struct list_head *done_q) { - struct scsi_cmnd *scmd, *tgtr_scmd, *next; - unsigned int id = 0; - int rtn; + LIST_HEAD(tmp_list); - do { - tgtr_scmd = NULL; - list_for_each_entry(scmd, work_q, eh_entry) { - if (id == scmd_id(scmd)) { - tgtr_scmd = scmd; - break; - } - } - if (!tgtr_scmd) { - /* not one exactly equal; find the next highest */ - list_for_each_entry(scmd, work_q, eh_entry) { - if (scmd_id(scmd) > id && - (!tgtr_scmd || - scmd_id(tgtr_scmd) > scmd_id(scmd))) - tgtr_scmd = scmd; - } - } - if (!tgtr_scmd) - /* no more commands, that's it */ - break; + list_splice_init(work_q, &tmp_list); + + while (!list_empty(&tmp_list)) { + struct scsi_cmnd *next, *scmd; + int rtn; + unsigned int id; + + scmd = list_entry(tmp_list.next, struct scsi_cmnd, eh_entry); + id = scmd_id(scmd); SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Sending target reset " "to target %d\n", current->comm, id)); - rtn = scsi_try_target_reset(tgtr_scmd); - if (rtn == SUCCESS || rtn == FAST_IO_FAIL) { - list_for_each_entry_safe(scmd, next, work_q, eh_entry) { - if (id == scmd_id(scmd)) - if (!scsi_device_online(scmd->device) || - rtn == FAST_IO_FAIL || - !scsi_eh_tur(tgtr_scmd)) - scsi_eh_finish_cmd(scmd, - done_q); - } - } else + rtn = scsi_try_target_reset(scmd); + if (rtn != SUCCESS && rtn != FAST_IO_FAIL) SCSI_LOG_ERROR_RECOVERY(3, printk("%s: Target reset" " failed target: " "%d\n", current->comm, id)); - id++; - } while(id != 0); + list_for_each_entry_safe(scmd, next, &tmp_list, eh_entry) { + if (scmd_id(scmd) != id) + continue; + + if ((rtn == SUCCESS || rtn == FAST_IO_FAIL) + && (!scsi_device_online(scmd->device) || + rtn == FAST_IO_FAIL || !scsi_eh_tur(scmd))) + scsi_eh_finish_cmd(scmd, done_q); + else + /* push back on work queue for further processing */ + list_move(&scmd->eh_entry, work_q); + } + } return list_empty(work_q); }