From: Matthew Wilcox <matthew@wil.cx>
To: Hannes Reinecke <hare@suse.de>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>,
SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH] Restart scsi_device_lookup_by_target
Date: Tue, 13 Jan 2009 06:58:56 -0700 [thread overview]
Message-ID: <20090113135856.GE29283@parisc-linux.org> (raw)
In-Reply-To: <496C9C26.9020106@suse.de>
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);
--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
next prev parent reply other threads:[~2009-01-13 13:58 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 [this message]
2009-01-13 14:02 ` Hannes Reinecke
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=20090113135856.GE29283@parisc-linux.org \
--to=matthew@wil.cx \
--cc=James.Bottomley@HansenPartnership.com \
--cc=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