rbd: move locking out of rbd_header_set_snap()
authorAlex Elder <elder@inktank.com>
Fri, 24 Aug 2012 04:48:49 +0000 (23:48 -0500)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:51 +0000 (14:30 -0500)
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>
drivers/block/rbd.c

index 634a16c40291c40b0b33836f4ce35bb9c0e6e1d1..214c937a6de5292a9ff7f4426b28928df7987d1f 100644 (file)
@@ -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;