[ANNOUNCE 7/7] Diskdump 1.0 Release

Takao Indoh
2004-11-29T10:50:19Z

This is a patch for IBM Power Linux RAID driver.

diff -Nur linux-2.6.9.org/drivers/scsi/ipr.c linux-2.6.9/drivers/scsi/ipr.c
--- linux-2.6.9.org/drivers/scsi/ipr.c 2004-10-19 06:55:36.000000000 +0900
+++ linux-2.6.9/drivers/scsi/ipr.c 2004-11-24 19:20:56.889376282 +0900
@@ -71,6 +71,7 @@
#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
+#include <linux/diskdump.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/processor.h>
@@ -1264,7 +1265,13 @@
ipr_initiate_ioa_reset(ioa_cfg, shutdown_type);

spin_unlock_irq(ioa_cfg->host->host_lock);
- wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
+ if (crashdump_mode()) {
+ while (ioa_cfg->in_reset_reload) {
+ diskdump_update();
+ diskdump_mdelay(1);
+ }
+ } else
+ wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
spin_lock_irq(ioa_cfg->host->host_lock);

/* If we got hit with a host reset while we were already resetting
@@ -3288,6 +3295,80 @@
}

/**
+ * ipr_poll - Check for command completion
+ * @sdev: the SCSI device to which the command was queued
+ *
+ * This function is called after the diskdump subsystem has queued an
+ * I/O command to the indicated device. Since interrupts are disabled,
+ * this function is called periodically to detect command completion.
+ * To report completion, ipr_cmd->done() sets a value that our caller
+ * can monitor.
+ **/
+static void ipr_poll(struct scsi_device *sdev)
+{
+ struct ipr_ioa_cfg *ioa_cfg =
+ (struct ipr_ioa_cfg *) sdev->host->hostdata;
+ u16 cmd_index;
+ struct ipr_cmnd *ipr_cmd;
+ unsigned long lock_flags = 0;
+
+ spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
+
+ while ((be32_to_cpu(*ioa_cfg->hrrq_curr) & IPR_HRRQ_TOGGLE_BIT) ==
+ ioa_cfg->toggle_bit) {
+ cmd_index = (be32_to_cpu(*ioa_cfg->hrrq_curr) &
+ IPR_HRRQ_REQ_RESP_HANDLE_MASK) >> IPR_HRRQ_REQ_RESP_HANDLE_SHIFT;
+
+ if (unlikely(cmd_index >= IPR_NUM_CMD_BLKS)) {
+ /* FIXME: Need to abort the diskdump. */
+ panic("Command index %u out of range in %s\n",
+ cmd_index, __FUNCTION__);
+ /*NOTREACHED*/
+ }
+
+ ipr_cmd = ioa_cfg->ipr_cmnd_list[cmd_index];
+ list_del(&ipr_cmd->queue);
+ del_timer(&ipr_cmd->timer);
+ ipr_cmd->done(ipr_cmd);
+
+ if (ioa_cfg->hrrq_curr < ioa_cfg->hrrq_end) {
+ ioa_cfg->hrrq_curr++;
+ } else {
+ ioa_cfg->hrrq_curr = ioa_cfg->hrrq_start;
+ ioa_cfg->toggle_bit ^= 1u;
+ }
+ }
+ spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
+}
+
+/**
+ * ipr_sanity_check - Verify that SCSI device can receive dump
+ * @sdev: the SCSI device
+ *
+ * Called by mid-layer diskdump sanity-check function to determine
+ * whether the indicated device is operational. Caller has already
+ * verified that scsi_device_online(device) is true.
+ *
+ * Return value:
+ * 0 for a good device, < 0 for a bad one
+ */
+static int ipr_sanity_check(struct scsi_device *sdev)
+{
+ struct ipr_ioa_cfg *ioa_cfg;
+ if (!sdev->host) {
+ return -ENXIO;
+ }
+ ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata;
+ if (!ioa_cfg) {
+ return -ENXIO;
+ }
+ if (ioa_cfg->ioa_is_dead) {
+ return -EIO;
+ }
+ return 0;
+}
+
+/**
* ipr_build_ioadl - Build a scatter/gather list and map the buffer
* @ioa_cfg: ioa config struct
* @ipr_cmd: ipr command struct
@@ -3967,7 +4048,9 @@
.use_clustering = ENABLE_CLUSTERING,
.shost_attrs = ipr_ioa_attrs,
.sdev_attrs = ipr_dev_attrs,
- .proc_name = IPR_NAME
+ .proc_name = IPR_NAME,
+ .dump_sanity_check = ipr_sanity_check,
+ .dump_poll = ipr_poll
};

#ifdef CONFIG_PPC_PSERIES