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)
commit47cae0c71f7a126903f930191e6e9f103674aca1
treeca1d73da05e7f9699b156f4b4b0f40bccdefb5d9
parent49e7f0c789add1330b111af0b7caeb0e87df063e
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: 3d4e4face9c1 ("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