Re: [PATCH v2 1/3] scsi_cmnd: Introduce scsi_transfer_length helper

Christoph Hellwig
2014-06-24T16:27:32Z

On Tue, Jun 24, 2014 at 11:08:54AM -0500, Michael Christie wrote:
> > static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
> > {
> > - unsigned int xfer_len = blk_rq_bytes(scmd->request);
> > + unsigned int xfer_len = scsi_out(scmd)->length;
> > unsigned int prot_op = scsi_get_prot_op(scmd);
> > unsigned int sector_size = scmd->device->sector_size;
>
>
> Do we need to check for the data direction. Something like
>
> if (scmd->sc_data_direction == DMA_TO_DEVICE)
> xfer_len = scsi_out(scmnd)->length;
> else
> xfer_len = scsi_in(scmnd)->length;

For non-bidi commands those are the same, but I suspect we'd need
something like that for bidi commands.