block: introduce blk_rq_is_passthrough
authorChristoph Hellwig <hch@lst.de>
Tue, 31 Jan 2017 15:57:29 +0000 (16:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Nov 2019 08:53:14 +0000 (09:53 +0100)
commit 57292b58ddb58689e8c3b4c6eadbef10d9ca44dd upstream.

This can be used to check for fs vs non-fs requests and basically
removes all knowledge of BLOCK_PC specific from the block layer,
as well as preparing for removing the cmd_type field in struct request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
[only take the blkdev.h changes as we only want the function for backported
patches - gregkh]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/blkdev.h

index bd738aafd4321cffa83b0b31ac126b9f36c9dda6..7582a5712458b55fcf8c0f3e8d9d9312a2243edc 100644 (file)
@@ -212,6 +212,11 @@ struct request {
        (req)->cmd_flags |= flags;              \
 } while (0)
 
+static inline bool blk_rq_is_passthrough(struct request *rq)
+{
+       return rq->cmd_type != REQ_TYPE_FS;
+}
+
 static inline unsigned short req_get_ioprio(struct request *req)
 {
        return req->ioprio;
@@ -663,7 +668,7 @@ static inline void blk_clear_rl_full(struct request_list *rl, bool sync)
 
 static inline bool rq_mergeable(struct request *rq)
 {
-       if (rq->cmd_type != REQ_TYPE_FS)
+       if (blk_rq_is_passthrough(rq))
                return false;
 
        if (req_op(rq) == REQ_OP_FLUSH)
@@ -910,7 +915,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
 {
        struct request_queue *q = rq->q;
 
-       if (unlikely(rq->cmd_type != REQ_TYPE_FS))
+       if (blk_rq_is_passthrough(rq))
                return q->limits.max_hw_sectors;
 
        if (!q->limits.chunk_sectors ||