Signed-off-by: Chaitanya Kulkarni <chaitanya.kulka...@wdc.com>
---
 include/linux/blkdev.h | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 6032bb740cf4..34fecc1a3a28 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -741,23 +741,33 @@ static inline bool rq_is_sync(struct request *rq)
        return op_is_sync(rq->cmd_flags);
 }
 
-static inline bool rq_mergeable(struct request *rq)
+static bool rq_mergeable_op(enum req_opf op)
 {
-       if (blk_rq_is_passthrough(rq))
-               return false;
+       bool ret;
 
-       if (req_op(rq) == REQ_OP_FLUSH)
+       if (blk_op_is_private(op) || blk_op_is_scsi(op))
                return false;
 
-       if (req_op(rq) == REQ_OP_WRITE_ZEROES)
-               return false;
+       switch (op) {
+       case REQ_OP_FLUSH:
+       case REQ_OP_WRITE_ZEROES:
+               ret = false;
+               break;
+       default:
+               ret =true;
+       }
+       return ret;
+}
 
+static inline bool rq_mergeable(struct request *rq)
+{
        if (rq->cmd_flags & REQ_NOMERGE_FLAGS)
                return false;
+
        if (rq->rq_flags & RQF_NOMERGE_FLAGS)
                return false;
 
-       return true;
+       return rq_mergeable_op(req_op(rq));
 }
 
 static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
-- 
2.17.0

Reply via email to