linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
	Bart van Assche <bart.vanassche@sandisk.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-scsi@vger.kernel.org, Ewan Milne <emilne@redhat.com>
Subject: Re: [PATCH 1/5] scsi: rescan VPD attributes
Date: Fri, 24 Jul 2015 16:38:34 +0200	[thread overview]
Message-ID: <20150724143834.GA28970@lst.de> (raw)
In-Reply-To: <1436353788-104911-2-git-send-email-hare@suse.de>

On Wed, Jul 08, 2015 at 01:09:44PM +0200, Hannes Reinecke wrote:
> +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
> @@ -264,8 +264,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h)
>  	int device_id_size, device_id_type = 0;
>  	struct alua_port_group *tmp_pg, *pg = NULL;
>  
> -	if (!sdev->vpd_pg83)
> +	rcu_read_lock();
> +	if (!rcu_dereference(sdev->vpd_pg83)) {
> +		rcu_read_unlock();
>  		return SCSI_DH_DEV_UNSUPP;
> +	}
>  
>  	/*
>  	 * Look for the correct descriptor.
> @@ -281,8 +284,8 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h)
>  	 */
>  	memset(device_id_str, 0, 256);
>  	device_id_size = 0;
> -	d = sdev->vpd_pg83 + 4;
> -	while (d < sdev->vpd_pg83 + sdev->vpd_pg83_len) {
> +	d = rcu_dereference(sdev->vpd_pg83) + 4;
> +	while (d < rcu_dereference(sdev->vpd_pg83) + sdev->vpd_pg83_len) {

Seem like this code would benefit from a local variable in favor of the
repeated rcu_dereference() calls.

> @@ -803,7 +803,7 @@ void scsi_attach_vpd(struct scsi_device *sdev)

I think this function could use a new name, e.g. scsi_read_vpd_pages?

> @@ -563,8 +563,9 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,
>  	if (!sdev->vpd_pg83_len)
>  		return;
>  
> -	desc = sdev->vpd_pg83 + 4;
> -	while (desc < sdev->vpd_pg83 + sdev->vpd_pg83_len) {
> +	rcu_read_lock();
> +	desc = rcu_dereference(sdev->vpd_pg83) + 4;
> +	while (desc < rcu_dereference(sdev->vpd_pg83) + sdev->vpd_pg83_len) {

A local variable or two would help here as well.

  reply	other threads:[~2015-07-24 14:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-08 11:09 [PATCH 0/5] device handler interface update Hannes Reinecke
2015-07-08 11:09 ` [PATCH 1/5] scsi: rescan VPD attributes Hannes Reinecke
2015-07-24 14:38   ` Christoph Hellwig [this message]
2015-07-24 14:40     ` Hannes Reinecke
2015-07-24 14:43       ` Christoph Hellwig
2015-07-25 15:42         ` Hannes Reinecke
2015-07-08 11:09 ` [PATCH 2/5] scsi_dh: add 'rescan' callback Hannes Reinecke
2015-07-08 11:09 ` [PATCH 3/5] scsi: Add 'access_state' attribute Hannes Reinecke
2015-07-09  8:22   ` Christoph Hellwig
2015-07-09  8:43     ` Hannes Reinecke
2015-07-08 11:09 ` [PATCH 4/5] scsi_dh_alua: add 'state' callback function Hannes Reinecke
2015-07-24 14:42   ` Christoph Hellwig
2015-07-25 15:42     ` Hannes Reinecke
2015-07-08 11:09 ` [PATCH 5/5] scsi_dh_rdac: Add 'state' callback Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150724143834.GA28970@lst.de \
    --to=hch@lst.de \
    --cc=bart.vanassche@sandisk.com \
    --cc=emilne@redhat.com \
    --cc=hare@suse.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).