diff options
author | Alex Elder <elder@dreamhost.com> | 2012-01-29 14:57:44 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:47 -0400 |
commit | bc534d86be71aaf8dfac46131420ab1c47387d42 (patch) | |
tree | 196d43864c2c1033b30d4ae03cb946793cf29b19 /drivers/block/rbd.c | |
parent | d97081b0c7bdb55371994cc6690217bf393eb63e (diff) |
rbd: move ctl_mutex lock inside rbd_client_create()
Since rbd_client_create() is only called in one place, move the
acquisition of the mutex around that call inside that function.
Signed-off-by: Alex Elder <elder@dreamhost.com>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 7f60ff28ac29..38174bffa049 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -257,9 +257,11 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt, | |||
257 | kref_init(&rbdc->kref); | 257 | kref_init(&rbdc->kref); |
258 | INIT_LIST_HEAD(&rbdc->node); | 258 | INIT_LIST_HEAD(&rbdc->node); |
259 | 259 | ||
260 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
261 | |||
260 | rbdc->client = ceph_create_client(opt, rbdc, 0, 0); | 262 | rbdc->client = ceph_create_client(opt, rbdc, 0, 0); |
261 | if (IS_ERR(rbdc->client)) | 263 | if (IS_ERR(rbdc->client)) |
262 | goto out_rbdc; | 264 | goto out_mutex; |
263 | opt = NULL; /* Now rbdc->client is responsible for opt */ | 265 | opt = NULL; /* Now rbdc->client is responsible for opt */ |
264 | 266 | ||
265 | ret = ceph_open_session(rbdc->client); | 267 | ret = ceph_open_session(rbdc->client); |
@@ -272,12 +274,15 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt, | |||
272 | list_add_tail(&rbdc->node, &rbd_client_list); | 274 | list_add_tail(&rbdc->node, &rbd_client_list); |
273 | spin_unlock(&node_lock); | 275 | spin_unlock(&node_lock); |
274 | 276 | ||
277 | mutex_unlock(&ctl_mutex); | ||
278 | |||
275 | dout("rbd_client_create created %p\n", rbdc); | 279 | dout("rbd_client_create created %p\n", rbdc); |
276 | return rbdc; | 280 | return rbdc; |
277 | 281 | ||
278 | out_err: | 282 | out_err: |
279 | ceph_destroy_client(rbdc->client); | 283 | ceph_destroy_client(rbdc->client); |
280 | out_rbdc: | 284 | out_mutex: |
285 | mutex_unlock(&ctl_mutex); | ||
281 | kfree(rbdc); | 286 | kfree(rbdc); |
282 | out_opt: | 287 | out_opt: |
283 | if (opt) | 288 | if (opt) |
@@ -396,9 +401,7 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr, | |||
396 | } | 401 | } |
397 | spin_unlock(&node_lock); | 402 | spin_unlock(&node_lock); |
398 | 403 | ||
399 | mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING); | ||
400 | rbdc = rbd_client_create(opt, rbd_opts); | 404 | rbdc = rbd_client_create(opt, rbd_opts); |
401 | mutex_unlock(&ctl_mutex); | ||
402 | 405 | ||
403 | if (IS_ERR(rbdc)) { | 406 | if (IS_ERR(rbdc)) { |
404 | ret = PTR_ERR(rbdc); | 407 | ret = PTR_ERR(rbdc); |