Re: [PATCH] Restart scsi_device_lookup_by_target

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

 



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.

> 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.

-- 
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."
--
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