summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-08-24 06:48:49 +0200
committerAlex Elder <elder@inktank.com>2012-10-01 21:30:51 +0200
commit4bb1f1ed0063870f34ae5783cda08924964bac0b (patch)
treed4e2ce70d02b0bffb08a31da4f55e08237c16f99 /drivers
parentrbd: simplify rbd_init_disk() a bit (diff)
downloadlinux-4bb1f1ed0063870f34ae5783cda08924964bac0b.tar.xz
linux-4bb1f1ed0063870f34ae5783cda08924964bac0b.zip
rbd: move locking out of rbd_header_set_snap()
Move the calls to get the header semaphore out of rbd_header_set_snap() and into its caller. 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.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 634a16c40291..214c937a6de5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -647,8 +647,6 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, char *snap_name)
{
int ret;
- down_write(&rbd_dev->header_rwsem);
-
if (!memcmp(snap_name, RBD_SNAP_HEAD_NAME,
sizeof (RBD_SNAP_HEAD_NAME))) {
rbd_dev->mapping.snap_id = CEPH_NOSNAP;
@@ -666,7 +664,6 @@ static int rbd_header_set_snap(struct rbd_device *rbd_dev, char *snap_name)
ret = 0;
done:
- up_write(&rbd_dev->header_rwsem);
return ret;
}
@@ -2608,7 +2605,9 @@ static ssize_t rbd_add(struct bus_type *bus,
if (rc)
goto err_out_bus;
+ down_write(&rbd_dev->header_rwsem);
rc = rbd_header_set_snap(rbd_dev, snap_name);
+ up_write(&rbd_dev->header_rwsem);
if (rc)
goto err_out_bus;