diff mbox series

[V2,1/2] block: add helper to check mergeable req op

Message ID 20190918005454.6872-2-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series block: track per requests type merged count | expand

Commit Message

Chaitanya Kulkarni Sept. 18, 2019, 12:54 a.m. UTC
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 include/linux/blkdev.h | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
diff mbox series

Patch

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)