[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 05/16] block: Convert bs->file to BdrvChild
From: |
Alberto Garcia |
Subject: |
Re: [Qemu-devel] [PATCH 05/16] block: Convert bs->file to BdrvChild |
Date: |
Fri, 25 Sep 2015 16:09:35 +0200 |
User-agent: |
Notmuch/0.13.2 (http://notmuchmail.org) Emacs/23.2.1 (i486-pc-linux-gnu) |
On Thu 17 Sep 2015 03:48:09 PM CEST, Kevin Wolf <address@hidden> wrote:
> @@ -1929,6 +1925,11 @@ void bdrv_close(BlockDriverState *bs)
> bdrv_unref(backing_hd);
> }
>
> + if (bs->file != NULL) {
> + bdrv_unref(bs->file->bs);
> + bs->file = NULL;
> + }
> +
> QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
> /* TODO Remove bdrv_unref() from drivers' close function and use
> * bdrv_unref_child() here */
> @@ -1953,11 +1954,6 @@ void bdrv_close(BlockDriverState *bs)
> bs->options = NULL;
> QDECREF(bs->full_open_options);
> bs->full_open_options = NULL;
> -
> - if (bs->file != NULL) {
> - bdrv_unref(bs->file);
> - bs->file = NULL;
> - }
> }
You are moving bdrv_unref(bs->file) up in the function and this seems to
be causing a problem, by turning this:
bs->drv->bdrv_close(bs);
bs->drv = NULL;
bdrv_unref(bs->file);
into this:
bs->drv->bdrv_close(bs);
bdrv_unref(bs->file);
bs->drv = NULL;
In the latter case, closing bs->file calls aio_poll(). This can trigger
new requests on bs, which at that point has a valid pointer to a
BlockDriver that has already been closed. If throttling is enabled on bs
those requests might be queued for later. At the point in which those
requests are scheduled bs->drv is already NULL, crashing QEMU. I can
reproduce this easily with x-data-plane=on.
I sent a separate patch that moves the bdrv_io_limits_disable() call to
the beginning of bdrv_close(). That solves the crash, but I guess that
this patch should also be changed.
Berto
- Re: [Qemu-devel] [PATCH 13/16] block: Implement bdrv_append() without bdrv_swap(), (continued)
- [Qemu-devel] [PATCH 12/16] block: Introduce parents list, Kevin Wolf, 2015/09/17
- [Qemu-devel] [PATCH 15/16] block: Add and use bdrv_replace_in_backing_chain(), Kevin Wolf, 2015/09/17
- [Qemu-devel] [PATCH 05/16] block: Convert bs->file to BdrvChild, Kevin Wolf, 2015/09/17
- [Qemu-devel] [PATCH 16/16] block: Remove bdrv_swap(), Kevin Wolf, 2015/09/17
- Re: [Qemu-devel] [PATCH 00/16] block: Get rid of bdrv_swap(), Alberto Garcia, 2015/09/18
- Re: [Qemu-devel] [PATCH 00/16] block: Get rid of bdrv_swap(), Alberto Garcia, 2015/09/24