mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] interface for doing a full host scsi rescan
@ 2007-05-10 10:01 Menny Hamburger
  2007-05-10 10:09 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Menny Hamburger @ 2007-05-10 10:01 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] interface for doing a full host scsi rescan
  2007-05-10 10:01 [PATCH] interface for doing a full host scsi rescan Menny Hamburger
@ 2007-05-10 10:09 ` Christoph Hellwig
  2007-05-10 11:08   ` Menny Hamburger
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2007-05-10 10:09 UTC (permalink / raw)
  To: Menny Hamburger; +Cc: linux-kernel

On Thu, May 10, 2007 at 01:01:55PM +0300, Menny Hamburger wrote:
> 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:

/proc/scsi/scsi is deprecated, don't use it.  But you can do a full
rescan through /sys/.../scan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] interface for doing a full host scsi rescan
  2007-05-10 10:09 ` Christoph Hellwig
@ 2007-05-10 11:08   ` Menny Hamburger
  0 siblings, 0 replies; 3+ messages in thread
From: Menny Hamburger @ 2007-05-10 11:08 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel

Thnx,

I'll check that

M. 

-----Original Message-----
From: Christoph Hellwig [mailto:hch@infradead.org] 
Sent: Thursday, May 10, 2007 12:10 PM
To: Menny Hamburger
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] interface for doing a full host scsi rescan

On Thu, May 10, 2007 at 01:01:55PM +0300, Menny Hamburger wrote:
> 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:

/proc/scsi/scsi is deprecated, don't use it.  But you can do a full
rescan through /sys/.../scan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-05-10 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-10 10:01 [PATCH] interface for doing a full host scsi rescan Menny Hamburger
2007-05-10 10:09 ` Christoph Hellwig
2007-05-10 11:08   ` Menny Hamburger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®