Skip to content

Commit 4b422cb

Browse files
biger410konradwilk
authored andcommitted
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 <[email protected]> Reviewed-by: Ankur Arora <[email protected]> Acked-by: Roger Pau Monné <[email protected]> Signed-off-by: Konrad Rzeszutek Wilk <[email protected]>
1 parent 76451d7 commit 4b422cb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/block/xen-blkfront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,8 @@ static blk_status_t blkif_queue_rq(struct blk_mq_hw_ctx *hctx,
906906
return BLK_STS_IOERR;
907907

908908
out_busy:
909-
spin_unlock_irqrestore(&rinfo->ring_lock, flags);
910909
blk_mq_stop_hw_queue(hctx);
910+
spin_unlock_irqrestore(&rinfo->ring_lock, flags);
911911
return BLK_STS_RESOURCE;
912912
}
913913

0 commit comments

Comments
 (0)