aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-05-19 08:07:05 -0400
committerJeff Garzik <jeff@garzik.org>2006-05-20 00:39:08 -0400
commitf8bbfc247efb0e5fa69094614380768ce79afe17 (patch)
tree726b8eb9d41b5f7036c987b80282b90440a295ed
parenta20f33ffde8ba5fb27666aa1e228a45b7e3b8dcb (diff)
[PATCH] SCSI: make scsi_implement_eh() generic API for SCSI transports
libata implemented a feature to schedule EH without an associated EH by manipulating shost->host_eh_scheduled in ata_scsi_schedule_eh() directly. Move this function to scsi_error.c and rename it to scsi_schedule_eh(). It is now an exported API for SCSI transports and exported via new header file drivers/scsi/scsi_transport_api.h This patch also de-export scsi_eh_wakeup() which was exported specifically for ata_scsi_schedule_eh(). Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/scsi/libata-eh.c3
-rw-r--r--drivers/scsi/libata-scsi.c24
-rw-r--r--drivers/scsi/scsi_error.c23
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_transport_api.h6
-rw-r--r--include/scsi/scsi_eh.h1
6 files changed, 31 insertions, 27 deletions
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 750e734d1c09..71b45ad2c124 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -39,6 +39,7 @@
39#include <scsi/scsi_eh.h> 39#include <scsi/scsi_eh.h>
40#include <scsi/scsi_device.h> 40#include <scsi/scsi_device.h>
41#include <scsi/scsi_cmnd.h> 41#include <scsi/scsi_cmnd.h>
42#include "scsi_transport_api.h"
42 43
43#include <linux/libata.h> 44#include <linux/libata.h>
44 45
@@ -432,7 +433,7 @@ void ata_port_schedule_eh(struct ata_port *ap)
432 WARN_ON(!ap->ops->error_handler); 433 WARN_ON(!ap->ops->error_handler);
433 434
434 ap->flags |= ATA_FLAG_EH_PENDING; 435 ap->flags |= ATA_FLAG_EH_PENDING;
435 ata_schedule_scsi_eh(ap->host); 436 scsi_schedule_eh(ap->host);
436 437
437 DPRINTK("port EH scheduled\n"); 438 DPRINTK("port EH scheduled\n");
438} 439}
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index f036ae4b8afb..2007b4b6e1b4 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -2745,27 +2745,3 @@ void ata_scsi_scan_host(struct ata_port *ap)
2745 scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0); 2745 scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
2746 } 2746 }
2747} 2747}
2748
2749/**
2750 * ata_schedule_scsi_eh - schedule EH for SCSI host
2751 * @shost: SCSI host to invoke error handling on.
2752 *
2753 * Schedule SCSI EH without scmd. This is a hack.
2754 *
2755 * LOCKING:
2756 * spin_lock_irqsave(host_set lock)
2757 **/
2758void ata_schedule_scsi_eh(struct Scsi_Host *shost)
2759{
2760 unsigned long flags;
2761
2762 spin_lock_irqsave(shost->host_lock, flags);
2763
2764 if (scsi_host_set_state(shost, SHOST_RECOVERY) == 0 ||
2765 scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY) == 0) {
2766 shost->host_eh_scheduled++;
2767 scsi_eh_wakeup(shost);
2768 }
2769
2770 spin_unlock_irqrestore(shost->host_lock, flags);
2771}
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 9ca71cbefce0..346ab72ebf86 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -56,7 +56,28 @@ void scsi_eh_wakeup(struct Scsi_Host *shost)
56 printk("Waking error handler thread\n")); 56 printk("Waking error handler thread\n"));
57 } 57 }
58} 58}
59EXPORT_SYMBOL_GPL(scsi_eh_wakeup); 59
60/**
61 * scsi_schedule_eh - schedule EH for SCSI host
62 * @shost: SCSI host to invoke error handling on.
63 *
64 * Schedule SCSI EH without scmd.
65 **/
66void scsi_schedule_eh(struct Scsi_Host *shost)
67{
68 unsigned long flags;
69
70 spin_lock_irqsave(shost->host_lock, flags);
71
72 if (scsi_host_set_state(shost, SHOST_RECOVERY) == 0 ||
73 scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY) == 0) {
74 shost->host_eh_scheduled++;
75 scsi_eh_wakeup(shost);
76 }
77
78 spin_unlock_irqrestore(shost->host_lock, flags);
79}
80EXPORT_SYMBOL_GPL(scsi_schedule_eh);
60 81
61/** 82/**
62 * scsi_eh_scmd_add - add scsi cmd to error handling. 83 * scsi_eh_scmd_add - add scsi cmd to error handling.
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index 0b39081113be..27c48274e8cb 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -63,6 +63,7 @@ extern int scsi_delete_timer(struct scsi_cmnd *);
63extern void scsi_times_out(struct scsi_cmnd *cmd); 63extern void scsi_times_out(struct scsi_cmnd *cmd);
64extern int scsi_error_handler(void *host); 64extern int scsi_error_handler(void *host);
65extern int scsi_decide_disposition(struct scsi_cmnd *cmd); 65extern int scsi_decide_disposition(struct scsi_cmnd *cmd);
66extern void scsi_eh_wakeup(struct Scsi_Host *shost);
66extern int scsi_eh_scmd_add(struct scsi_cmnd *, int); 67extern int scsi_eh_scmd_add(struct scsi_cmnd *, int);
67 68
68/* scsi_lib.c */ 69/* scsi_lib.c */
diff --git a/drivers/scsi/scsi_transport_api.h b/drivers/scsi/scsi_transport_api.h
new file mode 100644
index 000000000000..934f0e62bb5c
--- /dev/null
+++ b/drivers/scsi/scsi_transport_api.h
@@ -0,0 +1,6 @@
1#ifndef _SCSI_TRANSPORT_API_H
2#define _SCSI_TRANSPORT_API_H
3
4void scsi_schedule_eh(struct Scsi_Host *shost);
5
6#endif /* _SCSI_TRANSPORT_API_H */
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index 212c983a6a18..d160880b2a87 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -35,7 +35,6 @@ static inline int scsi_sense_valid(struct scsi_sense_hdr *sshdr)
35} 35}
36 36
37 37
38extern void scsi_eh_wakeup(struct Scsi_Host *shost);
39extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, 38extern void scsi_eh_finish_cmd(struct scsi_cmnd *scmd,
40 struct list_head *done_q); 39 struct list_head *done_q);
41extern void scsi_eh_flush_done_q(struct list_head *done_q); 40extern void scsi_eh_flush_done_q(struct list_head *done_q);