From: Junxiao Bi Date: Mon, 19 Jun 2017 07:56:36 +0000 (+0800) Subject: xen-blkfront: fix mq start/stop race X-Git-Tag: v4.1.12-106.0.20170710_2300~59 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=20a524d9cdbcb1f7f83700b34ea4f2da14f8da7d;p=users%2Fjedix%2Flinux-maple.git xen-blkfront: fix mq start/stop race Orabug: 26397415 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 Reviewed-by: Ankur Arora Reviewed-by: Boris Ostrovsky Acked-by: Roger Pau Monné --- diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 2edf895d3d0f..2320f230c530 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -912,8 +912,8 @@ out_err: return BLK_MQ_RQ_QUEUE_ERROR; out_busy: - spin_unlock_irqrestore(&rinfo->ring_lock, flags); blk_mq_stop_hw_queue(hctx); + spin_unlock_irqrestore(&rinfo->ring_lock, flags); return BLK_MQ_RQ_QUEUE_BUSY; }