[PATCH] libata-eh: implement ata_eh_info and ata_eh_context
struct ata_eh_info serves as the communication channel between
execution path and EH. Execution path describes detected error
condition in ap->eh_info and EH recovers the port using it. To avoid
missing error conditions detected during EH, EH makes its own copy of
eh_info and clears it on entry allowing error info to accumulate
during EH.
Most EH states including EH's copy of eh_info are stored in
ap->eh_context (struct ata_eh_context) which is owned by EH and thus
doesn't require any synchronization to access and alter. This
standardized context makes it easy to integrate various parts of EH
and extend EH to handle multiple links (for PM).
Signed-off-by: Tejun Heo <htejun@gmail.com>
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c
index 71ad18b..1968f2d 100644
--- a/drivers/scsi/libata-eh.c
+++ b/drivers/scsi/libata-eh.c
@@ -229,9 +229,15 @@
repeat:
/* invoke error handler */
if (ap->ops->error_handler) {
- /* clear EH pending */
+ /* fetch & clear EH info */
spin_lock_irqsave(hs_lock, flags);
+
+ memset(&ap->eh_context, 0, sizeof(ap->eh_context));
+ ap->eh_context.i = ap->eh_info;
+ memset(&ap->eh_info, 0, sizeof(ap->eh_info));
+
ap->flags &= ~ATA_FLAG_EH_PENDING;
+
spin_unlock_irqrestore(hs_lock, flags);
/* invoke EH */
@@ -255,6 +261,9 @@
"tries, giving up\n", ATA_EH_MAX_REPEAT);
}
+ /* this run is complete, make sure EH info is clear */
+ memset(&ap->eh_info, 0, sizeof(ap->eh_info));
+
/* Clear host_eh_scheduled while holding hs_lock such
* that if exception occurs after this point but
* before EH completion, SCSI midlayer will