cciss: Add lunid attribute to each logical drive in /sys
authorStephen M. Cameron <scameron@beardog.cce.hp.com>
Thu, 17 Sep 2009 18:48:10 +0000 (13:48 -0500)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 1 Oct 2009 19:15:44 +0000 (21:15 +0200)
Add lunid attribute to each logical drive at
/sys/devices/<dev>/ccissX/cXdY/lunid for controller X,
logical drive Y

Signed-off-by: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Documentation/ABI/testing/sysfs-bus-pci-devices-cciss
drivers/block/cciss.c

index ac3429def2350d975b3b9e75ee8a83c938af70e5..5a6c8d36afc4841db5cb62b9811711d9d7bb33e7 100644 (file)
@@ -38,3 +38,10 @@ Kernel Version:      2.6.31
 Contact:       iss_storagedev@hp.com
 Description:   Kicks of a rescan of the controller to discover logical
                drive topology changes.
+
+Where:         /sys/bus/pci/devices/<dev>/ccissX/cXdY/lunid
+Date:          August 2009
+Kernel Version: 2.6.31
+Contact:       iss_storagedev@hp.com
+Description:   Displays the 8-byte LUN ID used to address logical
+               drive Y of controller X.
index 79afca2e824f9dc914ffaf7c1791ee56cb91a729..ae0cb1329e9261a6879f7c21294352209f57ace0 100644 (file)
@@ -579,6 +579,31 @@ static ssize_t dev_show_rev(struct device *dev,
 }
 DEVICE_ATTR(rev, S_IRUGO, dev_show_rev, NULL);
 
+static ssize_t cciss_show_lunid(struct device *dev,
+                               struct device_attribute *attr, char *buf)
+{
+       drive_info_struct *drv = dev_get_drvdata(dev);
+       struct ctlr_info *h = to_hba(drv->dev->parent);
+       unsigned long flags;
+       unsigned char lunid[8];
+
+       spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
+       if (h->busy_configuring) {
+               spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+               return -EBUSY;
+       }
+       if (!drv->heads) {
+               spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+               return -ENOTTY;
+       }
+       memcpy(lunid, drv->LunID, sizeof(lunid));
+       spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
+       return snprintf(buf, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+               lunid[0], lunid[1], lunid[2], lunid[3],
+               lunid[4], lunid[5], lunid[6], lunid[7]);
+}
+DEVICE_ATTR(lunid, S_IRUGO, cciss_show_lunid, NULL);
+
 static struct attribute *cciss_host_attrs[] = {
        &dev_attr_rescan.attr,
        NULL
@@ -604,6 +629,7 @@ static struct attribute *cciss_dev_attrs[] = {
        &dev_attr_model.attr,
        &dev_attr_vendor.attr,
        &dev_attr_rev.attr,
+       &dev_attr_lunid.attr,
        NULL
 };