Re: [PATCH 1/4] block: add blk_rq_payload_bytes
Add a helper to calculate the actual data transfer size for special payload requests. Signed-off-by: Christoph Hellwig--- include/linux/blkdev.h | 13 + 1 file changed, 13 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ff3d774..1ca8e8f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) return blk_rq_cur_bytes(rq) >> 9; } +/* + * Some commands like WRITE SAME have a payload or data transfer size which Don't you mean here DISCARD? + * is different from the size of the request. Any driver that supports such + * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to + * calculate the data transfer size. + */ +static inline unsigned int blk_rq_payload_bytes(struct request *rq) +{ + if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) + return rq->special_vec.bv_len; + return blk_rq_bytes(rq); +} + static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, int op) { -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] block: add blk_rq_payload_bytes
On 01/13/2017 12:29 PM, Christoph Hellwig wrote: > Add a helper to calculate the actual data transfer size for special > payload requests. > > Signed-off-by: Christoph Hellwig> --- > include/linux/blkdev.h | 13 + > 1 file changed, 13 insertions(+) > > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h > index ff3d774..1ca8e8f 100644 > --- a/include/linux/blkdev.h > +++ b/include/linux/blkdev.h > @@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const > struct request *rq) > return blk_rq_cur_bytes(rq) >> 9; > } > > +/* > + * Some commands like WRITE SAME have a payload or data transfer size which > + * is different from the size of the request. Any driver that supports such > + * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to > + * calculate the data transfer size. > + */ > +static inline unsigned int blk_rq_payload_bytes(struct request *rq) > +{ > + if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) > + return rq->special_vec.bv_len; > + return blk_rq_bytes(rq); > +} > + > static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, >int op) > { > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeTeamlead Storage & Networking h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/4] block: add blk_rq_payload_bytes
Add a helper to calculate the actual data transfer size for special payload requests. Signed-off-by: Christoph Hellwig--- include/linux/blkdev.h | 13 + 1 file changed, 13 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index ff3d774..1ca8e8f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) return blk_rq_cur_bytes(rq) >> 9; } +/* + * Some commands like WRITE SAME have a payload or data transfer size which + * is different from the size of the request. Any driver that supports such + * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to + * calculate the data transfer size. + */ +static inline unsigned int blk_rq_payload_bytes(struct request *rq) +{ + if (rq->rq_flags & RQF_SPECIAL_PAYLOAD) + return rq->special_vec.bv_len; + return blk_rq_bytes(rq); +} + static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, int op) { -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html