All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 5/5] rbd: set up watch in rbd_dev_probe_image()
Date: Sat, 27 Apr 2013 14:40:10 -0500	[thread overview]
Message-ID: <517C299A.6030109@inktank.com> (raw)
In-Reply-To: <517C2914.8030400@inktank.com>

Move setting up the watch request for an image so it's done in
rbd_dev_probe_image() rather than rbd_dev_probe_finish().  Move
it all the way up to before doing the initial probe.  This avoids
a potential race condition, in which we get (and use) the initial
snapshot context for an image, and it gets changed between that
time and the time we get the watch set up.

This resolves:
    http://tracker.ceph.com/issues/3871

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 1832b6a..5fcf23f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4705,10 +4705,6 @@ static int rbd_dev_probe_finish(struct rbd_device
*rbd_dev)
 {
 	int ret;

-	ret = rbd_dev_header_watch_sync(rbd_dev, 1);
-	if (ret)
-		return ret;
-
 	/* generate unique id: find highest unique id, add one */
 	rbd_dev_id_get(rbd_dev);

@@ -4767,7 +4763,6 @@ err_out_id:
 	rbd_dev_id_put(rbd_dev);
 	if (rbd_dev->parent);
 		rbd_dev_remove_parent(rbd_dev);
-	(void)rbd_dev_header_watch_sync(rbd_dev, 0);

 	return ret;
 }
@@ -4824,12 +4819,16 @@ static int rbd_dev_probe_image(struct rbd_device
*rbd_dev)
 	if (ret)
 		goto out_err;

+	ret = rbd_dev_header_watch_sync(rbd_dev, 1);
+	if (ret)
+		goto out_header_name;
+
 	if (rbd_dev->image_format == 1)
 		ret = rbd_dev_v1_probe(rbd_dev);
 	else
 		ret = rbd_dev_v2_probe(rbd_dev);
 	if (ret)
-		goto out_header_name;
+		goto err_out_watch;

 	ret = rbd_dev_snaps_update(rbd_dev);
 	if (ret)
@@ -4841,7 +4840,7 @@ static int rbd_dev_probe_image(struct rbd_device
*rbd_dev)

 	ret = rbd_dev_probe_parent(rbd_dev);
 	if (ret)
-		goto err_out_snaps;
+		goto err_out_watch;

 	ret = rbd_dev_probe_finish(rbd_dev);
 	if (ret)
@@ -4857,6 +4856,8 @@ err_out_snaps:
 out_header_name:
 	kfree(rbd_dev->header_name);
 	rbd_dev->header_name = NULL;
+err_out_watch:
+	(void)rbd_dev_header_watch_sync(rbd_dev, 0);
 out_err:
 	kfree(rbd_dev->spec->image_id);
 	rbd_dev->spec->image_id = NULL;
-- 
1.7.9.5


  parent reply	other threads:[~2013-04-27 19:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 19:37 [PATCH 0/5] rbd: avoid snapshot update race Alex Elder
2013-04-27 19:39 ` [PATCH 1/5] rbd: move more initialization into rbd_dev_probe_image() Alex Elder
2013-04-27 19:39 ` [PATCH 2/5] rbd: define rbd_header_name() Alex Elder
2013-04-27 19:39 ` [PATCH 3/5] rbd: don't clean up watch in device release function Alex Elder
2013-04-27 19:39 ` [PATCH 4/5] rbd: don't bother checking whether order changes Alex Elder
2013-04-27 19:40 ` Alex Elder [this message]
2013-04-27 19:42 ` [PATCH 0/5] rbd: avoid snapshot update race Alex Elder
2013-04-29 17:52   ` Alex Elder
2013-04-30 19:13     ` Josh Durgin

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=517C299A.6030109@inktank.com \
    --to=elder@inktank.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.