diff options
author | Alex Elder <elder@inktank.com> | 2013-05-31 17:40:44 -0500 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-07-03 15:32:41 -0700 |
commit | 82a442d239695a242c4d584464c9606322cd02aa (patch) | |
tree | 50ce1f9db9ecede73a92fc6ce1680e340495fee1 /drivers | |
parent | 751cc0e3cfabdda87c4c21519253c6751e97a8d4 (diff) | |
download | linux-82a442d239695a242c4d584464c9606322cd02aa.tar.gz linux-82a442d239695a242c4d584464c9606322cd02aa.tar.bz2 linux-82a442d239695a242c4d584464c9606322cd02aa.zip |
rbd: protect against concurrent unmaps
Make sure two concurrent unmap operations on the same rbd device
won't collide, by only proceeding with the removal and cleanup of a
device if is not already underway.
Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/rbd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 9eead4879c90..305c740778c6 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -5137,6 +5137,7 @@ static ssize_t rbd_remove(struct bus_type *bus, struct list_head *tmp; int dev_id; unsigned long ul; + bool already = false; int ret; ret = strict_strtoul(buf, 10, &ul); @@ -5164,11 +5165,12 @@ static ssize_t rbd_remove(struct bus_type *bus, if (rbd_dev->open_count) ret = -EBUSY; else - set_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags); + already = test_and_set_bit(RBD_DEV_FLAG_REMOVING, + &rbd_dev->flags); spin_unlock_irq(&rbd_dev->lock); } spin_unlock(&rbd_dev_list_lock); - if (ret < 0) + if (ret < 0 || already) goto done; rbd_bus_del_dev(rbd_dev); |