Skip to content

Commit be987fd

Browse files
hreineckeJens Axboe
authored andcommitted
block: fix deadlock in blk_abort_queue() for drivers that readd to timeout list
blk_abort_queue() iterates the timeout list and aborts each request on the list, but if the driver error handling readds a request to the timeout list during this processing, we could be looping forever. Fix this by splicing current entries to a local list and run over that list instead. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent 41b8c85 commit be987fd

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎block/blk-timeout.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,19 @@ void blk_abort_queue(struct request_queue *q)
209209
{
210210
unsigned long flags;
211211
struct request *rq, *tmp;
212+
LIST_HEAD(list);
212213

213214
spin_lock_irqsave(q->queue_lock, flags);
214215

215216
elv_abort_queue(q);
216217

217-
list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list)
218+
/*
219+
* Splice entries to local list, to avoid deadlocking if entries
220+
* get readded to the timeout list by error handling
221+
*/
222+
list_splice_init(&q->timeout_list, &list);
223+
224+
list_for_each_entry_safe(rq, tmp, &list, timeout_list)
218225
blk_abort_request(rq);
219226

220227
spin_unlock_irqrestore(q->queue_lock, flags);

0 commit comments

Comments
 (0)