]> git.baikalelectronics.ru Git - kernel.git/commit
rbd: do not allow remove of mounted-on image
authorAlex Elder <elder@inktank.com>
Fri, 16 Nov 2012 15:29:16 +0000 (09:29 -0600)
committerAlex Elder <elder@inktank.com>
Mon, 17 Dec 2012 14:36:59 +0000 (08:36 -0600)
commit4b797fb6656bf0f0ae83b1f5da69a613c4d75dc3
tree2d6a8c6910ab15bffed7ab91d74005e05984f891
parent4ce2155ca9000e58c41731a6c09d69045156dc33
rbd: do not allow remove of mounted-on image

There is no check in rbd_remove() to see if anybody holds open the
image being removed.  That's not cool.

Add a simple open count that goes up and down with opens and closes
(releases) of the device, and don't allow an rbd image to be removed
if the count is non-zero.

Protect the updates of the open count value with ctl_mutex to ensure
the underlying rbd device doesn't get removed while concurrently
being opened.

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
drivers/block/rbd.c