aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-07-25 10:32:41 -0400
committerSage Weil <sage@inktank.com>2012-07-30 21:21:46 -0400
commit1fe5e9932156f6122c3b1ff6ba7541c27c86718c (patch)
treec5218897ce6cfbc3e2d5686772eb2bdabf415c89 /drivers/block/rbd.c
parentb813623ab95d0b4bbeb22e160bd5461965d0c571 (diff)
rbd: create rbd_refresh_helper()
Create a simple helper that handles the common case of calling __rbd_refresh_header() while holding the ctl_mutex. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index de981ac72362..9917943a3572 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -240,7 +240,7 @@ static void rbd_put_dev(struct rbd_device *rbd_dev)
240 put_device(&rbd_dev->dev); 240 put_device(&rbd_dev->dev);
241} 241}
242 242
243static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver); 243static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver);
244 244
245static int rbd_open(struct block_device *bdev, fmode_t mode) 245static int rbd_open(struct block_device *bdev, fmode_t mode)
246{ 246{
@@ -1225,9 +1225,7 @@ static void rbd_watch_cb(u64 ver, u64 notify_id, u8 opcode, void *data)
1225 dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n", 1225 dout("rbd_watch_cb %s notify_id=%llu opcode=%u\n",
1226 rbd_dev->header_name, (unsigned long long) notify_id, 1226 rbd_dev->header_name, (unsigned long long) notify_id,
1227 (unsigned int) opcode); 1227 (unsigned int) opcode);
1228 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1228 rc = rbd_refresh_header(rbd_dev, &hver);
1229 rc = __rbd_refresh_header(rbd_dev, &hver);
1230 mutex_unlock(&ctl_mutex);
1231 if (rc) 1229 if (rc)
1232 pr_warning(RBD_DRV_NAME "%d got notification but failed to " 1230 pr_warning(RBD_DRV_NAME "%d got notification but failed to "
1233 " update snaps: %d\n", rbd_dev->major, rc); 1231 " update snaps: %d\n", rbd_dev->major, rc);
@@ -1751,6 +1749,17 @@ static int __rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
1751 return ret; 1749 return ret;
1752} 1750}
1753 1751
1752static int rbd_refresh_header(struct rbd_device *rbd_dev, u64 *hver)
1753{
1754 int ret;
1755
1756 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
1757 ret = __rbd_refresh_header(rbd_dev, hver);
1758 mutex_unlock(&ctl_mutex);
1759
1760 return ret;
1761}
1762
1754static int rbd_init_disk(struct rbd_device *rbd_dev) 1763static int rbd_init_disk(struct rbd_device *rbd_dev)
1755{ 1764{
1756 struct gendisk *disk; 1765 struct gendisk *disk;
@@ -1904,9 +1913,7 @@ static ssize_t rbd_image_refresh(struct device *dev,
1904 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev); 1913 struct rbd_device *rbd_dev = dev_to_rbd_dev(dev);
1905 int ret; 1914 int ret;
1906 1915
1907 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 1916 ret = rbd_refresh_header(rbd_dev, NULL);
1908 ret = __rbd_refresh_header(rbd_dev, NULL);
1909 mutex_unlock(&ctl_mutex);
1910 1917
1911 return ret < 0 ? ret : size; 1918 return ret < 0 ? ret : size;
1912} 1919}
@@ -2196,9 +2203,7 @@ static int rbd_init_watch_dev(struct rbd_device *rbd_dev)
2196 do { 2203 do {
2197 ret = rbd_req_sync_watch(rbd_dev); 2204 ret = rbd_req_sync_watch(rbd_dev);
2198 if (ret == -ERANGE) { 2205 if (ret == -ERANGE) {
2199 mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); 2206 rc = rbd_refresh_header(rbd_dev, NULL);
2200 rc = __rbd_refresh_header(rbd_dev, NULL);
2201 mutex_unlock(&ctl_mutex);
2202 if (rc < 0) 2207 if (rc < 0)
2203 return rc; 2208 return rc;
2204 } 2209 }