Prevent that fio hangs when using io_submit_mode=offload
authorBart Van Assche <bvanassche@acm.org>
Sat, 1 Aug 2020 18:01:06 +0000 (11:01 -0700)
committerBart Van Assche <bvanassche@acm.org>
Sat, 1 Aug 2020 18:25:45 +0000 (11:25 -0700)
This patch has been tested by running the following shell command:

for ((i=0;i<1000;i++)); do echo $i; python3 t/run-fio-tests.py -o 10; done

Fixes: d28174f0189c ("workqueue: ensure we see deferred error for IOs")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
rate-submit.c

index b7b703722bbb102c84e0dbfd1fed7be0b35727e5..13dbe7a2e9ff8f3face1619e750b83018ba222df 100644 (file)
@@ -97,8 +97,11 @@ static int io_workqueue_fn(struct submit_worker *sw,
                        td->cur_depth -= ret;
        }
 
-       if (error || td->error)
+       if (error || td->error) {
+               pthread_mutex_lock(&td->io_u_lock);
                pthread_cond_signal(&td->parent->free_cond);
+               pthread_mutex_unlock(&td->io_u_lock);
+       }
 
        return 0;
 }