Re: [PATCH v3 5/5] dm-crypt: Fix lost ioprio when queuing write bios

From: Mike Snitzer
Date: Mon Dec 11 2023 - 17:15:25 EST


On Mon, Dec 11 2023 at 4:00P -0500,
Hongyu Jin <hongyu.jin.cn@xxxxxxxxx> wrote:

> From: Hongyu Jin <hongyu.jin@xxxxxxxxxx>
>
> The original submitting bio->bi_ioprio setting can be retained by
> struct dm_crypt_io::base_bio, we set the original bio's ioprio to
> the cloned bio for write.
>
> Signed-off-by: Hongyu Jin <hongyu.jin@xxxxxxxxxx>
> ---
> drivers/md/dm-crypt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
> index 6de107aff331..b67fec865f00 100644
> --- a/drivers/md/dm-crypt.c
> +++ b/drivers/md/dm-crypt.c
> @@ -1683,6 +1683,7 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned int size)
> GFP_NOIO, &cc->bs);
> clone->bi_private = io;
> clone->bi_end_io = crypt_endio;
> + clone->bi_ioprio = bio_prio(io->base_bio);

Weird use of bio_prio() wrapper given the assignment to
clone->bi_ioprio. I'd prefer:
clone->bi_ioprio = io->base_bio->bi_ioprio;

Some additional info to be mindful of:

This encryption bio has always been unique (ever since dm-crypt
stopped using the block layer's methods for cloning with 2007's commit
2f9941b6c55d7).

Prior to commit 2f9941b6c55d7, dm-crypt used to call __bio_clone() to
make sure not to miss cloning other capabilities -- and __bio_clone()
does exist again as of commit a0e8de798dd67 but it is private to bio.c
(in service to bio_alloc_clone, etc).

My point: because we aren't using traditional bio cloning (due to not
wanting to share the bio_vec) we also aren't transferring over the
cgroup (via bio_clone_blkg_association), etc.

That can be a secondary concern that you don't need to worry about
(but it is something Mikulas and I need to look at closer).

Mike