linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] floppy: Fix hang in watchdog when disk is ejected
@ 2021-09-03  6:47 Tasos Sahanidis
  2021-09-18 22:33 ` Denis Efremov
  0 siblings, 1 reply; 2+ messages in thread
From: Tasos Sahanidis @ 2021-09-03  6:47 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, efremov, jkosina, tasos

When the watchdog detects a disk change, it calls cancel_activity(),
which in turn tries to cancel the fd_timer delayed work.

In the above scenario, fd_timer_fn is set to fd_watchdog(), meaning
it is trying to cancel its own work.
This results in a hang as cancel_delayed_work_sync() is waiting for the
watchdog (itself) to return, which never happens.

This can be reproduced relatively consistently by attempting to read a
broken floppy, and ejecting it while IO is being attempted and retried.

To resolve this, this patch calls cancel_delayed_work() instead, which
cancels the work without waiting for the watchdog to return and finish.

Before this regression was introduced, the code in this section used
del_timer(), and not del_timer_sync() to delete the watchdog timer.

Fixes: 070ad7e793dc ("floppy: convert to delayed work and single-thread wq")
Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
---
 drivers/block/floppy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index fef79ea52..85464d72d 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -1014,7 +1014,7 @@ static DECLARE_DELAYED_WORK(fd_timer, fd_timer_workfn);
 static void cancel_activity(void)
 {
 	do_floppy = NULL;
-	cancel_delayed_work_sync(&fd_timer);
+	cancel_delayed_work(&fd_timer);
 	cancel_work_sync(&floppy_work);
 }
 
-- 
2.25.1


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

* Re: [PATCH] floppy: Fix hang in watchdog when disk is ejected
  2021-09-03  6:47 [PATCH] floppy: Fix hang in watchdog when disk is ejected Tasos Sahanidis
@ 2021-09-18 22:33 ` Denis Efremov
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Efremov @ 2021-09-18 22:33 UTC (permalink / raw)
  To: Tasos Sahanidis, linux-block; +Cc: axboe, jkosina

Hi,

On 9/3/21 09:47, Tasos Sahanidis wrote:
> When the watchdog detects a disk change, it calls cancel_activity(),
> which in turn tries to cancel the fd_timer delayed work.
> 
> In the above scenario, fd_timer_fn is set to fd_watchdog(), meaning
> it is trying to cancel its own work.
> This results in a hang as cancel_delayed_work_sync() is waiting for the
> watchdog (itself) to return, which never happens.
> 
> This can be reproduced relatively consistently by attempting to read a
> broken floppy, and ejecting it while IO is being attempted and retried.
> 
> To resolve this, this patch calls cancel_delayed_work() instead, which
> cancels the work without waiting for the watchdog to return and finish.
> 
> Before this regression was introduced, the code in this section used
> del_timer(), and not del_timer_sync() to delete the watchdog timer.
> 
> Fixes: 070ad7e793dc ("floppy: convert to delayed work and single-thread wq")
> Signed-off-by: Tasos Sahanidis <tasos@tasossah.com>
> ---
>  drivers/block/floppy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index fef79ea52..85464d72d 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -1014,7 +1014,7 @@ static DECLARE_DELAYED_WORK(fd_timer, fd_timer_workfn);
>  static void cancel_activity(void)
>  {
>  	do_floppy = NULL;
> -	cancel_delayed_work_sync(&fd_timer);
> +	cancel_delayed_work(&fd_timer);
>  	cancel_work_sync(&floppy_work);
>  }


Sorry for the long response. Applied, thanks!
https://github.com/evdenis/linux-floppy/commit/4258a7afaf3bde4441e844335170ee310ee29392

I will send it to Jens with other fixes.

Regards,
Denis



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

end of thread, other threads:[~2021-09-18 22:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-03  6:47 [PATCH] floppy: Fix hang in watchdog when disk is ejected Tasos Sahanidis
2021-09-18 22:33 ` Denis Efremov

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).