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

rbd: don't hold spinlock during messenger flush

A recent change made changes to the rbd_client_list be protected by
a spinlock.  Unfortunately in rbd_put_client(), the lock is taken
before possibly dropping the last reference to an rbd_client, and on
the last reference that eventually calls flush_workqueue() which can
sleep.

The problem was flagged by a debug spinlock warning:
    BUG: spinlock wrong CPU on CPU#3, rbd/27814

The solution is to move the spinlock acquisition and release inside
rbd_client_release(), which is the spot where it's really needed for
protecting the removal of the rbd_client from the client list.
Signed-off-by: NAlex Elder <elder@dreamhost.com>
Reviewed-by: NSage Weil <sage@newdream.net>
上级 c666601a
...@@ -450,7 +450,9 @@ static void rbd_client_release(struct kref *kref) ...@@ -450,7 +450,9 @@ static void rbd_client_release(struct kref *kref)
struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref); struct rbd_client *rbdc = container_of(kref, struct rbd_client, kref);
dout("rbd_release_client %p\n", rbdc); dout("rbd_release_client %p\n", rbdc);
spin_lock(&rbd_client_list_lock);
list_del(&rbdc->node); list_del(&rbdc->node);
spin_unlock(&rbd_client_list_lock);
ceph_destroy_client(rbdc->client); ceph_destroy_client(rbdc->client);
kfree(rbdc->rbd_opts); kfree(rbdc->rbd_opts);
...@@ -463,9 +465,7 @@ static void rbd_client_release(struct kref *kref) ...@@ -463,9 +465,7 @@ static void rbd_client_release(struct kref *kref)
*/ */
static void rbd_put_client(struct rbd_device *rbd_dev) static void rbd_put_client(struct rbd_device *rbd_dev)
{ {
spin_lock(&rbd_client_list_lock);
kref_put(&rbd_dev->rbd_client->kref, rbd_client_release); kref_put(&rbd_dev->rbd_client->kref, rbd_client_release);
spin_unlock(&rbd_client_list_lock);
rbd_dev->rbd_client = NULL; rbd_dev->rbd_client = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册