dm crypt: Fix IO priority lost when queuing write bios
authorHongyu Jin <hongyu.jin@unisoc.com>
Wed, 24 Jan 2024 05:35:56 +0000 (13:35 +0800)
committerMike Snitzer <snitzer@kernel.org>
Tue, 20 Feb 2024 19:22:55 +0000 (14:22 -0500)
Since dm-crypt queues writes to a different kernel thread (workqueue),
the bios will dispatch from tasks with different io_context->ioprio
settings and blkcg than the submitting task, thus giving incorrect
ioprio to the io scheduler.

Get the original IO priority setting via struct dm_crypt_io::base_bio
and set this priority in the bio for write.

Link: https://lore.kernel.org/dm-devel/alpine.LRH.2.11.1612141049250.13402@mail.ewheeler.net
Signed-off-by: Hongyu Jin <hongyu.jin@unisoc.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-crypt.c

index 7388f45ada07a3335f7c3f443d47936689215ebe..50467f005177c67b6ae04f0844dee4f81f450904 100644 (file)
@@ -1688,6 +1688,7 @@ retry:
                                 GFP_NOIO, &cc->bs);
        clone->bi_private = io;
        clone->bi_end_io = crypt_endio;
+       clone->bi_ioprio = io->base_bio->bi_ioprio;
 
        remaining_size = size;