Re: [PATCH] Restart scsi_device_lookup_by_target

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Matthew,

Matthew Wilcox wrote:
On Tue, Jan 13, 2009 at 03:02:27PM +0100, Hannes Reinecke wrote:
Matthew Wilcox wrote:
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.

I'd be fine with:

	do {
		sdev = __scsi_device_lookup_by_target(starget, sdev, lun);
	} while (sdev && scsi_device_get(sdev));

though I find that slightly less clear than the for (;;) construct.

Opinons differ.
Something for the maintainer to decide. James?

And it's really confusing as we want to find an sdev, so breaking
if it's _not_ found is ... weird.

Those are the two conditions when we want to stop trying -- if there's
no device or if the device we've found is bad.  I can definitely see an
argument for splitting the two conditions to make that more obvious.  I
can also see an argument for not returning an sdev in the _DEL state
from __scsi_device_lookup_by_target in the first place.

Not sure if that would work with esp_scsi.c (the other user of
__scsi_device_lookup_by_target()).
And don't have a device to try it with.

But modifying __scsi_device_lookup_by_target() would alter the behaviour,
whereas this patch does not.

Cheers,

Hannes
--
Dr. Hannes Reinecke		      zSeries & Storage
hare@xxxxxxx			      +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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux