Skip to content
  • Hanna Reitz's avatar
    ca9bd24c
    block: Rewrite bdrv_close_all() · ca9bd24c
    Hanna Reitz authored
    
    
    This patch rewrites bdrv_close_all(): Until now, all root BDSs have been
    force-closed. This is bad because it can lead to cached data not being
    flushed to disk.
    
    Instead, try to make all reference holders relinquish their reference
    voluntarily:
    
    1. All BlockBackend users are handled by making all BBs simply eject
       their BDS tree. Since a BDS can never be on top of a BB, this will
       not cause any of the issues as seen with the force-closing of BDSs.
       The references will be relinquished and any further access to the BB
       will fail gracefully.
    2. All BDSs which are owned by the monitor itself (because they do not
       have a BB) are relinquished next.
    3. Besides BBs and the monitor, block jobs and other BDSs are the only
       things left that can hold a reference to BDSs. After every remaining
       block job has been canceled, there should not be any BDSs left (and
       the loop added here will always terminate (as long as NDEBUG is not
       defined), because either all_bdrv_states will be empty or there will
       not be any block job left to cancel, failing the assertion).
    
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    ca9bd24c
    block: Rewrite bdrv_close_all()
    Hanna Reitz authored
    
    
    This patch rewrites bdrv_close_all(): Until now, all root BDSs have been
    force-closed. This is bad because it can lead to cached data not being
    flushed to disk.
    
    Instead, try to make all reference holders relinquish their reference
    voluntarily:
    
    1. All BlockBackend users are handled by making all BBs simply eject
       their BDS tree. Since a BDS can never be on top of a BB, this will
       not cause any of the issues as seen with the force-closing of BDSs.
       The references will be relinquished and any further access to the BB
       will fail gracefully.
    2. All BDSs which are owned by the monitor itself (because they do not
       have a BB) are relinquished next.
    3. Besides BBs and the monitor, block jobs and other BDSs are the only
       things left that can hold a reference to BDSs. After every remaining
       block job has been canceled, there should not be any BDSs left (and
       the loop added here will always terminate (as long as NDEBUG is not
       defined), because either all_bdrv_states will be empty or there will
       not be any block job left to cancel, failing the assertion).
    
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading