All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Jens Axboe <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>,
	Damien Le Moal <damien.lemoal@opensource.wdc.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Niklas Cassel <Niklas.Cassel@wdc.com>, Jan Kara <jack@suse.cz>
Subject: [PATCH 9/9] block: Always initialize bio IO priority on submit
Date: Thu, 23 Jun 2022 09:48:34 +0200	[thread overview]
Message-ID: <20220623074840.5960-9-jack@suse.cz> (raw)
In-Reply-To: <20220623074450.30550-1-jack@suse.cz>

Currently, IO priority set in task's IO context is not reflected in the
bio->bi_ioprio for most IO (only io_uring and direct IO set it). This
results in odd results where process is submitting some bios with one
priority and other bios with a different (unset) priority and due to
differing priorities bios cannot be merged. Make sure bio->bi_ioprio is
always set on bio submission.

Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 block/blk-mq.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index e17d822e6051..7548f8aebea8 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2793,6 +2793,9 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
 
 static void bio_set_ioprio(struct bio *bio)
 {
+	/* Nobody set ioprio so far? Initialize it based on task's nice value */
+	if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE)
+		bio->bi_ioprio = get_current_ioprio();
 	blkcg_set_ioprio(bio);
 }
 
-- 
2.35.3


  parent reply	other threads:[~2022-06-23  7:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23  7:48 [PATCH 0/9 v5] block: Fix IO priority mess Jan Kara
2022-06-23  7:48 ` [PATCH 1/9] block: fix default IO priority handling again Jan Kara
2022-06-23 13:57   ` Christoph Hellwig
2022-06-23 14:23   ` Jens Axboe
2022-06-23  7:48 ` [PATCH 2/9] block: Return effective IO priority from get_current_ioprio() Jan Kara
2022-06-23 13:57   ` Christoph Hellwig
2022-06-23  7:48 ` [PATCH 3/9] block: Generalize get_current_ioprio() for any task Jan Kara
2022-06-23 13:59   ` Christoph Hellwig
2022-06-23  7:48 ` [PATCH 4/9] block: Make ioprio_best() static Jan Kara
2022-06-23 13:58   ` Christoph Hellwig
2022-06-23  7:48 ` [PATCH 5/9] block: Fix handling of tasks without ioprio in ioprio_get(2) Jan Kara
2022-06-23  7:48 ` [PATCH 6/9] blk-ioprio: Remove unneeded field Jan Kara
2022-06-23 14:00   ` Christoph Hellwig
2022-06-23  7:48 ` [PATCH 7/9] blk-ioprio: Convert from rqos policy to direct call Jan Kara
2022-06-23 14:01   ` Christoph Hellwig
2022-06-23  7:48 ` [PATCH 8/9] block: Initialize bio priority earlier Jan Kara
2022-06-23 14:01   ` Christoph Hellwig
2022-06-23  7:48 ` Jan Kara [this message]
2022-06-23 14:01   ` [PATCH 9/9] block: Always initialize bio IO priority on submit Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2022-06-21 10:24 [PATCH 0/9 v4] block: Fix IO priority mess Jan Kara
2022-06-21 10:24 ` [PATCH 9/9] block: Always initialize bio IO priority on submit Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220623074840.5960-9-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=Niklas.Cassel@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.