From d6f4965d7d2e718eb9b223cb06db5f6a53b73507 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Thu, 17 Sep 2009 13:47:03 -0500 Subject: cciss: Allow triggering of rescan of logical drive topology via sysfs entry Added /sys/bus/pci/devices//ccissX/rescan sysfs entry used to kick off a rescan that discovers logical drive topology changes. Signed-off-by: Andrew Patterson Signed-off-by: Stephen M. Cameron Acked-by: Mike Miller Signed-off-by: Jens Axboe --- Documentation/ABI/testing/sysfs-bus-pci-devices-cciss | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Documentation') diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss index 0a92a7c93a62..ac3429def235 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss @@ -31,3 +31,10 @@ Date: March 2009 Kernel Version: 2.6.30 Contact: iss_storagedev@hp.com Description: A symbolic link to /sys/block/cciss!cXdY + +Where: /sys/bus/pci/devices//ccissX/rescan +Date: August 2009 +Kernel Version: 2.6.31 +Contact: iss_storagedev@hp.com +Description: Kicks of a rescan of the controller to discover logical + drive topology changes. -- cgit v1.2.3-59-g8ed1b From ce84a8aeac4a4a2cc421b3145dd2fb7cae860e4d Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Thu, 17 Sep 2009 13:48:10 -0500 Subject: cciss: Add lunid attribute to each logical drive in /sys Add lunid attribute to each logical drive at /sys/devices//ccissX/cXdY/lunid for controller X, logical drive Y Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- .../ABI/testing/sysfs-bus-pci-devices-cciss | 7 ++++++ drivers/block/cciss.c | 26 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'Documentation') diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss index ac3429def235..5a6c8d36afc4 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss @@ -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//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. diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 79afca2e824f..ae0cb1329e92 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -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 }; -- cgit v1.2.3-59-g8ed1b From 3ff1111dc6e27524eeef267ab0ca9b5690594748 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Thu, 17 Sep 2009 13:48:21 -0500 Subject: cciss: Add a "raid_level" attribute to each logical drive in /sys and change get rid of some magic numbers in raid lavel decoding. Add raid_level attribute to each logical drive at /sys/devices//ccissX/cXdY/raid_level for controller X, logical drive Y Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- .../ABI/testing/sysfs-bus-pci-devices-cciss | 7 +++++++ drivers/block/cciss.c | 24 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'Documentation') diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss index 5a6c8d36afc4..8d0260256168 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss @@ -45,3 +45,10 @@ 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. + +Where: /sys/bus/pci/devices//ccissX/cXdY/raid_level +Date: August 2009 +Kernel Version: 2.6.31 +Contact: iss_storagedev@hp.com +Description: Displays the RAID level of logical drive Y of + controller X. diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index b674f93d4be8..063e8b0834da 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -603,6 +603,29 @@ static ssize_t cciss_show_lunid(struct device *dev, } DEVICE_ATTR(lunid, S_IRUGO, cciss_show_lunid, NULL); +static ssize_t cciss_show_raid_level(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); + int raid; + unsigned long flags; + + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + if (h->busy_configuring) { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EBUSY; + } + raid = drv->raid_level; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + if (raid < 0 || raid > RAID_UNKNOWN) + raid = RAID_UNKNOWN; + + return snprintf(buf, strlen(raid_label[raid]) + 7, "RAID %s\n", + raid_label[raid]); +} +DEVICE_ATTR(raid_level, S_IRUGO, cciss_show_raid_level, NULL); + static struct attribute *cciss_host_attrs[] = { &dev_attr_rescan.attr, NULL @@ -629,6 +652,7 @@ static struct attribute *cciss_dev_attrs[] = { &dev_attr_vendor.attr, &dev_attr_rev.attr, &dev_attr_lunid.attr, + &dev_attr_raid_level.attr, NULL }; -- cgit v1.2.3-59-g8ed1b From e272afecaf18912e971374df4605496975942e5c Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Thu, 17 Sep 2009 13:48:26 -0500 Subject: cciss: Add usage_count attribute to each logical drive in /sys Add usage_count attribute to each logical drive at /sys/devices//ccissX/cXdY/usage_count for controller X, logical drive Y. The usage count is the number of times the device has currently been opened. Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- .../ABI/testing/sysfs-bus-pci-devices-cciss | 7 +++++++ drivers/block/cciss.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'Documentation') diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss index 8d0260256168..4f29e5f1ebfa 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss +++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-cciss @@ -52,3 +52,10 @@ Kernel Version: 2.6.31 Contact: iss_storagedev@hp.com Description: Displays the RAID level of logical drive Y of controller X. + +Where: /sys/bus/pci/devices//ccissX/cXdY/usage_count +Date: August 2009 +Kernel Version: 2.6.31 +Contact: iss_storagedev@hp.com +Description: Displays the usage count (number of opens) of logical drive Y + of controller X. diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 063e8b0834da..b808e9287b73 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c @@ -626,6 +626,25 @@ static ssize_t cciss_show_raid_level(struct device *dev, } DEVICE_ATTR(raid_level, S_IRUGO, cciss_show_raid_level, NULL); +static ssize_t cciss_show_usage_count(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; + int count; + + spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); + if (h->busy_configuring) { + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return -EBUSY; + } + count = drv->usage_count; + spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); + return snprintf(buf, 20, "%d\n", count); +} +DEVICE_ATTR(usage_count, S_IRUGO, cciss_show_usage_count, NULL); + static struct attribute *cciss_host_attrs[] = { &dev_attr_rescan.attr, NULL @@ -653,6 +672,7 @@ static struct attribute *cciss_dev_attrs[] = { &dev_attr_rev.attr, &dev_attr_lunid.attr, &dev_attr_raid_level.attr, + &dev_attr_usage_count.attr, NULL }; -- cgit v1.2.3-59-g8ed1b