2008-10-07 16:25:15

by Mike Miller

[permalink] [raw]
Subject: [PATCH 1 of 1] cciss: add procfs interface to rescan logical volumes

Patch 1 of 1

This patch adds a procfs interface so users can force a rescan of the
logical volumes attached to the controller. A new product uses Target Based
Management (TBM) out-of-band for configuration purposes. With this method
the driver has no way of knowing that something has changed, i.e., new
logical volume(s) added or existing volumes deleted.
This interface allows the user to echo "rescan volumes" >
/proc/driver/cciss/ccissN to force the driver to rebuild our table of
logical volumes.
Please consider this patch for inclusion.

Thanks,
mikem

Signed-off-by: Mike Miller <[email protected]>

diff --git a/Documentation/cciss.txt b/Documentation/cciss.txt
index 8244c64..afda23d 100644
--- a/Documentation/cciss.txt
+++ b/Documentation/cciss.txt
@@ -166,3 +166,17 @@ is issued which positions the tape to a known position. Typically you
must rewind the tape (by issuing "mt -f /dev/st0 rewind" for example)
before i/o can proceed again to a tape drive which was reset.

+Rescanning for changes in configuration
+---------------------------------------
+
+Some new products use Target Based Management (TBM) for configuration
+purposes. These products cannot inform the driver that a new logical volume
+has been added, an existing volume deleted, or of change in the size of a
+logical volume.
+A procfs interface has been added to facilitate a rescan of the devices
+attached to the controller. If a change is made the user may then issue:
+
+ # echo "rescan volumes" > /proc/driver/cciss/ccissN
+
+where N is the controller number. This will force the driver to update the
+configuration.
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b73116e..76b5b33 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -249,6 +249,7 @@ static inline CommandList_struct *removeQ(CommandList_struct **Qptr,
#define ENG_GIG 1000000000
#define ENG_GIG_FACTOR (ENG_GIG/512)
#define ENGAGE_SCSI "engage scsi"
+#define RESCAN_VOLUMES "rescan volumes"
static const char *raid_label[] = { "0", "4", "1(1+0)", "5", "5+1", "ADG",
"UNKNOWN"
};
@@ -379,7 +380,9 @@ static ssize_t
cciss_proc_write(struct file *file, const char __user *buf,
size_t length, loff_t *ppos)
{
- int err;
+ struct seq_file *seq = file->private_data;
+ ctlr_info_t *h = seq->private;
+ int err, rc;
char *buffer;

#ifndef CONFIG_CISS_SCSI_TAPE
@@ -398,12 +401,26 @@ cciss_proc_write(struct file *file, const char __user *buf,
goto out;
buffer[length] = '\0';

+ /* For the MSA2000 the firmware cannot tell the driver to
+ * rescan when new logical volumes are created. We provide
+ * this interface so users can `echo "rescan volumes" >
+ * /proc/driver/cciss/ccissN` to accomplish that task. It's not
+ * the best solution because it must be done on every server
+ * that connected to the storage.
+ */
+
+ if (strncmp(RESCAN_VOLUMES, buffer, sizeof RESCAN_VOLUMES - 1) == 0) {
+ /* rebuild_lun_table returns -1 on success to tell ACU
+ * to quit calling it. In this case we just ignore any
+ * return code.
+ */
+ (void) rebuild_lun_table(h, NULL);
+ err = length;
+ goto out;
+ }
+
#ifdef CONFIG_CISS_SCSI_TAPE
if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) {
- struct seq_file *seq = file->private_data;
- ctlr_info_t *h = seq->private;
- int rc;
-
rc = cciss_engage_scsi(h->ctlr);
if (rc != 0)
err = -rc;


2008-10-07 16:35:48

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [PATCH 1 of 1] cciss: add procfs interface to rescan logical volumes

On Tue, 7 Oct 2008 11:24:54 -0500
Mike Miller <[email protected]> wrote:

> Patch 1 of 1
>
> This patch adds a procfs interface so users can force a rescan of the
> logical volumes attached to the controller. A new product uses Target
> Based Management (TBM) out-of-band for configuration purposes. With
> this method the driver has no way of knowing that something has
> changed, i.e., new logical volume(s) added or existing volumes
> deleted. This interface allows the user to echo "rescan volumes" >
> /proc/driver/cciss/ccissN to force the driver to rebuild our table of
> logical volumes.
> Please consider this patch for inclusion.


I'll ask the obvious question (since you didn't address this)...
why is this a proc thing and not just a sysfs attribute of the device?


--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org

2008-10-07 17:34:24

by Mike Miller

[permalink] [raw]
Subject: RE: [PATCH 1 of 1] cciss: add procfs interface to rescan logical volumes



> -----Original Message-----
> From: Arjan van de Ven [mailto:[email protected]]
> Sent: Tuesday, October 07, 2008 11:36 AM
> To: Miller, Mike (OS Dev)
> Cc: Andrew Morton; [email protected]; LKML; LKML-scsi
> Subject: Re: [PATCH 1 of 1] cciss: add procfs interface to
> rescan logical volumes
>
> On Tue, 7 Oct 2008 11:24:54 -0500
> Mike Miller <[email protected]> wrote:
>
> > Patch 1 of 1
> >
> > This patch adds a procfs interface so users can force a
> rescan of the
> > logical volumes attached to the controller. A new product
> uses Target
> > Based Management (TBM) out-of-band for configuration purposes. With
> > this method the driver has no way of knowing that something has
> > changed, i.e., new logical volume(s) added or existing volumes
> > deleted. This interface allows the user to echo "rescan volumes" >
> > /proc/driver/cciss/ccissN to force the driver to rebuild
> our table of
> > logical volumes.
> > Please consider this patch for inclusion.
>
>
> I'll ask the obvious question (since you didn't address this)...
> why is this a proc thing and not just a sysfs attribute of the device?
>

Because I'm pretty sysfs stupid. :(

An attribute in sysfs is the ultimate goal but I did this for expediency. Any pointers to sysfs documentation that's either not very outdated or doesn't contradict itself?

Thanks,
mikem

>
> --
> Arjan van de Ven Intel Open Source Technology Centre
> For development, discussion and tips for power savings, visit
> http://www.lesswatts.org
>