OSDN Git Service

io-wq: wait for io_wq_create() to setup necessary workers
authorJens Axboe <axboe@kernel.dk>
Tue, 19 Nov 2019 15:37:07 +0000 (08:37 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 26 Nov 2019 02:56:05 +0000 (19:56 -0700)
commitb60fda6000a99a7ccac36005ab78b14b47c06de3
treea67c574d4f9fbe463204c60735405c7779c52356
parentfba38c272a0385148935d6443cb9dc68cf1f37a7
io-wq: wait for io_wq_create() to setup necessary workers

We currently have a race where if setup is really slow, we can be
calling io_wq_destroy() before we're done setting up. This will cause
the caller to get stuck waiting for the manager to set things up, but
the manager already exited.

Fix this by doing a sync setup of the manager. This also fixes the case
where if we failed creating workers, we'd also get stuck.

In practice this race window was really small, as we already wait for
the manager to start. Hence someone would have to call io_wq_destroy()
after the task has started, but before it started the first loop. The
reported test case forked tons of these, which is why it became an
issue.

Reported-by: syzbot+0f1cc17f85154f400465@syzkaller.appspotmail.com
Fixes: 771b53d033e8 ("io-wq: small threadpool implementation for io_uring")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c