Skip to content
  • Hanna Reitz's avatar
    6d17e287
    block/vmdk: Fix reopening bs->file · 6d17e287
    Hanna Reitz authored
    
    
    VMDK disk data is stored in extents, which may or may not be separate
    from bs->file.  VmdkExtent.file points to where they are stored.  Each
    that is stored in bs->file will simply reuse the exact pointer value of
    bs->file.
    
    (That is why vmdk_free_extents() will unref VmdkExtent.file (e->file)
    only if e->file != bs->file.)
    
    Reopen operations can change bs->file (they will replace the whole
    BdrvChild object, not just the BDS stored in that BdrvChild), and then
    we will need to change all .file pointers of all such VmdkExtents to
    point to the new BdrvChild.
    
    In vmdk_reopen_prepare(), we have to check which VmdkExtents are
    affected, and in vmdk_reopen_commit(), we can modify them.  We have to
    split this because:
    - The new BdrvChild is created only after prepare, so we can change
      VmdkExtent.file only in commit
    - In commit, there no longer is any (valid) reference to the old
      BdrvChild object, so there would be nothing to compare VmdkExtent.file
      against to see whether it was equal to bs->file before reopening
      (There is BDRVReopenState.old_file_bs, but the old bs->file
      BdrvChild's .bs pointer will be NULL-ed when the new BdrvChild is
      created, and so we cannot compare VmdkExtent.file->bs against
      BDRVReopenState.old_file_bs)
    
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20220314162719.65384-2-hreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    6d17e287
    block/vmdk: Fix reopening bs->file
    Hanna Reitz authored
    
    
    VMDK disk data is stored in extents, which may or may not be separate
    from bs->file.  VmdkExtent.file points to where they are stored.  Each
    that is stored in bs->file will simply reuse the exact pointer value of
    bs->file.
    
    (That is why vmdk_free_extents() will unref VmdkExtent.file (e->file)
    only if e->file != bs->file.)
    
    Reopen operations can change bs->file (they will replace the whole
    BdrvChild object, not just the BDS stored in that BdrvChild), and then
    we will need to change all .file pointers of all such VmdkExtents to
    point to the new BdrvChild.
    
    In vmdk_reopen_prepare(), we have to check which VmdkExtents are
    affected, and in vmdk_reopen_commit(), we can modify them.  We have to
    split this because:
    - The new BdrvChild is created only after prepare, so we can change
      VmdkExtent.file only in commit
    - In commit, there no longer is any (valid) reference to the old
      BdrvChild object, so there would be nothing to compare VmdkExtent.file
      against to see whether it was equal to bs->file before reopening
      (There is BDRVReopenState.old_file_bs, but the old bs->file
      BdrvChild's .bs pointer will be NULL-ed when the new BdrvChild is
      created, and so we cannot compare VmdkExtent.file->bs against
      BDRVReopenState.old_file_bs)
    
    Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
    Message-Id: <20220314162719.65384-2-hreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading