]> git.baikalelectronics.ru Git - kernel.git/commit
xen-blkfront: fix mq start/stop race
authorJunxiao Bi <junxiao.bi@oracle.com>
Thu, 20 Jul 2017 01:26:21 +0000 (09:26 +0800)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 25 Jul 2017 15:30:59 +0000 (11:30 -0400)
commit4b422cb99836de3d261faec20a0329385bdec43d
treebefe906fd623d221f2ca529f7350d6d41e698b93
parent76451d79bde6bed17e113f057e58e1fa5fb79e78
xen-blkfront: fix mq start/stop race

When ring buf full, hw queue will be stopped. While blkif interrupt consume
request and make free space in ring buf, hw queue will be started again.
But since start queue is protected by spin lock while stop not, that will
cause a race.

interrupt:                                      process:
blkif_interrupt()                               blkif_queue_rq()
 kick_pending_request_queues_locked()
   blk_mq_start_stopped_hw_queues()
      clear_bit(BLK_MQ_S_STOPPED, &hctx->state)
                                             blk_mq_stop_hw_queue(hctx)
  blk_mq_run_hw_queue(hctx, async)

If ring buf is made empty in this case, interrupt will never come, then the
hw queue will be stopped forever, all processes waiting for the pending io
in the queue will hung.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
Reviewed-by: Ankur Arora <ankur.a.arora@oracle.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkfront.c