[PATCH] loop: aio inherit the ioprio of original request

Yunlong Xing posted 1 patch 10 months ago
There is a newer version of this series
drivers/block/loop.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] loop: aio inherit the ioprio of original request
Posted by Yunlong Xing 10 months ago
Set cmd->iocb.ki_ioprio to the ioprio of loop device's request.
The purpose is to inherit the original request ioprio in the aio
flow.

Signed-off-by: Yunlong Xing <yunlong.xing@unisoc.com>
Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
 drivers/block/loop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 674527d770dc..ed73627af3ff 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -447,7 +447,6 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 	cmd->iocb.ki_filp = file;
 	cmd->iocb.ki_complete = lo_rw_aio_complete;
 	cmd->iocb.ki_flags = IOCB_DIRECT;
-	cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
 
 	if (rw == ITER_SOURCE)
 		ret = file->f_op->write_iter(&cmd->iocb, &iter);
@@ -1892,6 +1891,9 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 		break;
 	}
 
+	/* get original request ioprio */
+	cmd->iocb.ki_ioprio = req_get_ioprio(rq);
+
 	/* always use the first bio's css */
 	cmd->blkcg_css = NULL;
 	cmd->memcg_css = NULL;
-- 
2.25.1
Re: [PATCH] loop: aio inherit the ioprio of original request
Posted by Bart Van Assche 10 months ago
On 4/11/25 12:28 AM, Yunlong Xing wrote:
> diff --git a/drivers/block/loop.c b/drivers/block/loop.c
> index 674527d770dc..ed73627af3ff 100644
> --- a/drivers/block/loop.c
> +++ b/drivers/block/loop.c
> @@ -447,7 +447,6 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
>   	cmd->iocb.ki_filp = file;
>   	cmd->iocb.ki_complete = lo_rw_aio_complete;
>   	cmd->iocb.ki_flags = IOCB_DIRECT;
> -	cmd->iocb.ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0);
>   
>   	if (rw == ITER_SOURCE)
>   		ret = file->f_op->write_iter(&cmd->iocb, &iter);
> @@ -1892,6 +1891,9 @@ static blk_status_t loop_queue_rq(struct blk_mq_hw_ctx *hctx,
>   		break;
>   	}
>   
> +	/* get original request ioprio */
> +	cmd->iocb.ki_ioprio = req_get_ioprio(rq);
> +
>   	/* always use the first bio's css */
>   	cmd->blkcg_css = NULL;
>   	cmd->memcg_css = NULL;

Shouldn't the cmd->iocb.ki_ioprio assignment occur in lo_rw_aio() rather
than in loop_queue_rq() since the iocb is only used by lo_rw_aio()?

Bart.