All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 2/4] rbd: move ctl_mutex lock inside rbd_get_client()
Date: Tue, 28 Feb 2012 19:45:41 -0800	[thread overview]
Message-ID: <4F4D9F65.80605@dreamhost.com> (raw)
In-Reply-To: <4F4D9F0E.4080804@dreamhost.com>

Since rbd_get_client() is only called in one place, move the
acquisition of the mutex around that call inside that function.

Furthermore, within rbd_get_client(), it appears the mutex only
needs to be held while calling rbd_client_create().  (Moving
the lock inside that function will wait for the next patch.)

Signed-off-by: Alex Elder <elder@dreamhost.com>
---
  drivers/block/rbd.c |    6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4bf8300..99d5920 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -396,7 +396,10 @@ static int rbd_get_client(struct rbd_device 
*rbd_dev, const char *mon_addr,
  	}
  	spin_unlock(&node_lock);

+	mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
  	rbdc = rbd_client_create(opt, rbd_opts);
+	mutex_unlock(&ctl_mutex);
+
  	if (IS_ERR(rbdc)) {
  		ret = PTR_ERR(rbdc);
  		goto done_err;
@@ -2273,10 +2276,7 @@ static ssize_t rbd_add(struct bus_type *bus,
  	/* initialize rest of new object */
  	snprintf(rbd_dev->name, DEV_NAME_LEN, DRV_NAME "%d", rbd_dev->id);

-	mutex_lock_nested(&ctl_mutex, SINGLE_DEPTH_NESTING);
  	rc = rbd_get_client(rbd_dev, mon_dev_name, options);
-	mutex_unlock(&ctl_mutex);
-
  	if (rc < 0)
  		goto err_out_slot;

-- 
1.7.5.4


  parent reply	other threads:[~2012-02-29  3:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29  3:44 [PATCH 0/4] rbd: client list locking improvements Alex Elder
2012-02-29  3:45 ` [PATCH 1/4] rbd: release client list lock sooner Alex Elder
2012-02-29  3:45 ` Alex Elder [this message]
2012-02-29  3:45 ` [PATCH 3/4] rbd: move ctl_mutex lock inside rbd_client_create() Alex Elder
2012-02-29  3:45 ` [PATCH 4/4] rbd: rename "node_lock" Alex Elder
2012-03-02 19:56 ` [PATCH 0/4] rbd: client list locking improvements Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F4D9F65.80605@dreamhost.com \
    --to=elder@dreamhost.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.