]> git.ipfire.org Git - people/arne_f/kernel.git/commit
rbd: avoid a deadlock on header_rwsem when flushing notifies
authorIlya Dryomov <idryomov@gmail.com>
Fri, 13 Mar 2020 10:20:51 +0000 (11:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Apr 2020 06:01:14 +0000 (08:01 +0200)
commitfce4bd5793775570e461fc5d2da9b47e12a62c74
tree850d4ca6b0c2320210c86d1eb08fdf74df00e161
parentc6c4c74a0fe1bbe0141311f1bcec9e175897fd99
rbd: avoid a deadlock on header_rwsem when flushing notifies

[ Upstream commit 0e4e1de5b63fa423b13593337a27fd2d2b0bcf77 ]

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: 811c66887746 ("rbd: fix rbd map vs notify races")
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/block/rbd.c