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

Christoph Hellwig
2014-06-25T09:14:18Z

Mike, I'd prefer a fix on top of the core-for-3.16 branch in my
scsi-queue tree, which already has the fix from Martin.

I also really don't like these three confusing helpers:

> +static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd)
> +{
> + return __scsi_calculate_transfer_length(scmd,
> + blk_rq_bytes(scmd->request));
> +}

So here we use blk_rq_bytes still, which is incorrect for WRITE SAME.

> +static inline unsigned scsi_in_transfer_length(struct scsi_cmnd *scmd)
> +{
> + return __scsi_calculate_transfer_length(scmd, scsi_in(scmd)->length);
> +}
> +
> +static inline unsigned scsi_out_transfer_length(struct scsi_cmnd *scmd)
> +{
> + return __scsi_calculate_transfer_length(scmd, scsi_out(scmd)->length);

And here we use the in/out length. And no documentation whatsover which
one you'd want to choose.

I think the easiest fix is to just pass a scsi_data_buffer to
scsi_transfer_length(), and let the caller use scsi_in/scsi_out to find
the right one.