提交 82a442d2 编写于 作者: A Alex Elder 提交者: Sage Weil

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: NAlex Elder <elder@inktank.com>
Reviewed-by: NJosh Durgin <josh.durgin@inktank.com>
上级 751cc0e3
...@@ -5137,6 +5137,7 @@ static ssize_t rbd_remove(struct bus_type *bus, ...@@ -5137,6 +5137,7 @@ static ssize_t rbd_remove(struct bus_type *bus,
struct list_head *tmp; struct list_head *tmp;
int dev_id; int dev_id;
unsigned long ul; unsigned long ul;
bool already = false;
int ret; int ret;
ret = strict_strtoul(buf, 10, &ul); ret = strict_strtoul(buf, 10, &ul);
...@@ -5164,11 +5165,12 @@ static ssize_t rbd_remove(struct bus_type *bus, ...@@ -5164,11 +5165,12 @@ static ssize_t rbd_remove(struct bus_type *bus,
if (rbd_dev->open_count) if (rbd_dev->open_count)
ret = -EBUSY; ret = -EBUSY;
else 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_irq(&rbd_dev->lock);
} }
spin_unlock(&rbd_dev_list_lock); spin_unlock(&rbd_dev_list_lock);
if (ret < 0) if (ret < 0 || already)
goto done; goto done;
rbd_bus_del_dev(rbd_dev); rbd_bus_del_dev(rbd_dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册