]> git.kernelconcepts.de Git - karo-tx-linux.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:51:21 +0000 (08:51 -0800)
commit3317122449a2ce5c0bba77e1f05b1df2ff716447
tree56de6b861daee00e1f6399e46c94f0fde7ddfdc1
parent1e411c66732294f5fb983323dafa7559796481f5
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>
(based on commit 42382b709bd1d143b9f0fa93e0a3a1f2f4210707)
drivers/block/rbd.c