diff mbox

[4/5] block: Inline blk_rq_set_prio()

Message ID 20170418231037.3968-5-bart.vanassche@sandisk.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bart Van Assche April 18, 2017, 11:10 p.m. UTC
Since only a single caller remains, inline blk_rq_set_prio(). Initialize
req->ioprio even if no I/O priority has been set in the bio nor in the
I/O context.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Adam Manzanares <adam.manzanares@wdc.com>
Tested-by: Adam Manzanares <adam.manzanares@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Matias Bjørling <m@bjorling.me>
---
 block/blk-core.c       |  7 ++++---
 include/linux/blkdev.h | 14 --------------
 2 files changed, 4 insertions(+), 17 deletions(-)

Comments

Christoph Hellwig April 19, 2017, 6:20 a.m. UTC | #1
> +	req->ioprio = ioprio_valid(bio_prio(bio)) ? bio_prio(bio) : ioc ?
> +		ioc->ioprio : IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);

I think this would be a tad cleaner with a traditional if / else if / else
chain, e.g.

	if (ioprio_valid(bio_prio(bio)))
		req->ioprio = bio_prio(bio);
	else if (ioc)
		req->ioprio = ioc->ioprio;
	else
		req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);

But otherwise the patch looks good to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Jens Axboe April 19, 2017, 2:38 p.m. UTC | #2
On 04/19/2017 12:20 AM, Christoph Hellwig wrote:
>> +	req->ioprio = ioprio_valid(bio_prio(bio)) ? bio_prio(bio) : ioc ?
>> +		ioc->ioprio : IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
> 
> I think this would be a tad cleaner with a traditional if / else if / else
> chain, e.g.
> 
> 	if (ioprio_valid(bio_prio(bio)))
> 		req->ioprio = bio_prio(bio);
> 	else if (ioc)
> 		req->ioprio = ioc->ioprio;
> 	else
> 		req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);

Agree, I hate ternaries with a vengeance, and a doubly nested one is
almost a shooting offense.

Bart, care to respin with this fixed and the GPL export modification?
Bart Van Assche April 19, 2017, 3:54 p.m. UTC | #3
On Wed, 2017-04-19 at 08:38 -0600, Jens Axboe wrote:
> On 04/19/2017 12:20 AM, Christoph Hellwig wrote:
> > > +	req->ioprio = ioprio_valid(bio_prio(bio)) ? bio_prio(bio) : ioc ?
> > > +		ioc->ioprio : IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
> > 
> > I think this would be a tad cleaner with a traditional if / else if / else
> > chain, e.g.
> > 
> > 	if (ioprio_valid(bio_prio(bio)))
> > 		req->ioprio = bio_prio(bio);
> > 	else if (ioc)
> > 		req->ioprio = ioc->ioprio;
> > 	else
> > 		req->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
> 
> Agree, I hate ternaries with a vengeance, and a doubly nested one is
> almost a shooting offense.
> 
> Bart, care to respin with this fixed and the GPL export modification?

Hello Christoph and Jens,

Thanks for the review and the feedback. I will make the proposed changes
and repost this patch series.

Bart.
diff mbox

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index c274aed2ca3f..7374b02370fa 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1635,14 +1635,15 @@  unsigned int blk_plug_queued_count(struct request_queue *q)
 
 void blk_init_request_from_bio(struct request *req, struct bio *bio)
 {
+	struct io_context *ioc = rq_ioc(bio);
+
 	if (bio->bi_opf & REQ_RAHEAD)
 		req->cmd_flags |= REQ_FAILFAST_MASK;
 
 	req->errors = 0;
 	req->__sector = bio->bi_iter.bi_sector;
-	blk_rq_set_prio(req, rq_ioc(bio));
-	if (ioprio_valid(bio_prio(bio)))
-		req->ioprio = bio_prio(bio);
+	req->ioprio = ioprio_valid(bio_prio(bio)) ? bio_prio(bio) : ioc ?
+		ioc->ioprio : IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
 	blk_rq_bio_prep(req->q, req, bio);
 }
 EXPORT_SYMBOL(blk_init_request_from_bio);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e1ea875ec048..28f713803871 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1088,20 +1088,6 @@  static inline unsigned int blk_rq_count_bios(struct request *rq)
 }
 
 /*
- * blk_rq_set_prio - associate a request with prio from ioc
- * @rq: request of interest
- * @ioc: target iocontext
- *
- * Assocate request prio with ioc prio so request based drivers
- * can leverage priority information.
- */
-static inline void blk_rq_set_prio(struct request *rq, struct io_context *ioc)
-{
-	if (ioc)
-		rq->ioprio = ioc->ioprio;
-}
-
-/*
  * Request issue related functions.
  */
 extern struct request *blk_peek_request(struct request_queue *q);