On Fri, 2005-02-25 at 03:38 -0500, Jeff Garzik wrote:
> Arjan van de Ven wrote:
> > On Thu, 2005-02-24 at 23:21 -0500, Doug Ledford wrote:
> > 
> >>Don't use cmd->request->nr_hw_segments as it may not be initialized
> >>(SG_IO in particular bypasses anything that initializes this and just
> >>uses scsi_do_req to insert a scsi_request directly on the head of the
> >>queue) 
> > 
> > 
> > should we fix that in the SG_IO layer ?
> 
> Possibly/probably.

I'm not concerned with it personally.  The only reason that the scsi
layer copies the block layer request struct into the scsi
command/request is so that upon completion it has enough information to
mark blocks as either up to date or not while at the same time allowing
the scsi layer to free the original block request at queue time, not at
completion time.  It was never intended to be used by low level drivers.
And since the scsi layer has several ways of bypassing the block layer
to inject commands directly to devices, trying to catch all those
injection points and make them emulate block layer activity when we
already provide everything a low level driver needs in the scsi command
struct is silly.  Just use what's available, reliable, always
initialized, and intended for you to use (cmd->use_sg) instead of trying
to use a roughly duplicate item from a different abstraction layer that
isn't always involved in commands sent to a low level driver (request-
>nr_hw_segments).

> For SCSI drivers specifically, using nr_hw_segments is pointless unless 
> cmd->use_sg goes away.  At which point tons of SCSI drivers want 
> changing anyway.
> 
>       n_sg = dma_map_sg(..., cmd->use_sg, ...)
> 
> will always do the right thing, when the cmd contains a scatterlist.
> 
> Deviate from the norm and pay the price, really...

Aye, yup.

-- 
Doug Ledford <[EMAIL PROTECTED]>
http://people.redhat.com/dledford


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to