public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] Restart scsi_device_lookup_by_target
Date: Tue, 13 Jan 2009 15:02:27 +0100	[thread overview]
Message-ID: <496C9EF3.2090409@suse.de> (raw)
In-Reply-To: <20090113135856.GE29283@parisc-linux.org>

Hi Matthew,

Matthew Wilcox wrote:
> On Tue, Jan 13, 2009 at 02:50:30PM +0100, Hannes Reinecke wrote:
>> @@ -1131,14 +1137,15 @@ EXPORT_SYMBOL(__scsi_device_lookup_by_target);
>>  struct scsi_device *scsi_device_lookup_by_target(struct scsi_target *starget,
>>  						 uint lun)
>>  {
>> -	struct scsi_device *sdev;
>> +	struct scsi_device *sdev = NULL;
>>  	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
>>  	unsigned long flags;
>>  
>>  	spin_lock_irqsave(shost->host_lock, flags);
>> -	sdev = __scsi_device_lookup_by_target(starget, lun);
>> + restart:
>> +	sdev = __scsi_device_lookup_by_target(starget, sdev, lun);
>>  	if (sdev && scsi_device_get(sdev))
>> -		sdev = NULL;
>> +		goto restart;
>>  	spin_unlock_irqrestore(shost->host_lock, flags);
>>  
>>  	return sdev;
> 
> Backwards jumps are generally disapproved of.  How about:
> 
> 	spin_lock_irqsave(shost->host_lock, flags);
> 	for (;;) {
> 		sdev = __scsi_device_lookup_by_target(starget, sdev, lun);
> 		if (!sdev || !scsi_device_get(sdev))
> 			break;
> 	}
> 	spin_unlock_irqrestore(shost->host_lock, flags);
> 
> 
I must say I don't really like the for(;;) construct.
And it's really confusing as we want to find an sdev, so breaking
if it's _not_ found is ... weird.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, 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

  reply	other threads:[~2009-01-13 14:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-13 13:50 [PATCH] Restart scsi_device_lookup_by_target Hannes Reinecke
2009-01-13 13:58 ` Matthew Wilcox
2009-01-13 14:02   ` Hannes Reinecke [this message]
2009-01-13 14:05     ` Hannes Reinecke
2009-01-13 14:11     ` Matthew Wilcox
2009-01-13 14:17       ` Hannes Reinecke
2009-01-13 15:22 ` James Bottomley
2009-01-13 15:28   ` Hannes Reinecke
2009-01-13 15:32     ` James Bottomley

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=496C9EF3.2090409@suse.de \
    --to=hare@suse.de \
    --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