From b44247b1a97c46ee7454769f9acaddb19bc6c7d2 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 1 Mar 2018 10:31:51 +0000 Subject: [PATCH] Correct the return value from flush_work() and flush_delayed_work() in the LinuxKPI to comply more with Linux. This fixes an issue when these functions are used in waiting loops. MFC after: 1 week Sponsored by: Mellanox Technologies --- sys/compat/linuxkpi/common/src/linux_work.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_work.c b/sys/compat/linuxkpi/common/src/linux_work.c index 76d3a2225f0b..b42b14d4bbdc 100644 --- a/sys/compat/linuxkpi/common/src/linux_work.c +++ b/sys/compat/linuxkpi/common/src/linux_work.c @@ -454,6 +454,7 @@ bool linux_flush_work(struct work_struct *work) { struct taskqueue *tq; + int retval; WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "linux_flush_work() might sleep"); @@ -463,8 +464,9 @@ linux_flush_work(struct work_struct *work) return (0); default: tq = work->work_queue->taskqueue; + retval = taskqueue_poll_is_busy(tq, &work->work_task); taskqueue_drain(tq, &work->work_task); - return (1); + return (retval); } } @@ -477,6 +479,7 @@ bool linux_flush_delayed_work(struct delayed_work *dwork) { struct taskqueue *tq; + int retval; WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, "linux_flush_delayed_work() might sleep"); @@ -490,8 +493,9 @@ linux_flush_delayed_work(struct delayed_work *dwork) /* FALLTHROUGH */ default: tq = dwork->work.work_queue->taskqueue; + retval = taskqueue_poll_is_busy(tq, &dwork->work.work_task); taskqueue_drain(tq, &dwork->work.work_task); - return (1); + return (retval); } }