All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 3/5] rbd: define rbd_dev_unparent()
Date: Sat, 11 May 2013 12:44:12 -0500	[thread overview]
Message-ID: <518E836C.9010404@inktank.com> (raw)
In-Reply-To: <518E831E.6000206@inktank.com>

Define rbd_dev_unparent() to encapsulate cleaning up parent data
structures from a layered rbd image.

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

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index ac3f4e7..607c536 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1835,6 +1835,17 @@ static void rbd_obj_request_destroy(struct kref
*kref)
 	kmem_cache_free(rbd_obj_request_cache, obj_request);
 }

+/* It's OK to call this for a device with no parent */
+
+static void rbd_spec_put(struct rbd_spec *spec);
+static void rbd_dev_unparent(struct rbd_device *rbd_dev)
+{
+	rbd_dev_remove_parent(rbd_dev);
+	rbd_spec_put(rbd_dev->parent_spec);
+	rbd_dev->parent_spec = NULL;
+	rbd_dev->parent_overlap = 0;
+}
+
 /*
  * Caller is responsible for filling in the list of object requests
  * that comprises the image request, and the Linux request pointer
@@ -4062,9 +4073,7 @@ out_err:
 	rbd_dev->mapping.size = 0;
 	rbd_dev->header.image_size = 0;
 	rbd_dev->header.obj_order = 0;
-	rbd_dev->parent_overlap = 0;
-	rbd_spec_put(rbd_dev->parent_spec);
-	rbd_dev->parent_spec = NULL;
+	rbd_dev_unparent(rbd_dev);
 	rbd_dev->header.stripe_count = 0;
 	rbd_dev->header.stripe_unit = 0;
 	rbd_dev->header.features = 0;
@@ -4492,10 +4501,7 @@ static void rbd_dev_unprobe(struct rbd_device
*rbd_dev)
 {
 	struct rbd_image_header	*header;

-	rbd_dev_remove_parent(rbd_dev);
-	rbd_spec_put(rbd_dev->parent_spec);
-	rbd_dev->parent_spec = NULL;
-	rbd_dev->parent_overlap = 0;
+	rbd_dev_unparent(rbd_dev);

 	/* Free dynamic fields from the header, then zero it out */

@@ -4571,7 +4577,7 @@ static int rbd_dev_probe_parent(struct rbd_device
*rbd_dev)
 	return 0;
 out_err:
 	if (parent) {
-		rbd_spec_put(rbd_dev->parent_spec);
+		rbd_dev_unparent(rbd_dev);
 		kfree(rbd_dev->header_name);
 		rbd_dev_destroy(parent);
 	} else {
-- 
1.7.9.5


  parent reply	other threads:[~2013-05-11 17:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-11 17:42 [PATCH 0/5] rbd: prep work for flattening images Alex Elder
2013-05-11 17:43 ` [PATCH 1/5] rbd: get parent info on refresh Alex Elder
2013-05-11 20:59   ` Josh Durgin
2013-05-11 21:52     ` Alex Elder
2013-05-13 17:58     ` [PATCH 1/5, v2] " Alex Elder
2013-05-13 19:34       ` Josh Durgin
2013-05-11 17:44 ` [PATCH 2/5] rbd: don't release write request until necessary Alex Elder
2013-05-11 17:44 ` Alex Elder [this message]
2013-05-11 17:44 ` [PATCH 4/5] rbd: define parent image request routines Alex Elder
2013-05-11 17:44 ` [PATCH 5/5] rbd: reference count parent requests Alex Elder
2013-05-11 21:08 ` [PATCH 0/5] rbd: prep work for flattening images 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=518E836C.9010404@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.