]> git.baikalelectronics.ru Git - kernel.git/commit
rbd: prevent open for image being removed
authorAlex Elder <elder@inktank.com>
Mon, 14 Jan 2013 18:43:31 +0000 (12:43 -0600)
committerSage Weil <sage@inktank.com>
Thu, 14 Feb 2013 02:29:10 +0000 (18:29 -0800)
commit32e416dac09dd37c6a461be359c47166e1e4c29f
tree45f23409f8412ad4c536b1002553a8f8dd7a5081
parentd4772a09dd707d489e0c338cc8b832d89e95bc2d
rbd: prevent open for image being removed

An open request for a mapped rbd image can arrive while removal of
that mapping is underway.  We need to prevent such an open request
from succeeding.  (It appears that Maciej Galkiewicz ran into this
problem.)

Define and use a "removing" flag to indicate a mapping is getting
removed.  Set it in the remove path after verifying nothing holds
the device open.  And check it in the open path before allowing the
open to proceed.  Acquire the rbd device's lock around each of these
spots to avoid any races accessing the flags and open_count fields.

This addresses:
    http://tracker.newdream.net/issues/3427

Reported-by: Maciej Galkiewicz <maciejgalkiewicz@ragnarson.com>
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
drivers/block/rbd.c