Commit 7aa73ee1 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

rbd: protect against concurrent unmaps

commit 82a442d2 upstream.

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: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarJosh Durgin <josh.durgin@inktank.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c4d00f5b
......@@ -5108,6 +5108,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);
......@@ -5135,11 +5136,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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment