]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - block/blk-exec.c
[media] au0828: fix case where STREAMOFF being called on stopped stream causes BUG()
[karo-tx-linux.git] / block / blk-exec.c
index a1ebceb332f963ee366aa7ebed60d69c4e1c11cb..8b6dc5bd4dd061336172b144ae8c09da6bbc56f8 100644 (file)
@@ -43,6 +43,9 @@ static void blk_end_sync_rq(struct request *rq, int error)
  * Description:
  *    Insert a fully prepared request at the back of the I/O scheduler queue
  *    for execution.  Don't wait for completion.
+ *
+ * Note:
+ *    This function will invoke @done directly if the queue is dead.
  */
 void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
                           struct request *rq, int at_head,
@@ -50,17 +53,21 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
 {
        int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
 
-       if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
+       WARN_ON(irqs_disabled());
+
+       rq->rq_disk = bd_disk;
+       rq->end_io = done;
+
+       spin_lock_irq(q->queue_lock);
+
+       if (unlikely(blk_queue_dead(q))) {
                rq->errors = -ENXIO;
                if (rq->end_io)
                        rq->end_io(rq, rq->errors);
+               spin_unlock_irq(q->queue_lock);
                return;
        }
 
-       rq->rq_disk = bd_disk;
-       rq->end_io = done;
-       WARN_ON(irqs_disabled());
-       spin_lock_irq(q->queue_lock);
        __elv_add_request(q, rq, where);
        __blk_run_queue(q);
        /* the queue is stopped so it won't be run */