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

From: Mike Miller
Date: Tue Oct 07 2008 - 12:25:17 EST


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 <mike.miller@xxxxxx>

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;
--
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/