diff mbox series

[2/3] block/mq-deadline: Introduce dd_bio_ioclass()

Message ID 20231205053213.522772-3-bvanassche@acm.org (mailing list archive)
State New, archived
Headers show
Series Improve mq-deadline I/O priority support | expand

Commit Message

Bart Van Assche Dec. 5, 2023, 5:32 a.m. UTC
Prepare for disabling I/O prioritization in certain cases.

Cc: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 block/mq-deadline.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Damien Le Moal Dec. 6, 2023, 2:35 a.m. UTC | #1
On 12/5/23 14:32, Bart Van Assche wrote:
> Prepare for disabling I/O prioritization in certain cases.
> 
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Damien Le Moal <dlemoal@kernel.org>

> ---
>  block/mq-deadline.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block/mq-deadline.c b/block/mq-deadline.c
> index e558f3660357..fe5da2ade953 100644
> --- a/block/mq-deadline.c
> +++ b/block/mq-deadline.c
> @@ -128,6 +128,11 @@ static u8 dd_rq_ioclass(struct request *rq)
>  	return IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
>  }
>  
> +static u8 dd_bio_ioclass(struct bio *bio)
> +{
> +	return IOPRIO_PRIO_CLASS(bio->bi_ioprio);
> +}
> +
>  /*
>   * get the request before `rq' in sector-sorted order
>   */
> @@ -744,7 +749,7 @@ static int dd_request_merge(struct request_queue *q, struct request **rq,
>  			    struct bio *bio)
>  {
>  	struct deadline_data *dd = q->elevator->elevator_data;
> -	const u8 ioprio_class = IOPRIO_PRIO_CLASS(bio->bi_ioprio);
> +	const u8 ioprio_class = dd_bio_ioclass(bio);
>  	const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
>  	struct dd_per_prio *per_prio = &dd->per_prio[prio];
>  	sector_t sector = bio_end_sector(bio);
Christoph Hellwig Dec. 11, 2023, 4:55 p.m. UTC | #2
On Mon, Dec 04, 2023 at 09:32:12PM -0800, Bart Van Assche wrote:
> Prepare for disabling I/O prioritization in certain cases.

On it's own this looks pretty useless to be honest, an with just a
single caller it can't really make future patches significantly
simpler either.
Bart Van Assche Dec. 18, 2023, 5:35 p.m. UTC | #3
On 12/11/23 08:55, Christoph Hellwig wrote:
> On Mon, Dec 04, 2023 at 09:32:12PM -0800, Bart Van Assche wrote:
>> Prepare for disabling I/O prioritization in certain cases.
> 
> On it's own this looks pretty useless to be honest, an with just a
> single caller it can't really make future patches significantly
> simpler either.

This patch helps because a helper function can have multiple return
statements. The alternative without helper function is using a less
readable ternary conditional.

Bart.
diff mbox series

Patch

diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index e558f3660357..fe5da2ade953 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -128,6 +128,11 @@  static u8 dd_rq_ioclass(struct request *rq)
 	return IOPRIO_PRIO_CLASS(req_get_ioprio(rq));
 }
 
+static u8 dd_bio_ioclass(struct bio *bio)
+{
+	return IOPRIO_PRIO_CLASS(bio->bi_ioprio);
+}
+
 /*
  * get the request before `rq' in sector-sorted order
  */
@@ -744,7 +749,7 @@  static int dd_request_merge(struct request_queue *q, struct request **rq,
 			    struct bio *bio)
 {
 	struct deadline_data *dd = q->elevator->elevator_data;
-	const u8 ioprio_class = IOPRIO_PRIO_CLASS(bio->bi_ioprio);
+	const u8 ioprio_class = dd_bio_ioclass(bio);
 	const enum dd_prio prio = ioprio_class_to_prio[ioprio_class];
 	struct dd_per_prio *per_prio = &dd->per_prio[prio];
 	sector_t sector = bio_end_sector(bio);