Skip to content
  • Eric Blake's avatar
    61bc846d
    nbd: Grab aio context lock in more places · 61bc846d
    Eric Blake authored
    
    
    When iothreads are in use, the failure to grab the aio context results
    in an assertion failure when trying to unlock things during blk_unref,
    when trying to unlock a mutex that was not locked.  In short, all
    calls to nbd_export_put need to done while within the correct aio
    context.  But since nbd_export_put can recursively reach itself via
    nbd_export_close, and recursively grabbing the context would deadlock,
    we can't do the context grab directly in those functions, but must do
    so in their callers.
    
    Hoist the use of the correct aio_context from nbd_export_new() to its
    caller qmp_nbd_server_add().  Then tweak qmp_nbd_server_remove(),
    nbd_eject_notifier(), and nbd_esport_close_all() to grab the right
    context, so that all callers during qemu now own the context before
    nbd_export_put() can call blk_unref().
    
    Remaining uses in qemu-nbd don't matter (since that use case does not
    support iothreads).
    
    Suggested-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20190917023917.32226-1-eblake@redhat.com>
    Reviewed-by: default avatarSergio Lopez <slp@redhat.com>
    61bc846d
    nbd: Grab aio context lock in more places
    Eric Blake authored
    
    
    When iothreads are in use, the failure to grab the aio context results
    in an assertion failure when trying to unlock things during blk_unref,
    when trying to unlock a mutex that was not locked.  In short, all
    calls to nbd_export_put need to done while within the correct aio
    context.  But since nbd_export_put can recursively reach itself via
    nbd_export_close, and recursively grabbing the context would deadlock,
    we can't do the context grab directly in those functions, but must do
    so in their callers.
    
    Hoist the use of the correct aio_context from nbd_export_new() to its
    caller qmp_nbd_server_add().  Then tweak qmp_nbd_server_remove(),
    nbd_eject_notifier(), and nbd_esport_close_all() to grab the right
    context, so that all callers during qemu now own the context before
    nbd_export_put() can call blk_unref().
    
    Remaining uses in qemu-nbd don't matter (since that use case does not
    support iothreads).
    
    Suggested-by: default avatarKevin Wolf <kwolf@redhat.com>
    Signed-off-by: default avatarEric Blake <eblake@redhat.com>
    Message-Id: <20190917023917.32226-1-eblake@redhat.com>
    Reviewed-by: default avatarSergio Lopez <slp@redhat.com>
Loading