virtio-blk: fix hw_queue stopped on arbitrary error
[linux-2.6-microblaze.git] / drivers / block / virtio_blk.c
index 5415876..adfe43f 100644 (file)
@@ -245,10 +245,12 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
        err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num);
        if (err) {
                virtqueue_kick(vblk->vqs[qid].vq);
-               blk_mq_stop_hw_queue(hctx);
+               /* Don't stop the queue if -ENOMEM: we may have failed to
+                * bounce the buffer due to global resource outage.
+                */
+               if (err == -ENOSPC)
+                       blk_mq_stop_hw_queue(hctx);
                spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags);
-               /* Out of mem doesn't actually happen, since we fall back
-                * to direct descriptors */
                if (err == -ENOMEM || err == -ENOSPC)
                        return BLK_STS_DEV_RESOURCE;
                return BLK_STS_IOERR;