diff mbox

[v3,28/44] block: Fix pending requests check in bdrv_append()

Message ID 1488286469-9381-29-git-send-email-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kevin Wolf Feb. 28, 2017, 12:54 p.m. UTC
bdrv_append() cares about isolation of the node that it modifies, but
not about activity in some subtree below it. Instead of using the
recursive bdrv_requests_pending(), directly check bs->in_flight, which
considers only the node in question.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alberto Garcia Oct. 4, 2017, 10:24 a.m. UTC | #1
On Tue 28 Feb 2017 01:54:13 PM CET, Kevin Wolf wrote:
> bdrv_append() cares about isolation of the node that it modifies, but
> not about activity in some subtree below it. Instead of using the
> recursive bdrv_requests_pending(), directly check bs->in_flight, which
> considers only the node in question.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
>  block.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/block.c b/block.c
> index 9e538a5..5189c7c 100644
> --- a/block.c
> +++ b/block.c
> @@ -2897,8 +2897,8 @@ static void change_parent_backing_link(BlockDriverState *from,
>   */
>  void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
>  {
> -    assert(!bdrv_requests_pending(bs_top));
> -    assert(!bdrv_requests_pending(bs_new));
> +    assert(!atomic_read(&bs_top->in_flight));
> +    assert(!atomic_read(&bs_new->in_flight));
>  
>      bdrv_ref(bs_top);

I don't know if there's still any maintenance on the v2.8.x branch, but
I can make v2.8.1.1 crash easily because of this failing assertion.
Applying this patch fixes the issue.

I can provide more details if needed.

Regards,

Berto
diff mbox

Patch

diff --git a/block.c b/block.c
index 9e538a5..5189c7c 100644
--- a/block.c
+++ b/block.c
@@ -2897,8 +2897,8 @@  static void change_parent_backing_link(BlockDriverState *from,
  */
 void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top)
 {
-    assert(!bdrv_requests_pending(bs_top));
-    assert(!bdrv_requests_pending(bs_new));
+    assert(!atomic_read(&bs_top->in_flight));
+    assert(!atomic_read(&bs_new->in_flight));
 
     bdrv_ref(bs_top);