提交 bc534d86 编写于 作者: A Alex Elder

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: NAlex Elder <elder@dreamhost.com>
Signed-off-by: NSage Weil <sage@newdream.net>
上级 d97081b0
...@@ -257,9 +257,11 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt, ...@@ -257,9 +257,11 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt,
kref_init(&rbdc->kref); kref_init(&rbdc->kref);
INIT_LIST_HEAD(&rbdc->node); INIT_LIST_HEAD(&rbdc->node);
mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
rbdc->client = ceph_create_client(opt, rbdc, 0, 0); rbdc->client = ceph_create_client(opt, rbdc, 0, 0);
if (IS_ERR(rbdc->client)) if (IS_ERR(rbdc->client))
goto out_rbdc; goto out_mutex;
opt = NULL; /* Now rbdc->client is responsible for opt */ opt = NULL; /* Now rbdc->client is responsible for opt */
ret = ceph_open_session(rbdc->client); ret = ceph_open_session(rbdc->client);
...@@ -272,12 +274,15 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt, ...@@ -272,12 +274,15 @@ static struct rbd_client *rbd_client_create(struct ceph_options *opt,
list_add_tail(&rbdc->node, &rbd_client_list); list_add_tail(&rbdc->node, &rbd_client_list);
spin_unlock(&node_lock); spin_unlock(&node_lock);
mutex_unlock(&ctl_mutex);
dout("rbd_client_create created %p\n", rbdc); dout("rbd_client_create created %p\n", rbdc);
return rbdc; return rbdc;
out_err: out_err:
ceph_destroy_client(rbdc->client); ceph_destroy_client(rbdc->client);
out_rbdc: out_mutex:
mutex_unlock(&ctl_mutex);
kfree(rbdc); kfree(rbdc);
out_opt: out_opt:
if (opt) if (opt)
...@@ -396,9 +401,7 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr, ...@@ -396,9 +401,7 @@ static int rbd_get_client(struct rbd_device *rbd_dev, const char *mon_addr,
} }
spin_unlock(&node_lock); spin_unlock(&node_lock);
mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
rbdc = rbd_client_create(opt, rbd_opts); rbdc = rbd_client_create(opt, rbd_opts);
mutex_unlock(&ctl_mutex);
if (IS_ERR(rbdc)) { if (IS_ERR(rbdc)) {
ret = PTR_ERR(rbdc); ret = PTR_ERR(rbdc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册