aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorMartin K. Petersen <martin.petersen@oracle.com>2012-09-18 12:19:26 -0400
committerJens Axboe <axboe@kernel.dk>2012-09-20 08:31:41 -0400
commitf31dc1cd490539e2b62a126bc4dc2495b165d772 (patch)
treee8a917161111266f72a7aea539c9562dc2f2653d /include/linux/blkdev.h
parente2a60da74fc8215c68509a89e9a69c66363153db (diff)
block: Consolidate command flag and queue limit checks for merges
- blk_check_merge_flags() verifies that cmd_flags / bi_rw are compatible. This function is called for both req-req and req-bio merging. - blk_rq_get_max_sectors() and blk_queue_get_max_sectors() can be used to query the maximum sector count for a given request or queue. The calls will return the right value from the queue limits given the type of command (RW, discard, write same, etc.) Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 3a6fea7460f..90f7abe8f18 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -605,6 +605,18 @@ static inline bool rq_mergeable(struct request *rq)
605 return true; 605 return true;
606} 606}
607 607
608static inline bool blk_check_merge_flags(unsigned int flags1,
609 unsigned int flags2)
610{
611 if ((flags1 & REQ_DISCARD) != (flags2 & REQ_DISCARD))
612 return false;
613
614 if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE))
615 return false;
616
617 return true;
618}
619
608/* 620/*
609 * q->prep_rq_fn return values 621 * q->prep_rq_fn return values
610 */ 622 */
@@ -800,6 +812,25 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
800 return blk_rq_cur_bytes(rq) >> 9; 812 return blk_rq_cur_bytes(rq) >> 9;
801} 813}
802 814
815static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
816 unsigned int cmd_flags)
817{
818 if (unlikely(cmd_flags & REQ_DISCARD))
819 return q->limits.max_discard_sectors;
820
821 return q->limits.max_sectors;
822}
823
824static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
825{
826 struct request_queue *q = rq->q;
827
828 if (unlikely(rq->cmd_type == REQ_TYPE_BLOCK_PC))
829 return q->limits.max_hw_sectors;
830
831 return blk_queue_get_max_sectors(q, rq->cmd_flags);
832}
833
803/* 834/*
804 * Request issue related functions. 835 * Request issue related functions.
805 */ 836 */