]> git.baikalelectronics.ru Git - kernel.git/commit
io-wq: fix IO_WORKER_F_FIXED issue in create_io_worker()
authorHao Xu <haoxu@linux.alibaba.com>
Sun, 8 Aug 2021 13:54:34 +0000 (21:54 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 10 Aug 2021 01:59:06 +0000 (19:59 -0600)
commitce2fc89cc5244f25709f48986bd04a2b9bd96b45
treeca1d73da05e7f9699b156f4b4b0f40bccdefb5d9
parentb6e1db2b3e03621d0d5f8090f2f5414a26aef6c2
io-wq: fix IO_WORKER_F_FIXED issue in create_io_worker()

There may be cases like:
        A                                 B
spin_lock(wqe->lock)
nr_workers is 0
nr_workers++
spin_unlock(wqe->lock)
                                     spin_lock(wqe->lock)
                                     nr_wokers is 1
                                     nr_workers++
                                     spin_unlock(wqe->lock)
create_io_worker()
  acct->worker is 1
                                     create_io_worker()
                                       acct->worker is 1

There should be one worker marked IO_WORKER_F_FIXED, but no one is.
Fix this by introduce a new agrument for create_io_worker() to indicate
if it is the first worker.

Fixes: 54ebaec01ab3 ("io-wq: fix no lock protection of acct->nr_worker")
Signed-off-by: Hao Xu <haoxu@linux.alibaba.com>
Link: https://lore.kernel.org/r/20210808135434.68667-3-haoxu@linux.alibaba.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c