]> err.no Git - linux-2.6/commitdiff
[SCSI] aacraid: add sysfs report of RAID level
authorSalyzyn, Mark <Mark_Salyzyn@adaptec.com>
Tue, 8 Jan 2008 20:23:49 +0000 (12:23 -0800)
committerJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 23 Jan 2008 17:29:19 +0000 (11:29 -0600)
Report the RAID level string for the SCSI device representing the
array. Report is in /sys/class/scsi_device/#:#:#:#/device/level.

Signed-off-by: Mark Salyzyn <aacraid@adaptec.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/aacraid.h
drivers/scsi/aacraid/linit.c

index 43d6aff460d2ca612b24c0bdbbfc9f9e7de8a155..eee65c145cb8b6e85fc39e6cbe3b7e146e58c34f 100644 (file)
@@ -690,7 +690,12 @@ static char *container_types[] = {
         "Unknown"
 };
 
-
+char * get_container_type(unsigned tindex)
+{
+       if (tindex >= ARRAY_SIZE(container_types))
+               tindex = ARRAY_SIZE(container_types) - 1;
+       return container_types[tindex];
+}
 
 /* Function: setinqstr
  *
index 7bb3d9fde713ae520368041ff032cab5effa5729..6d4e24cea3dc72e6c8c4d05ef7f16c1637990c97 100644 (file)
@@ -1869,6 +1869,7 @@ int aac_probe_container(struct aac_dev *dev, int cid);
 int _aac_rx_init(struct aac_dev *dev);
 int aac_rx_select_comm(struct aac_dev *dev, int comm);
 int aac_rx_deliver_producer(struct fib * fib);
+char * get_container_type(unsigned type);
 extern int numacb;
 extern int acbsize;
 extern char aac_driver_version[];
index b4ad9effcf50a4bc2c4c9b6e07d155c462504bf2..e6bdc930d52881e212fcf5acdb8e055ace949716 100644 (file)
@@ -487,6 +487,30 @@ static int aac_change_queue_depth(struct scsi_device *sdev, int depth)
        return sdev->queue_depth;
 }
 
+static ssize_t aac_show_raid_level(struct device *dev, struct device_attribute *attr, char *buf)
+{
+       struct scsi_device * sdev = to_scsi_device(dev);
+       if (sdev_channel(sdev) != CONTAINER_CHANNEL)
+               return snprintf(buf, PAGE_SIZE, sdev->no_uld_attach
+                 ? "Hidden\n" : "JBOD");
+       return snprintf(buf, PAGE_SIZE, "%s\n",
+         get_container_type(((struct aac_dev *)(sdev->host->hostdata))
+           ->fsa_dev[sdev_id(sdev)].type));
+}
+
+static struct device_attribute aac_raid_level_attr = {
+       .attr = {
+               .name = "level",
+               .mode = S_IRUGO,
+       },
+       .show = aac_show_raid_level
+};
+
+static struct device_attribute *aac_dev_attrs[] = {
+       &aac_raid_level_attr,
+       NULL,
+};
+
 static int aac_ioctl(struct scsi_device *sdev, int cmd, void __user * arg)
 {
        struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
@@ -941,6 +965,7 @@ static struct scsi_host_template aac_driver_template = {
        .shost_attrs                    = aac_attrs,
        .slave_configure                = aac_slave_configure,
        .change_queue_depth             = aac_change_queue_depth,
+       .sdev_attrs                     = aac_dev_attrs,
        .eh_abort_handler               = aac_eh_abort,
        .eh_host_reset_handler          = aac_eh_reset,
        .can_queue                      = AAC_NUM_IO_FIB,