summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorStephen M. Cameron <scameron@beardog.cce.hp.com>2009-09-17 13:48:26 -0500
committerJens Axboe <jens.axboe@oracle.com>2009-10-01 21:15:44 +0200
commite272afecaf18912e971374df4605496975942e5c (patch)
treee3dbdedb51da5a48acf50b186ed12b43a614368c /drivers/block
parent3ff1111dc6e27524eeef267ab0ca9b5690594748 (diff)
downloadblackbird-op-linux-e272afecaf18912e971374df4605496975942e5c.tar.gz
blackbird-op-linux-e272afecaf18912e971374df4605496975942e5c.zip
cciss: Add usage_count attribute to each logical drive in /sys
Add usage_count attribute to each logical drive at /sys/devices/<dev>/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 <scameron@beardog.cce.hp.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/cciss.c20
1 files changed, 20 insertions, 0 deletions
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
};
OpenPOWER on IntegriCloud