History

block: add blk_rq_payload_bytes

Add a helper to calculate the actual data transfer size for special payload requests.

Christoph Hellwig committed 9 years ago

Commit 2e3258e1 parent f99e8641 file · +13 −0Browse files

Showing the changes to include/linux/blkdev.h (1 of 1 file). Show all

Unified · Split

include/linux/blkdev.h+13−0
@@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) · 999 unmodified lines
10001000 return blk_rq_cur_bytes(rq) >> 9;
10011001 }
10021002
1003+/*
1004+ * Some commands like WRITE SAME have a payload or data transfer size which
1005+ * is different from the size of the request. Any driver that supports such
1006+ * commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to
1007+ * calculate the data transfer size.
1008+ */
1009+static inline unsigned int blk_rq_payload_bytes(struct request *rq)
1010+{
1011+ if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
1012+ return rq->special_vec.bv_len;
1013+ return blk_rq_bytes(rq);
1014+}
1015+
10031016 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
10041017 int op)
10051018 {