Skip to content
  • Vladimir Sementsov-Ogievskiy's avatar
    a2aabf88
    block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare · a2aabf88
    Vladimir Sementsov-Ogievskiy authored
    
    
    During reopen we may add backing bs from other aio context, which may
    lead to changing original context of top bs.
    
    We are going to move graph modification to prepare stage. So, it will
    be possible that bdrv_flush() in bdrv_reopen_prepare called on bs in
    non-original aio context, which we didn't aquire which leads to crash.
    
    To avoid this problem move bdrv_flush() to be a separate reopen stage
    before bdrv_reopen_prepare().
    
    This doesn't seem correct to acquire only one aio context and not all
    contexts participating in reopen. But it's not obvious how to do it
    correctly, keeping in mind:
    
     1. rules of bdrv_set_aio_context_ignore() that requires new_context
        lock not being held
    
     2. possible deadlocks because of holding all (or several?) AioContext
        locks
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20210428151804.439460-30-vsementsov@virtuozzo.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    a2aabf88
    block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare
    Vladimir Sementsov-Ogievskiy authored
    
    
    During reopen we may add backing bs from other aio context, which may
    lead to changing original context of top bs.
    
    We are going to move graph modification to prepare stage. So, it will
    be possible that bdrv_flush() in bdrv_reopen_prepare called on bs in
    non-original aio context, which we didn't aquire which leads to crash.
    
    To avoid this problem move bdrv_flush() to be a separate reopen stage
    before bdrv_reopen_prepare().
    
    This doesn't seem correct to acquire only one aio context and not all
    contexts participating in reopen. But it's not obvious how to do it
    correctly, keeping in mind:
    
     1. rules of bdrv_set_aio_context_ignore() that requires new_context
        lock not being held
    
     2. possible deadlocks because of holding all (or several?) AioContext
        locks
    
    Signed-off-by: default avatarVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
    Reviewed-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20210428151804.439460-30-vsementsov@virtuozzo.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading