public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] block: fix potential IO hang when turning off io_poll
@ 2021-02-22  6:54 Jeffle Xu
  2021-02-22  7:12 ` Joseph Qi
  2021-02-22 13:40 ` Jens Axboe
  0 siblings, 2 replies; 4+ messages in thread
From: Jeffle Xu @ 2021-02-22  6:54 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, io-uring, joseph.qi

QUEUE_FLAG_POLL flag will be cleared when turning off 'io_poll', while
at that moment there may be IOs stuck in hw queue uncompleted. The
following polling routine won't help reap these IOs, since blk_poll()
will return immediately because of cleared QUEUE_FLAG_POLL flag. Thus
these IOs will hang until they finnaly time out. The hang out can be
observed by 'fio --engine=io_uring iodepth=1', while turning off
'io_poll' at the same time.

To fix this, freeze and flush the request queue first when turning off
'io_poll'.

Signed-off-by: Jeffle Xu <[email protected]>
---
 block/blk-sysfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index b513f1683af0..10d74741c002 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
 
 	if (poll_on)
 		blk_queue_flag_set(QUEUE_FLAG_POLL, q);
-	else
+	else {
+		blk_mq_freeze_queue(q);
 		blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
+		blk_mq_unfreeze_queue(q);
+	}
 
 	return ret;
 }
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix potential IO hang when turning off io_poll
  2021-02-22  6:54 [PATCH] block: fix potential IO hang when turning off io_poll Jeffle Xu
@ 2021-02-22  7:12 ` Joseph Qi
  2021-02-22  7:46   ` JeffleXu
  2021-02-22 13:40 ` Jens Axboe
  1 sibling, 1 reply; 4+ messages in thread
From: Joseph Qi @ 2021-02-22  7:12 UTC (permalink / raw)
  To: Jeffle Xu, axboe; +Cc: linux-block, io-uring



On 2/22/21 2:54 PM, Jeffle Xu wrote:
> QUEUE_FLAG_POLL flag will be cleared when turning off 'io_poll', while
> at that moment there may be IOs stuck in hw queue uncompleted. The
> following polling routine won't help reap these IOs, since blk_poll()
> will return immediately because of cleared QUEUE_FLAG_POLL flag. Thus
> these IOs will hang until they finnaly time out. The hang out can be
> observed by 'fio --engine=io_uring iodepth=1', while turning off
> 'io_poll' at the same time.
> 
> To fix this, freeze and flush the request queue first when turning off
> 'io_poll'.
> 
> Signed-off-by: Jeffle Xu <[email protected]>
> ---
>  block/blk-sysfs.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index b513f1683af0..10d74741c002 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
>  
>  	if (poll_on)
>  		blk_queue_flag_set(QUEUE_FLAG_POLL, q);
> -	else
> +	else {
> +		blk_mq_freeze_queue(q);
>  		blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
> +		blk_mq_unfreeze_queue(q);
> +	}
>  
>  	return ret;
>  }
> 

Better to place brace to 'if' as well.

Thanks,
Joseph



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix potential IO hang when turning off io_poll
  2021-02-22  7:12 ` Joseph Qi
@ 2021-02-22  7:46   ` JeffleXu
  0 siblings, 0 replies; 4+ messages in thread
From: JeffleXu @ 2021-02-22  7:46 UTC (permalink / raw)
  To: Joseph Qi, axboe; +Cc: linux-block, io-uring



On 2/22/21 3:12 PM, Joseph Qi wrote:
> 
> 
> On 2/22/21 2:54 PM, Jeffle Xu wrote:
>> QUEUE_FLAG_POLL flag will be cleared when turning off 'io_poll', while
>> at that moment there may be IOs stuck in hw queue uncompleted. The
>> following polling routine won't help reap these IOs, since blk_poll()
>> will return immediately because of cleared QUEUE_FLAG_POLL flag. Thus
>> these IOs will hang until they finnaly time out. The hang out can be
>> observed by 'fio --engine=io_uring iodepth=1', while turning off
>> 'io_poll' at the same time.
>>
>> To fix this, freeze and flush the request queue first when turning off
>> 'io_poll'.
>>
>> Signed-off-by: Jeffle Xu <[email protected]>
>> ---
>>  block/blk-sysfs.c | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
>> index b513f1683af0..10d74741c002 100644
>> --- a/block/blk-sysfs.c
>> +++ b/block/blk-sysfs.c
>> @@ -430,8 +430,11 @@ static ssize_t queue_poll_store(struct request_queue *q, const char *page,
>>  
>>  	if (poll_on)
>>  		blk_queue_flag_set(QUEUE_FLAG_POLL, q);
>> -	else
>> +	else {
>> +		blk_mq_freeze_queue(q);
>>  		blk_queue_flag_clear(QUEUE_FLAG_POLL, q);
>> +		blk_mq_unfreeze_queue(q);
>> +	}
>>  
>>  	return ret;
>>  }
>>
> 
> Better to place brace to 'if' as well.

Got it, thanks.


-- 
Thanks,
Jeffle

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] block: fix potential IO hang when turning off io_poll
  2021-02-22  6:54 [PATCH] block: fix potential IO hang when turning off io_poll Jeffle Xu
  2021-02-22  7:12 ` Joseph Qi
@ 2021-02-22 13:40 ` Jens Axboe
  1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-02-22 13:40 UTC (permalink / raw)
  To: Jeffle Xu; +Cc: linux-block, io-uring, joseph.qi

On 2/21/21 11:54 PM, Jeffle Xu wrote:
> QUEUE_FLAG_POLL flag will be cleared when turning off 'io_poll', while
> at that moment there may be IOs stuck in hw queue uncompleted. The
> following polling routine won't help reap these IOs, since blk_poll()
> will return immediately because of cleared QUEUE_FLAG_POLL flag. Thus
> these IOs will hang until they finnaly time out. The hang out can be
> observed by 'fio --engine=io_uring iodepth=1', while turning off
> 'io_poll' at the same time.
> 
> To fix this, freeze and flush the request queue first when turning off
> 'io_poll'.

Applied, thanks. Fixed up the braces.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-22 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22  6:54 [PATCH] block: fix potential IO hang when turning off io_poll Jeffle Xu
2021-02-22  7:12 ` Joseph Qi
2021-02-22  7:46   ` JeffleXu
2021-02-22 13:40 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox