Re: [PATCHv2 2/4] scsi: Export blacklist flags to sysfs

2017-08-11 Thread Hannes Reinecke
On 08/11/2017 02:43 AM, Martin K. Petersen wrote:
> 
> Hannes,
> 
>> Each scsi device is scanned according to the found blacklist flags,
>> but this information is never presented to sysfs.  This makes it quite
>> hard to figure out if blacklisting worked as expected.  With this
>> patch we're exporting an additional attribute 'blacklist' containing
>> the blacklist flags for this device.
> 
> There have been changes to the blacklist values over the years so I'm
> not so keen on exporting them as a numbers.
> 
Ah, good to know.
I was thinking of exporting them as text; 'tis better for a quick check
anyway.
Would that be acceptable?

Cheers,

Hannes
-- 
Dr. Hannes ReineckezSeries & Storage
h...@suse.com  +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)


Re: [PATCHv2 2/4] scsi: Export blacklist flags to sysfs

2017-08-10 Thread Martin K. Petersen

Hannes,

> Each scsi device is scanned according to the found blacklist flags,
> but this information is never presented to sysfs.  This makes it quite
> hard to figure out if blacklisting worked as expected.  With this
> patch we're exporting an additional attribute 'blacklist' containing
> the blacklist flags for this device.

There have been changes to the blacklist values over the years so I'm
not so keen on exporting them as a numbers.

-- 
Martin K. Petersen  Oracle Linux Engineering


[PATCHv2 2/4] scsi: Export blacklist flags to sysfs

2017-08-09 Thread Hannes Reinecke
Each scsi device is scanned according to the found blacklist flags,
but this information is never presented to sysfs.
This makes it quite hard to figure out if blacklisting worked as
expected.
With this patch we're exporting an additional attribute 'blacklist'
containing the blacklist flags for this device.

Signed-off-by: Hannes Reinecke 
---
 drivers/scsi/scsi_scan.c  |  1 +
 drivers/scsi/scsi_sysfs.c | 11 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 3832ba5..e4e4374 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -984,6 +984,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned 
char *inq_result,
scsi_attach_vpd(sdev);
 
sdev->max_queue_depth = sdev->queue_depth;
+   sdev->sdev_bflags = *bflags;
 
/*
 * Ok, the device is now all set up, we can
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 5e8ace2..37d436b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -953,6 +953,16 @@ static DEVICE_ATTR(queue_depth, S_IRUGO | S_IWUSR, 
sdev_show_queue_depth,
 }
 static DEVICE_ATTR(wwid, S_IRUGO, sdev_show_wwid, NULL);
 
+static ssize_t
+sdev_show_blacklist(struct device *dev, struct device_attribute *attr,
+   char *buf)
+{
+   struct scsi_device *sdev = to_scsi_device(dev);
+
+   return snprintf (buf, 20, "0x%x\n", sdev->sdev_bflags);
+}
+static DEVICE_ATTR(blacklist, S_IRUGO, sdev_show_blacklist, NULL);
+
 #ifdef CONFIG_SCSI_DH
 static ssize_t
 sdev_show_dh_state(struct device *dev, struct device_attribute *attr,
@@ -1138,6 +1148,7 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct 
kobject *kobj,
_attr_queue_depth.attr,
_attr_queue_type.attr,
_attr_wwid.attr,
+   _attr_blacklist.attr,
 #ifdef CONFIG_SCSI_DH
_attr_dh_state.attr,
_attr_access_state.attr,
-- 
1.8.5.6