* [PATCH] block: put the reference of the io scheduler module after switching back
@ 2022-10-11 10:21 Jinlong Chen
2022-10-11 12:54 ` Yu Kuai
2022-10-12 0:54 ` Jinlong Chen
0 siblings, 2 replies; 5+ messages in thread
From: Jinlong Chen @ 2022-10-11 10:21 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, Jinlong Chen
We got a reference of the io scheduler module in
blk_mq_elv_switch_none to prevent the module from
being removed. We need to put that reference back
once we are done.
Signed-off-by: Jinlong Chen <chenjinlong2016@outlook.com>
---
block/blk-mq.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 8070b6c10e8d..8dfe3bf3e599 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4595,6 +4595,13 @@ static void blk_mq_elv_switch_back(struct list_head *head,
mutex_lock(&q->sysfs_lock);
elevator_switch(q, t);
+ /**
+ * We got a reference of the io scheduler module in
+ * blk_mq_elv_switch_none to prevent the module from
+ * being removed. We need to put that reference back
+ * once we are done.
+ */
+ module_put(t->elevator_owner);
mutex_unlock(&q->sysfs_lock);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] block: put the reference of the io scheduler module after switching back
2022-10-11 10:21 [PATCH] block: put the reference of the io scheduler module after switching back Jinlong Chen
@ 2022-10-11 12:54 ` Yu Kuai
2022-10-11 12:59 ` Yu Kuai
2022-10-12 0:54 ` Jinlong Chen
1 sibling, 1 reply; 5+ messages in thread
From: Yu Kuai @ 2022-10-11 12:54 UTC (permalink / raw)
To: Jinlong Chen, axboe; +Cc: linux-block, linux-kernel, yukuai (C)
Hi!
在 2022/10/11 18:21, Jinlong Chen 写道:
> We got a reference of the io scheduler module in
> blk_mq_elv_switch_none to prevent the module from
> being removed. We need to put that reference back
> once we are done.
However, if blk_mq_elv_switch_none() failed due to OOM, and module
reference is not acquired, blk_mq_elv_switch_back() will still be
called. This seems not to be the right fix.
Thanks,
Kuai
>
> Signed-off-by: Jinlong Chen <chenjinlong2016@outlook.com>
> ---
> block/blk-mq.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 8070b6c10e8d..8dfe3bf3e599 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -4595,6 +4595,13 @@ static void blk_mq_elv_switch_back(struct list_head *head,
>
> mutex_lock(&q->sysfs_lock);
> elevator_switch(q, t);
> + /**
> + * We got a reference of the io scheduler module in
> + * blk_mq_elv_switch_none to prevent the module from
> + * being removed. We need to put that reference back
> + * once we are done.
> + */
> + module_put(t->elevator_owner);
> mutex_unlock(&q->sysfs_lock);
> }
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: put the reference of the io scheduler module after switching back
2022-10-11 12:54 ` Yu Kuai
@ 2022-10-11 12:59 ` Yu Kuai
2022-10-11 13:23 ` Jinlong Chen
0 siblings, 1 reply; 5+ messages in thread
From: Yu Kuai @ 2022-10-11 12:59 UTC (permalink / raw)
To: Yu Kuai, Jinlong Chen, axboe; +Cc: linux-block, linux-kernel, yukuai (C)
Hi!
在 2022/10/11 20:54, Yu Kuai 写道:
> Hi!
>
> 在 2022/10/11 18:21, Jinlong Chen 写道:
>> We got a reference of the io scheduler module in
>> blk_mq_elv_switch_none to prevent the module from
>> being removed. We need to put that reference back
>> once we are done.
>
> However, if blk_mq_elv_switch_none() failed due to OOM, and module
> reference is not acquired, blk_mq_elv_switch_back() will still be
> called. This seems not to be the right fix.
Please ignore this.
I got it now if switch none failed, old queue is not added to the list,
and later blk_lookup_qe_pair() will fail to lookup the queue.
Thanks,
Kuai
>
> Thanks,
> Kuai
>>
>> Signed-off-by: Jinlong Chen <chenjinlong2016@outlook.com>
>> ---
>> block/blk-mq.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/block/blk-mq.c b/block/blk-mq.c
>> index 8070b6c10e8d..8dfe3bf3e599 100644
>> --- a/block/blk-mq.c
>> +++ b/block/blk-mq.c
>> @@ -4595,6 +4595,13 @@ static void blk_mq_elv_switch_back(struct
>> list_head *head,
>> mutex_lock(&q->sysfs_lock);
>> elevator_switch(q, t);
>> + /**
>> + * We got a reference of the io scheduler module in
>> + * blk_mq_elv_switch_none to prevent the module from
>> + * being removed. We need to put that reference back
>> + * once we are done.
>> + */
>> + module_put(t->elevator_owner);
>> mutex_unlock(&q->sysfs_lock);
>> }
>>
>
> .
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] block: put the reference of the io scheduler module after switching back
2022-10-11 12:59 ` Yu Kuai
@ 2022-10-11 13:23 ` Jinlong Chen
0 siblings, 0 replies; 5+ messages in thread
From: Jinlong Chen @ 2022-10-11 13:23 UTC (permalink / raw)
To: yukuai1; +Cc: axboe, chenjinlong2016, linux-block, linux-kernel, yukuai3
Hi!
Thank you for reviewing!
>
> I got it now if switch none failed, old queue is not added to the list,
> and later blk_lookup_qe_pair() will fail to lookup the queue.
>
That's what I'm going to say. :)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: put the reference of the io scheduler module after switching back
2022-10-11 10:21 [PATCH] block: put the reference of the io scheduler module after switching back Jinlong Chen
2022-10-11 12:54 ` Yu Kuai
@ 2022-10-12 0:54 ` Jinlong Chen
1 sibling, 0 replies; 5+ messages in thread
From: Jinlong Chen @ 2022-10-12 0:54 UTC (permalink / raw)
To: axboe; +Cc: chenjinlong2016, linux-block, linux-kernel
Hi!
I submitted a new patch with the commit message corrected:
[PATCH v2] blk-mq: put the reference of the io scheduler module after
switching back
Please ignore this patch.
Thanks!
Jinlong Chen
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-10-12 0:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 10:21 [PATCH] block: put the reference of the io scheduler module after switching back Jinlong Chen
2022-10-11 12:54 ` Yu Kuai
2022-10-11 12:59 ` Yu Kuai
2022-10-11 13:23 ` Jinlong Chen
2022-10-12 0:54 ` Jinlong Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).