Skip to content
  • Alberto Garcia's avatar
    dd4118c7
    block: Use bdrv_unref_child() for all children in bdrv_close() · dd4118c7
    Alberto Garcia authored
    
    
    bdrv_unref_child() does the following things:
    
      - Updates the child->bs->inherits_from pointer.
      - Calls bdrv_detach_child() to remove the BdrvChild from bs->children.
      - Calls bdrv_unref() to unref the child BlockDriverState.
    
    When bdrv_unref_child() was introduced in commit 33a60407 it was not
    used in bdrv_close() because the drivers that had additional children
    (like quorum or blkverify) had already called bdrv_unref() on their
    children during their own close functions.
    
    This was changed later (in 0bd6e91a for quorum, in 3e586be0 for
    blkverify) so there's no reason not to use bdrv_unref_child() in
    bdrv_close() anymore.
    
    After this there's also no need to remove bs->backing and bs->file
    separately from the rest of the children, so bdrv_close() can be
    simplified.
    
    Now bdrv_close() unrefs all children (before this patch it was only
    bs->file and bs->backing). As a result, none of the callers of
    brvd_attach_child() should remove their reference to child_bs (because
    this function effectively steals that reference). This patch updates a
    couple of tests that were doing their own bdrv_unref().
    
    Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
    Message-id: 6d1d5feaa53aa1ab127adb73d605dc4503e3abd5.1557754872.git.berto@igalia.com
    [mreitz: s/where/were/]
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    dd4118c7
    block: Use bdrv_unref_child() for all children in bdrv_close()
    Alberto Garcia authored
    
    
    bdrv_unref_child() does the following things:
    
      - Updates the child->bs->inherits_from pointer.
      - Calls bdrv_detach_child() to remove the BdrvChild from bs->children.
      - Calls bdrv_unref() to unref the child BlockDriverState.
    
    When bdrv_unref_child() was introduced in commit 33a60407 it was not
    used in bdrv_close() because the drivers that had additional children
    (like quorum or blkverify) had already called bdrv_unref() on their
    children during their own close functions.
    
    This was changed later (in 0bd6e91a for quorum, in 3e586be0 for
    blkverify) so there's no reason not to use bdrv_unref_child() in
    bdrv_close() anymore.
    
    After this there's also no need to remove bs->backing and bs->file
    separately from the rest of the children, so bdrv_close() can be
    simplified.
    
    Now bdrv_close() unrefs all children (before this patch it was only
    bs->file and bs->backing). As a result, none of the callers of
    brvd_attach_child() should remove their reference to child_bs (because
    this function effectively steals that reference). This patch updates a
    couple of tests that were doing their own bdrv_unref().
    
    Signed-off-by: default avatarAlberto Garcia <berto@igalia.com>
    Message-id: 6d1d5feaa53aa1ab127adb73d605dc4503e3abd5.1557754872.git.berto@igalia.com
    [mreitz: s/where/were/]
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Loading