[PATCH] interface for doing a full host scsi rescan

From: Menny Hamburger
Date: Thu May 10 2007 - 06:02:07 EST


Hi,

When we do want to rescan the SCSI host, a userland script needs to be
provided that does add/remove.
This patch adds an interface for doing this inside the kernel - seems
more appropriate:

--- linux-2.6.20/drivers/scsi/scsi_proc.c 2007-02-04
20:44:54.000000000 +0200
+++ linux-2.6.20_patched/drivers/scsi/scsi_proc.c 2007-05-10
12:52:13.353652000 +0300
@@ -227,6 +227,20 @@
return error;
}

+static int scsi_scan_selected_host(uint host, uint rescan)
+{
+ struct Scsi_Host *shost;
+ int error = -ENXIO;
+
+ shost = scsi_host_lookup(host);
+ if (IS_ERR(shost))
+ return PTR_ERR(shost);
+
+ error = scsi_scan_host_selected(shost, SCAN_WILD_CARD,
SCAN_WILD_CARD, SCAN_WILD_CARD, rescan);
+ scsi_host_put(shost);
+ return error;
+}
+
static ssize_t proc_scsi_write(struct file *file, const char __user
*buf,
size_t length, loff_t *ppos)
{
@@ -278,7 +292,24 @@
lun = simple_strtoul(p + 1, &p, 0);

err = scsi_remove_single_device(host, channel, id, lun);
- }
+ /*
+ * Usage: echo "scsi scan-devices 0 1" >/proc/scsi/scsi
+ * where 0 is Host and 1 is whether to rescan (1) or do a full
scan (0).
+ */
+ } else if(!strncmp("scsi scan-devices", buffer, 17)) {
+ p = buffer + 18;
+
+ host = simple_strtoul(p, &p, 0);
+ rescan = simple_strtoul(p + 1, &p, 0);
+
+ if (rescan)
+ printk(KERN_DEBUG "Rescanning SCSI host %d\n",
host);
+ else
+ printk(KERN_DEBUG "Scanning SCSI host %d\n",
host);
+
+ err = scsi_scan_selected_host(host, rescan);
+ }
+

/*
* convert success returns so that we return the


Menny
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/