Add a helper to calculate the actual data transfer size for special payload requests.
Showing the changes to include/linux/blkdev.h (1 of 1 file). Show all
Unified · Split
| @@ -1000,6 +1000,19 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq) · 999 unmodified lines | ||
| 1000 | 1000 | return blk_rq_cur_bytes(rq) >> 9; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 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 | + | |
| 1003 | 1016 | static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q, |
| 1004 | 1017 | int op) |
| 1005 | 1018 | { |