Skip to contentSkip to conversation

Add 'tpgs' sysfs attribute for SCSI devices

PATCH In review Hannes Reinecke 3 participants 3 messages Mar 19, 2009 – Apr 16, 2009 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add 'tpgs' sysfs attribute for SCSI devices

We need the 'TGPS' setting of the inquiry data
to properly support ALUA. So just add an accessor
for the stored inquiry data and display it
in sysfs.

---
 drivers/scsi/scsi_sysfs.c  |   10 ++++++++++
 include/scsi/scsi_device.h |    5 +++++
 2 files changed, 15 insertions(+), 0 deletions(-)
drivers/scsi/scsi_sysfs.c +10 -0
index fa4711d..cccdd89 100644
@@ -586,6 +586,15 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
 
 static ssize_t
+sdev_show_tpgs (struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct scsi_device *sdev;
+	sdev = to_scsi_device(dev);
+	return snprintf(buf, 20, "%d\n", scsi_device_tpgs(sdev));
+}
+static DEVICE_ATTR(tpgs, S_IRUGO, sdev_show_tpgs, NULL);
+
+static ssize_t
 store_rescan_field (struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
@@ -745,6 +754,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 	&dev_attr_vendor.attr,
 	&dev_attr_model.attr,
 	&dev_attr_rev.attr,
+	&dev_attr_tpgs.attr,
 	&dev_attr_rescan.attr,
 	&dev_attr_delete.attr,
 	&dev_attr_state.attr,
include/scsi/scsi_device.h +5 -0
index 3f566af..6ac6321 100644
@@ -450,6 +450,11 @@ static inline int scsi_device_protection(struct scsi_device *sdev)
 	return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
 }
 
+static inline int scsi_device_tpgs(struct scsi_device *sdev)
+{
+	return (sdev->inquiry[5] >> 4) &3;
+}
+
 #define MODULE_ALIAS_SCSI_DEVICE(type) \
 	MODULE_ALIAS("scsi:t-" __stringify(type) "*")
 #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
Signature · 1 line
1.5.3.2
Acked-by on v1 1/2
#1 lore raw
Quoted 6 lines · Hannes Reinecke

We need the 'TGPS' setting of the inquiry data
to properly support ALUA. So just add an accessor
for the stored inquiry data and display it
in sysfs.

Quoted 49 lines
---
 drivers/scsi/scsi_sysfs.c  |   10 ++++++++++
 include/scsi/scsi_device.h |    5 +++++
 2 files changed, 15 insertions(+), 0 deletions(-)
drivers/scsi/scsi_sysfs.c +10 -0
index fa4711d..cccdd89 100644
@@ -586,6 +586,15 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
 
 static ssize_t
+sdev_show_tpgs (struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct scsi_device *sdev;
+	sdev = to_scsi_device(dev);
+	return snprintf(buf, 20, "%d\n", scsi_device_tpgs(sdev));
+}
+static DEVICE_ATTR(tpgs, S_IRUGO, sdev_show_tpgs, NULL);
+
+static ssize_t
 store_rescan_field (struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
@@ -745,6 +754,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 	&dev_attr_vendor.attr,
 	&dev_attr_model.attr,
 	&dev_attr_rev.attr,
+	&dev_attr_tpgs.attr,
 	&dev_attr_rescan.attr,
 	&dev_attr_delete.attr,
 	&dev_attr_state.attr,
include/scsi/scsi_device.h +5 -0
index 3f566af..6ac6321 100644
@@ -450,6 +450,11 @@ static inline int scsi_device_protection(struct scsi_device *sdev)
 	return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
 }
 
+static inline int scsi_device_tpgs(struct scsi_device *sdev)
+{
+	return (sdev->inquiry[5] >> 4) &3;
+}
+
 #define MODULE_ALIAS_SCSI_DEVICE(type) \
 	MODULE_ALIAS("scsi:t-" __stringify(type) "*")
 #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
Acked-by on v1 1/2
#2 lore raw
In reply to Hannes Reinecke

Looks good to me

Quoted 55 lines · Hannes Reinecke

We need the 'TGPS' setting of the inquiry data
to properly support ALUA. So just add an accessor
for the stored inquiry data and display it
in sysfs.

---
 drivers/scsi/scsi_sysfs.c  |   10 ++++++++++
 include/scsi/scsi_device.h |    5 +++++
 2 files changed, 15 insertions(+), 0 deletions(-)
drivers/scsi/scsi_sysfs.c +10 -0
index fa4711d..cccdd89 100644
@@ -586,6 +586,15 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr,
 static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout);
 
 static ssize_t
+sdev_show_tpgs (struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct scsi_device *sdev;
+	sdev = to_scsi_device(dev);
+	return snprintf(buf, 20, "%d\n", scsi_device_tpgs(sdev));
+}
+static DEVICE_ATTR(tpgs, S_IRUGO, sdev_show_tpgs, NULL);
+
+static ssize_t
 store_rescan_field (struct device *dev, struct device_attribute *attr,
 		    const char *buf, size_t count)
 {
@@ -745,6 +754,7 @@ static struct attribute *scsi_sdev_attrs[] = {
 	&dev_attr_vendor.attr,
 	&dev_attr_model.attr,
 	&dev_attr_rev.attr,
+	&dev_attr_tpgs.attr,
 	&dev_attr_rescan.attr,
 	&dev_attr_delete.attr,
 	&dev_attr_state.attr,
include/scsi/scsi_device.h +5 -0
index 3f566af..6ac6321 100644
@@ -450,6 +450,11 @@ static inline int scsi_device_protection(struct scsi_device *sdev)
 	return sdev->scsi_level > SCSI_2 && sdev->inquiry[5] & (1<<0);
 }
 
+static inline int scsi_device_tpgs(struct scsi_device *sdev)
+{
+	return (sdev->inquiry[5] >> 4) &3;
+}
+
 #define MODULE_ALIAS_SCSI_DEVICE(type) \
 	MODULE_ALIAS("scsi:t-" __stringify(type) "*")
 #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"