diff mbox series

fuse: fix unfreezable tasks

Message ID fc097829-b4f1-5d8d-fd71-d204c79480dc@omp.ru (mailing list archive)
State New
Headers show
Series fuse: fix unfreezable tasks | expand

Commit Message

Sergey Shtylyov June 18, 2021, 7:45 p.m. UTC
From: Ildar Kamaletdinov <i.kamaletdinov@omp.ru>

It could be impossible to freeze the fuse task in request_wait_answer()
when it calls wait_event_killable() with the FR_FINISHED flag because
the fuse daemon could be frozen before the task, so it simply can't
finish a request. E.g. it could be impossible to freeze while doing
poll() on a fuse FS:

[   90.468003] (0)[]Freezing of tasks aborted after 6.507 seconds
[   90.468793] (0)[1649:kworker/u8:18]qtaround::mt::A D
[   90.468830]    0  1590   1102 0x00400009
[   90.468850] (0)[1649:kworker/u8:18]Call trace:
[   90.468887] (0)[1649:kworker/u8:18][<ffffff82a7685a44>] __switch_to+0xd8/0xf4
[   90.468929] (0)[1649:kworker/u8:18][<ffffff82a851fa9c>] __schedule+0x75c/0x964
[   90.468964] (0)[1649:kworker/u8:18][<ffffff82a851fd14>] schedule+0x70/0x90
[   90.468995] (0)[1649:kworker/u8:18][<ffffff82a79fec00>] __fuse_request_send+0x228/0x3a4
[   90.469031] (0)[1649:kworker/u8:18][<ffffff82a79feeec>] fuse_simple_request+0x170/0x1c4
[   90.469068] (0)[1649:kworker/u8:18][<ffffff82a7a070e0>] fuse_file_poll+0x164/0x1c8
[   90.469107] (0)[1649:kworker/u8:18][<ffffff82a7851050>] do_sys_poll+0x2f4/0x5a0
[   90.469142] (0)[1649:kworker/u8:18][<ffffff82a78518f4>] do_restart_poll+0x4c/0x90
[   90.469178] (0)[1649:kworker/u8:18][<ffffff82a76bb32c>] sys_restart_syscall+0x18/0x20
[   90.469213] (0)[1649:kworker/u8:18][<ffffff82a76835c0>] el0_svc_naked+0x34/0x38
[   90.469457] (3)[647:dsme-server]Restarting tasks ...

Use freezer_do_not_count() to tell freezer to ignore the task while it
waits for event.

[Sergey: added #include <linux/freezer.h>, cleaned up the patch description]

Link: https://bugzilla.kernel.org/show_bug.cgi?id=198879
Fixes: 7d3a07fcb8a0 (fuse: don't mess with blocking signals)
Signed-off-by: Ildar Kamaletdinov <i.kamaletdinov@omp.ru>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against the Linus' repo -- I didn't find a tag suitable for
the fixes in Miklos Szeredi's FUSE repo. :-(

 fs/fuse/dev.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Miklos Szeredi June 21, 2021, 9:05 a.m. UTC | #1
On Fri, 18 Jun 2021 at 21:45, Sergey Shtylyov <s.shtylyov@omp.ru> wrote:
>
> From: Ildar Kamaletdinov <i.kamaletdinov@omp.ru>
>
> It could be impossible to freeze the fuse task in request_wait_answer()
> when it calls wait_event_killable() with the FR_FINISHED flag because
> the fuse daemon could be frozen before the task, so it simply can't
> finish a request. E.g. it could be impossible to freeze while doing
> poll() on a fuse FS:
>
> [   90.468003] (0)[]Freezing of tasks aborted after 6.507 seconds
> [   90.468793] (0)[1649:kworker/u8:18]qtaround::mt::A D
> [   90.468830]    0  1590   1102 0x00400009
> [   90.468850] (0)[1649:kworker/u8:18]Call trace:
> [   90.468887] (0)[1649:kworker/u8:18][<ffffff82a7685a44>] __switch_to+0xd8/0xf4
> [   90.468929] (0)[1649:kworker/u8:18][<ffffff82a851fa9c>] __schedule+0x75c/0x964
> [   90.468964] (0)[1649:kworker/u8:18][<ffffff82a851fd14>] schedule+0x70/0x90
> [   90.468995] (0)[1649:kworker/u8:18][<ffffff82a79fec00>] __fuse_request_send+0x228/0x3a4
> [   90.469031] (0)[1649:kworker/u8:18][<ffffff82a79feeec>] fuse_simple_request+0x170/0x1c4
> [   90.469068] (0)[1649:kworker/u8:18][<ffffff82a7a070e0>] fuse_file_poll+0x164/0x1c8
> [   90.469107] (0)[1649:kworker/u8:18][<ffffff82a7851050>] do_sys_poll+0x2f4/0x5a0
> [   90.469142] (0)[1649:kworker/u8:18][<ffffff82a78518f4>] do_restart_poll+0x4c/0x90
> [   90.469178] (0)[1649:kworker/u8:18][<ffffff82a76bb32c>] sys_restart_syscall+0x18/0x20
> [   90.469213] (0)[1649:kworker/u8:18][<ffffff82a76835c0>] el0_svc_naked+0x34/0x38
> [   90.469457] (3)[647:dsme-server]Restarting tasks ...
>
> Use freezer_do_not_count() to tell freezer to ignore the task while it
> waits for event.
>
> [Sergey: added #include <linux/freezer.h>, cleaned up the patch description]
>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=198879
> Fixes: 7d3a07fcb8a0 (fuse: don't mess with blocking signals)
> Signed-off-by: Ildar Kamaletdinov <i.kamaletdinov@omp.ru>
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>
> ---
> This patch is against the Linus' repo -- I didn't find a tag suitable for
> the fixes in Miklos Szeredi's FUSE repo. :-(
>
>  fs/fuse/dev.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> Index: linux/fs/fuse/dev.c
> ===================================================================
> --- linux.orig/fs/fuse/dev.c
> +++ linux/fs/fuse/dev.c
> @@ -8,6 +8,7 @@
>
>  #include "fuse_i.h"
>
> +#include <linux/freezer.h>
>  #include <linux/init.h>
>  #include <linux/module.h>
>  #include <linux/poll.h>
> @@ -386,9 +387,11 @@ static void request_wait_answer(struct f
>         }
>
>         if (!test_bit(FR_FORCE, &req->flags)) {
> +               freezer_do_not_count();
>                 /* Only fatal signals may interrupt this */
>                 err = wait_event_killable(req->waitq,
>                                         test_bit(FR_FINISHED, &req->flags));
> +               freezer_count();


This is just and open coded variant of
wait_event_freezekillable_unsafe() which comes with this warning:

/* DO NOT ADD ANY NEW CALLERS OF THIS FUNCTION */

This is a really old issue and unlikely to be properly solvable with a
quick hack...

Thanks,
Miklos
diff mbox series

Patch

Index: linux/fs/fuse/dev.c
===================================================================
--- linux.orig/fs/fuse/dev.c
+++ linux/fs/fuse/dev.c
@@ -8,6 +8,7 @@ 
 
 #include "fuse_i.h"
 
+#include <linux/freezer.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/poll.h>
@@ -386,9 +387,11 @@  static void request_wait_answer(struct f
 	}
 
 	if (!test_bit(FR_FORCE, &req->flags)) {
+		freezer_do_not_count();
 		/* Only fatal signals may interrupt this */
 		err = wait_event_killable(req->waitq,
 					test_bit(FR_FINISHED, &req->flags));
+		freezer_count();
 		if (!err)
 			return;