Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1414155

[PATCH 35/45] block: convert merge/insert code to check for REQ_OPs.

From mchristi@redhat.com
Newsgroups linux.kernel
Subject [PATCH 35/45] block: convert merge/insert code to check for REQ_OPs.
Date 2016-06-05 21:40 +0200
Message-ID <rGM3U-2uj-17@gated-at.bofh.it> (permalink)
References <rGM3T-2uj-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Mike Christie <mchristi@redhat.com>

This patch converts the block layer merging code to use separate variables
for the operation and flags, and to check req_op for the REQ_OP.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
---
 block/blk-core.c       |  2 +-
 block/blk-merge.c      | 10 ++++++----
 include/linux/blkdev.h | 20 ++++++++++----------
 3 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 090e55d..1333bb7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2161,7 +2161,7 @@ EXPORT_SYMBOL(submit_bio);
 static int blk_cloned_rq_check_limits(struct request_queue *q,
 				      struct request *rq)
 {
-	if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {
+	if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, req_op(rq))) {
 		printk(KERN_ERR "%s: over max size limit.\n", __func__);
 		return -EIO;
 	}
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 5a03f96..c265348 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -649,7 +649,8 @@ static int attempt_merge(struct request_queue *q, struct request *req,
 	if (!rq_mergeable(req) || !rq_mergeable(next))
 		return 0;
 
-	if (!blk_check_merge_flags(req->cmd_flags, next->cmd_flags))
+	if (!blk_check_merge_flags(req->cmd_flags, req_op(req), next->cmd_flags,
+				   req_op(next)))
 		return 0;
 
 	/*
@@ -663,7 +664,7 @@ static int attempt_merge(struct request_queue *q, struct request *req,
 	    || req_no_special_merge(next))
 		return 0;
 
-	if (req->cmd_flags & REQ_WRITE_SAME &&
+	if (req_op(req) == REQ_OP_WRITE_SAME &&
 	    !blk_write_same_mergeable(req->bio, next->bio))
 		return 0;
 
@@ -751,7 +752,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
 	if (!rq_mergeable(rq) || !bio_mergeable(bio))
 		return false;
 
-	if (!blk_check_merge_flags(rq->cmd_flags, bio->bi_rw))
+	if (!blk_check_merge_flags(rq->cmd_flags, req_op(rq), bio->bi_rw,
+				   bio_op(bio)))
 		return false;
 
 	/* different data direction or already started, don't merge */
@@ -767,7 +769,7 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
 		return false;
 
 	/* must be using the same buffer */
-	if (rq->cmd_flags & REQ_WRITE_SAME &&
+	if (req_op(rq) == REQ_OP_WRITE_SAME &&
 	    !blk_write_same_mergeable(rq->bio, bio))
 		return false;
 
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 8c78aca..25f01ff 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -666,16 +666,16 @@ static inline bool rq_mergeable(struct request *rq)
 	return true;
 }
 
-static inline bool blk_check_merge_flags(unsigned int flags1,
-					 unsigned int flags2)
+static inline bool blk_check_merge_flags(unsigned int flags1, unsigned int op1,
+					 unsigned int flags2, unsigned int op2)
 {
-	if ((flags1 & REQ_DISCARD) != (flags2 & REQ_DISCARD))
+	if ((op1 == REQ_OP_DISCARD) != (op2 == REQ_OP_DISCARD))
 		return false;
 
 	if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE))
 		return false;
 
-	if ((flags1 & REQ_WRITE_SAME) != (flags2 & REQ_WRITE_SAME))
+	if ((op1 == REQ_OP_WRITE_SAME) != (op2 == REQ_OP_WRITE_SAME))
 		return false;
 
 	return true;
@@ -887,12 +887,12 @@ static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
 }
 
 static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
-						     unsigned int cmd_flags)
+						     int op)
 {
-	if (unlikely(cmd_flags & REQ_DISCARD))
+	if (unlikely(op == REQ_OP_DISCARD))
 		return min(q->limits.max_discard_sectors, UINT_MAX >> 9);
 
-	if (unlikely(cmd_flags & REQ_WRITE_SAME))
+	if (unlikely(op == REQ_OP_WRITE_SAME))
 		return q->limits.max_write_same_sectors;
 
 	return q->limits.max_sectors;
@@ -919,11 +919,11 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq)
 	if (unlikely(rq->cmd_type != REQ_TYPE_FS))
 		return q->limits.max_hw_sectors;
 
-	if (!q->limits.chunk_sectors || (rq->cmd_flags & REQ_DISCARD))
-		return blk_queue_get_max_sectors(q, rq->cmd_flags);
+	if (!q->limits.chunk_sectors || (req_op(rq) == REQ_OP_DISCARD))
+		return blk_queue_get_max_sectors(q, req_op(rq));
 
 	return min(blk_max_size_offset(q, blk_rq_pos(rq)),
-			blk_queue_get_max_sectors(q, rq->cmd_flags));
+			blk_queue_get_max_sectors(q, req_op(rq)));
 }
 
 static inline unsigned int blk_rq_count_bios(struct request *rq)
-- 
2.7.2

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/45] v8: separate operations from flags in the bio/request structs  mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 37/45] drivers: use req op accessor mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 35/45] block: convert merge/insert code to check for REQ_OPs. mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 43/45] block, drivers: add REQ_OP_FLUSH operation mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 36/45] block: convert is_sync helpers to use REQ_OPs. mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 14/45] btrfs: use bio fields for op and flags mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 05/45] block, drivers, cgroup: use op_is_write helper instead of checking for REQ_WRITE mchristi@redhat.com - 2016-06-05 21:40 +0200
    Re: [PATCH 05/45] block, drivers, cgroup: use op_is_write helper  instead of checking for REQ_WRITE Hannes Reinecke <hare@suse.de> - 2016-06-06 08:20 +0200
  [PATCH 40/45] block: move bio io prio to a new field mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 23/45] dm: pass dm stats data dir instead of bi_rw mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 41/45] block, drivers, fs: shrink bi_rw from long to int mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 45/45] block, drivers, fs: rename REQ_FLUSH to REQ_PREFLUSH mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 44/45] block: do not use REQ_FLUSH for tracking flush support mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 38/45] blktrace: use op accessors mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and related code mchristi@redhat.com - 2016-06-05 21:40 +0200
    Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and  related code kbuild test robot <lkp@intel.com> - 2016-06-05 23:00 +0200
    Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and  related code kbuild test robot <lkp@intel.com> - 2016-06-05 23:40 +0200
    Re: [PATCH 42/45] block, fs, drivers: remove REQ_OP compat defs and  related code kbuild test robot <lkp@intel.com> - 2016-06-06 00:10 +0200
  [PATCH 21/45] ocfs2: use bio op accessors mchristi@redhat.com - 2016-06-05 21:40 +0200
  [PATCH 28/45] target: use bio op accessors mchristi@redhat.com - 2016-06-05 21:40 +0200
    Re: [PATCH 28/45] target: use bio op accessors Hannes Reinecke <hare@suse.de> - 2016-06-06 08:50 +0200
      Re: [PATCH 28/45] target: use bio op accessors Hannes Reinecke <hare@suse.de> - 2016-06-06 17:50 +0200
      Re: [PATCH 28/45] target: use bio op accessors Mike Christie <mchristi@redhat.com> - 2016-06-06 17:50 +0200
  [PATCH 15/45] f2fs: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 02/45] block: add REQ_OP definitions and helpers mchristi@redhat.com - 2016-06-05 21:50 +0200
    Re: [PATCH 02/45] block: add REQ_OP definitions and helpers Hannes Reinecke <hare@suse.de> - 2016-06-06 08:20 +0200
  [PATCH 22/45] pm: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 33/45] block: prepare elevator to use REQ_OPs. mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 18/45] hfsplus: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 20/45] nilfs: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 06/45] dm: use op_is_write instead of checking for REQ_WRITE mchristi@redhat.com - 2016-06-05 21:50 +0200
    Re: [PATCH 06/45] dm: use op_is_write instead of checking for  REQ_WRITE Hannes Reinecke <hare@suse.de> - 2016-06-06 08:20 +0200
  [PATCH 19/45] mpage: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 16/45] gfs2: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 26/45] drbd: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 32/45] block: prepare mq request creation to use REQ_OPs mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 27/45] md: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 34/45] blkg_rwstat: separate op from flags mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 17/45] xfs: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 07/45] bcache: use op_is_write instead of checking for REQ_WRITE mchristi@redhat.com - 2016-06-05 21:50 +0200
    Re: [PATCH 07/45] bcache: use op_is_write instead of checking for  REQ_WRITE Hannes Reinecke <hare@suse.de> - 2016-06-06 08:20 +0200
  [PATCH 31/45] block: prepare request creation/destruction code to use REQ_OPs mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 29/45] xen: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 30/45] block: copy bio op to request op mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 25/45] bcache: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
    Re: [PATCH 25/45] bcache: use bio op accessors Hannes Reinecke <hare@suse.de> - 2016-06-06 08:50 +0200
  [PATCH 24/45] dm: use bio op accessors mchristi@redhat.com - 2016-06-05 21:50 +0200
    Re: [PATCH 24/45] dm: use bio op accessors Hannes Reinecke <hare@suse.de> - 2016-06-06 08:50 +0200
  [PATCH 04/45] fs: have ll_rw_block users pass in op and flags separately mchristi@redhat.com - 2016-06-05 21:50 +0200
  [PATCH 11/45] btrfs: have submit_one_bio users use bio op accessors mchristi@redhat.com - 2016-06-05 22:00 +0200
  [PATCH 08/45] block, fs, mm, drivers: use bio set/get op accessors mchristi@redhat.com - 2016-06-05 22:00 +0200
    Re: [PATCH 08/45] block, fs, mm, drivers: use bio set/get op  accessors Hannes Reinecke <hare@suse.de> - 2016-06-06 08:30 +0200
  [PATCH 09/45] block discard: use bio set op accessor mchristi@redhat.com - 2016-06-05 22:00 +0200
  [PATCH 13/45] btrfs: update __btrfs_map_block for REQ_OP transition mchristi@redhat.com - 2016-06-05 22:00 +0200
  [PATCH 12/45] btrfs: use bio op accessors mchristi@redhat.com - 2016-06-05 22:00 +0200
  [PATCH 10/45] direct-io: use bio set/get op accessors mchristi@redhat.com - 2016-06-05 22:00 +0200
  [PATCH 03/45] fs: have submit_bh users pass in op and flags separately mchristi@redhat.com - 2016-06-05 22:00 +0200

csiph-web