Commit 1abec4fdbb142e3ccb6ce99832fae42129134a96

Authored by Mike Snitzer
Committed by Jens Axboe
1 parent c86d1b8ae6

block: make blk_init_free_list and elevator_init idempotent

blk_init_allocated_queue_node may fail and the caller _could_ retry.
Accommodate the unlikely event that blk_init_allocated_queue_node is
called on an already initialized (possibly partially) request_queue.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Showing 2 changed files with 7 additions and 2 deletions Side-by-side Diff

... ... @@ -467,6 +467,9 @@
467 467 {
468 468 struct request_list *rl = &q->rq;
469 469  
  470 + if (unlikely(rl->rq_pool))
  471 + return 0;
  472 +
470 473 rl->count[BLK_RW_SYNC] = rl->count[BLK_RW_ASYNC] = 0;
471 474 rl->starved[BLK_RW_SYNC] = rl->starved[BLK_RW_ASYNC] = 0;
472 475 rl->elvpriv = 0;
... ... @@ -242,9 +242,11 @@
242 242 {
243 243 struct elevator_type *e = NULL;
244 244 struct elevator_queue *eq;
245   - int ret = 0;
246 245 void *data;
247 246  
  247 + if (unlikely(q->elevator))
  248 + return 0;
  249 +
248 250 INIT_LIST_HEAD(&q->queue_head);
249 251 q->last_merge = NULL;
250 252 q->end_sector = 0;
... ... @@ -284,7 +286,7 @@
284 286 }
285 287  
286 288 elevator_attach(q, eq, data);
287   - return ret;
  289 + return 0;
288 290 }
289 291 EXPORT_SYMBOL(elevator_init);
290 292