OSDN Git Service

io-wq: ensure we have a stable view of ->cur_work for cancellations
authorJens Axboe <axboe@kernel.dk>
Wed, 13 Nov 2019 16:43:34 +0000 (09:43 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 13 Nov 2019 20:51:54 +0000 (13:51 -0700)
commit36c2f9223e84c1aa84bfba90cb2e74b517c92a54
treeacb3bcd8f5cb61020c13a32c6ef7cacea84dd167
parent7d7230652e7c788ef908536fd79f4cca077f269f
io-wq: ensure we have a stable view of ->cur_work for cancellations

worker->cur_work is currently protected by the lock of the wqe that the
worker belongs to. When we send a signal to a worker, we need a stable
view of ->cur_work, so we need to hold that lock. But this doesn't work
so well, since we have the opposite order potentially on queueing work.
If POLL_ADD is used with a signalfd, then io_poll_wake() is called with
the signal lock, and that sometimes needs to insert work items.

Add a specific worker lock that protects the current work item. Then we
can guarantee that the task we're sending a signal is currently
processing the exact work we think it is.

Reported-by: Paul E. McKenney <paulmck@kernel.org>
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io-wq.c