From: Heinz Graalfs <graalfs@linux.vnet.ibm.com>
To: Rusty Russell <rusty@rustcorp.com.au>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] virtio_blk: don't crash, report error if virtqueue is broken.
Date: Thu, 30 Jan 2014 10:09:33 +0100 [thread overview]
Message-ID: <52EA16CD.7070807@linux.vnet.ibm.com> (raw)
In-Reply-To: <1389753371-26469-2-git-send-email-rusty@rustcorp.com.au>
On 15/01/14 03:36, Rusty Russell wrote:
> A bad implementation of virtio might cause us to mark the virtqueue
> broken: we'll dev_err() in that case, and the device is useless, but
> let's not BUG_ON().
>
> ENOMEM or ENOSPC implies the ring is full, and we should try again
> later (-ENOMEM is documented to happen, but doesn't, as we fall
> through to ENOSPC).
>
> EIO means it's broken.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/block/virtio_blk.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 6a680d4de7f1..704d6c814c17 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -158,6 +158,7 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
> unsigned long flags;
> unsigned int num;
> const bool last = (req->cmd_flags & REQ_END) != 0;
> + int err;
>
> BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
>
> @@ -198,11 +199,16 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *req)
> }
>
> spin_lock_irqsave(&vblk->vq_lock, flags);
> - if (__virtblk_add_req(vblk->vq, vbr, vbr->sg, num) < 0) {
> + err = __virtblk_add_req(vblk->vq, vbr, vbr->sg, num);
> + if (err) {
> virtqueue_kick(vblk->vq);
the kick might fail here after a request was successfully added.
> spin_unlock_irqrestore(&vblk->vq_lock, flags);
> blk_mq_stop_hw_queue(hctx);
> - return BLK_MQ_RQ_QUEUE_BUSY;
> + /* Out of mem doesn't actually happen, since we fall back
> + * to direct descriptors */
> + if (err == -ENOMEM || err == -ENOSPC)
> + return BLK_MQ_RQ_QUEUE_BUSY;
> + return BLK_MQ_RQ_QUEUE_ERROR;
> }
>
> if (last)
>
next prev parent reply other threads:[~2014-01-30 9:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-15 2:36 [PATCH 1/6] virtio_net: don't crash if virtqueue is broken Rusty Russell
2014-01-15 2:36 ` [PATCH 2/6] virtio_blk: don't crash, report error " Rusty Russell
2014-01-30 9:09 ` Heinz Graalfs [this message]
2014-01-31 5:00 ` Rusty Russell
2014-01-15 2:36 ` [PATCH 3/6] virtio_balloon: don't crash " Rusty Russell
2014-01-15 2:36 ` [PATCH 4/6] virtio-rng: " Rusty Russell
2014-01-15 2:36 ` [PATCH 5/6] virtio: fail adding buffer on broken queues Rusty Russell
2014-01-15 2:36 ` [PATCH 6/6] virtio: virtio_break_device() to mark all virtqueues broken Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52EA16CD.7070807@linux.vnet.ibm.com \
--to=graalfs@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).