linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
@ 2016-03-01  4:52 Hannes Reinecke
  2016-03-01  6:45 ` Seymour, Shane M
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Hannes Reinecke @ 2016-03-01  4:52 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, Ewan Milne, Bart van Assche, James Bottomley,
	linux-scsi, Hannes Reinecke, Hannes Reinecke

Add 'is_bin_visible' callback to blank out unsupported vpd pages.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_sysfs.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 00bc721..d8b275b 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1023,6 +1023,28 @@ static umode_t scsi_sdev_attr_is_visible(struct kobject *kobj,
 	return attr->mode;
 }
 
+static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
+					     struct bin_attribute *attr, int i)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct scsi_device *sdev = to_scsi_device(dev);
+
+
+	rcu_read_lock();
+	if (attr == &dev_attr_vpd_pg80 &&
+	    !rcu_dereference(sdev->vpd_pg80)) {
+		rcu_read_unlock();
+		return 0;
+	}
+	if (attr == &dev_attr_vpd_pg83 &&
+	    !rcu_dereference(sdev->vpd_pg83)) {
+		rcu_read_unlock();
+		return 0;
+	}
+	rcu_read_unlock();
+	return S_IRUGO;
+}
+
 /* Default template for device attributes.  May NOT be modified */
 static struct attribute *scsi_sdev_attrs[] = {
 	&dev_attr_device_blocked.attr,
@@ -1068,6 +1090,7 @@ static struct attribute_group scsi_sdev_attr_group = {
 	.attrs =	scsi_sdev_attrs,
 	.bin_attrs =	scsi_sdev_bin_attrs,
 	.is_visible =	scsi_sdev_attr_is_visible,
+	.is_bin_visible = scsi_sdev_bin_attr_is_visible,
 };
 
 static const struct attribute_group *scsi_sdev_attr_groups[] = {
-- 
2.6.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* RE: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-01  4:52 [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
@ 2016-03-01  6:45 ` Seymour, Shane M
  2016-03-01  9:08 ` Johannes Thumshirn
  2016-03-01 13:04 ` Christoph Hellwig
  2 siblings, 0 replies; 7+ messages in thread
From: Seymour, Shane M @ 2016-03-01  6:45 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, Ewan Milne, Bart van Assche, James Bottomley,
	linux-scsi@vger.kernel.org, Hannes Reinecke


Reviewed-by: Shane Seymour <shane.seymour@hpe.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-01  4:52 [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
  2016-03-01  6:45 ` Seymour, Shane M
@ 2016-03-01  9:08 ` Johannes Thumshirn
  2016-03-01 13:04 ` Christoph Hellwig
  2 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2016-03-01  9:08 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, Ewan Milne,
	Bart van Assche, James Bottomley, linux-scsi, Hannes Reinecke

On Tue, Mar 01, 2016 at 05:52:25AM +0100, Hannes Reinecke wrote:
> Add 'is_bin_visible' callback to blank out unsupported vpd pages.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-01  4:52 [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
  2016-03-01  6:45 ` Seymour, Shane M
  2016-03-01  9:08 ` Johannes Thumshirn
@ 2016-03-01 13:04 ` Christoph Hellwig
  2016-03-02  7:33   ` Hannes Reinecke
  2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2016-03-01 13:04 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, Ewan Milne,
	Bart van Assche, James Bottomley, linux-scsi, Hannes Reinecke

On Tue, Mar 01, 2016 at 05:52:25AM +0100, Hannes Reinecke wrote:
> +	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct scsi_device *sdev = to_scsi_device(dev);
> +
> +
> +	rcu_read_lock();
> +	if (attr == &dev_attr_vpd_pg80 &&
> +	    !rcu_dereference(sdev->vpd_pg80)) {
> +		rcu_read_unlock();
> +		return 0;
> +	}
> +	if (attr == &dev_attr_vpd_pg83 &&
> +	    !rcu_dereference(sdev->vpd_pg83)) {
> +		rcu_read_unlock();
> +		return 0;
> +	}
> +	rcu_read_unlock();

We are only checking the pointers for being non-zero.  No need for the
rcu_read_lock() or rcu_dereference() here.

Otherwise this looks fine to me.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-01 13:04 ` Christoph Hellwig
@ 2016-03-02  7:33   ` Hannes Reinecke
  2016-03-02  9:19     ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Hannes Reinecke @ 2016-03-02  7:33 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Martin K. Petersen, Ewan Milne, Bart van Assche, James Bottomley,
	linux-scsi, Hannes Reinecke

On 03/01/2016 09:04 PM, Christoph Hellwig wrote:
> On Tue, Mar 01, 2016 at 05:52:25AM +0100, Hannes Reinecke wrote:
>> +	struct device *dev = container_of(kobj, struct device, kobj);
>> +	struct scsi_device *sdev = to_scsi_device(dev);
>> +
>> +
>> +	rcu_read_lock();
>> +	if (attr == &dev_attr_vpd_pg80 &&
>> +	    !rcu_dereference(sdev->vpd_pg80)) {
>> +		rcu_read_unlock();
>> +		return 0;
>> +	}
>> +	if (attr == &dev_attr_vpd_pg83 &&
>> +	    !rcu_dereference(sdev->vpd_pg83)) {
>> +		rcu_read_unlock();
>> +		return 0;
>> +	}
>> +	rcu_read_unlock();
> 
> We are only checking the pointers for being non-zero.  No need for the
> rcu_read_lock() or rcu_dereference() here.
> 
Better to be same than sorry; some overly clever code analysis tool
might trip over it otherwise.

> Otherwise this looks fine to me.

Reviewed-by: ?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-02  7:33   ` Hannes Reinecke
@ 2016-03-02  9:19     ` Christoph Hellwig
  2016-03-02  9:34       ` Hannes Reinecke
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2016-03-02  9:19 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Christoph Hellwig, Martin K. Petersen, Ewan Milne,
	Bart van Assche, James Bottomley, linux-scsi, Hannes Reinecke

On Wed, Mar 02, 2016 at 03:33:14PM +0800, Hannes Reinecke wrote:
> >> +	rcu_read_lock();
> >> +	if (attr == &dev_attr_vpd_pg80 &&
> >> +	    !rcu_dereference(sdev->vpd_pg80)) {
> >> +		rcu_read_unlock();
> >> +		return 0;
> >> +	}
> >> +	if (attr == &dev_attr_vpd_pg83 &&
> >> +	    !rcu_dereference(sdev->vpd_pg83)) {
> >> +		rcu_read_unlock();
> >> +		return 0;
> >> +	}
> >> +	rcu_read_unlock();
> > 
> > We are only checking the pointers for being non-zero.  No need for the
> > rcu_read_lock() or rcu_dereference() here.
> > 
> Better to be same than sorry; some overly clever code analysis tool
> might trip over it otherwise.

It shouldn't.  There is no dereference going on here.

> 
> > Otherwise this looks fine to me.
> 
> Reviewed-by: ?

Only without the cargo culted rcu magic.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback
  2016-03-02  9:19     ` Christoph Hellwig
@ 2016-03-02  9:34       ` Hannes Reinecke
  0 siblings, 0 replies; 7+ messages in thread
From: Hannes Reinecke @ 2016-03-02  9:34 UTC (permalink / raw)
  To: Christoph Hellwig, Hannes Reinecke
  Cc: Martin K. Petersen, Ewan Milne, Bart van Assche, James Bottomley,
	linux-scsi

On 03/02/2016 05:19 PM, Christoph Hellwig wrote:
> On Wed, Mar 02, 2016 at 03:33:14PM +0800, Hannes Reinecke wrote:
>>>> +	rcu_read_lock();
>>>> +	if (attr == &dev_attr_vpd_pg80 &&
>>>> +	    !rcu_dereference(sdev->vpd_pg80)) {
>>>> +		rcu_read_unlock();
>>>> +		return 0;
>>>> +	}
>>>> +	if (attr == &dev_attr_vpd_pg83 &&
>>>> +	    !rcu_dereference(sdev->vpd_pg83)) {
>>>> +		rcu_read_unlock();
>>>> +		return 0;
>>>> +	}
>>>> +	rcu_read_unlock();
>>>
>>> We are only checking the pointers for being non-zero.  No need for the
>>> rcu_read_lock() or rcu_dereference() here.
>>>
>> Better to be same than sorry; some overly clever code analysis tool
>> might trip over it otherwise.
> 
> It shouldn't.  There is no dereference going on here.
> 
Ok.

>>
>>> Otherwise this looks fine to me.
>>
>> Reviewed-by: ?
> 
> Only without the cargo culted rcu magic.
> 
Okay, will be resending it.

Cheers,

Hannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-03-02  9:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01  4:52 [PATCH][RESEND] scsi_sysfs: add 'is_bin_visible' callback Hannes Reinecke
2016-03-01  6:45 ` Seymour, Shane M
2016-03-01  9:08 ` Johannes Thumshirn
2016-03-01 13:04 ` Christoph Hellwig
2016-03-02  7:33   ` Hannes Reinecke
2016-03-02  9:19     ` Christoph Hellwig
2016-03-02  9:34       ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).