• Ilya Dryomov's avatar
    rbd: avoid a deadlock on header_rwsem when flushing notifies · 0e4e1de5
    Ilya Dryomov authored
    rbd_unregister_watch() flushes notifies and therefore cannot be called
    under header_rwsem because a header update notify takes header_rwsem to
    synchronize with "rbd map".  If mapping an image fails after the watch
    is established and a header update notify sneaks in, we deadlock when
    erroring out from rbd_dev_image_probe().
    
    Move watch registration and unregistration out of the critical section.
    The only reason they were put there was to make header_rwsem management
    slightly more obvious.
    
    Fixes: 811c6688 ("rbd: fix rbd map vs notify races")
    Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
    Reviewed-by: default avatarJason Dillaman <dillaman@redhat.com>
    0e4e1de5
rbd.c 184 KB