All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 4/6] rbd: fix rbd_dev_remove_parent()
Date: Sat, 27 Apr 2013 07:37:31 -0500	[thread overview]
Message-ID: <517BC68B.3040806@inktank.com> (raw)
In-Reply-To: <517BC608.5030008@inktank.com>

In certain error paths, it is possible for an rbd device to have a
parent spec but no parent rbd_dev.  In rbd_dev_remove_parent() use
the parent field rather than parent_spec in determining whether to
try to remove any parent devices.  Use assertions to indicate that
any non-null parent pointer has parent_spec associated with it.

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

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9936067..99d231b 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4984,7 +4984,7 @@ static void rbd_dev_release(struct device *dev)

 static void rbd_dev_remove_parent(struct rbd_device *rbd_dev)
 {
-	while (rbd_dev->parent_spec) {
+	while (rbd_dev->parent) {
 		struct rbd_device *first = rbd_dev;
 		struct rbd_device *second = first->parent;
 		struct rbd_device *third;
@@ -4997,12 +4997,15 @@ static void rbd_dev_remove_parent(struct
rbd_device *rbd_dev)
 			first = second;
 			second = third;
 		}
+		rbd_assert(second);
 		rbd_remove_all_snaps(second);
 		rbd_bus_del_dev(second);
+		first->parent = NULL;
+		first->parent_overlap = 0;
+
+		rbd_assert(first->parent_spec);
 		rbd_spec_put(first->parent_spec);
 		first->parent_spec = NULL;
-		first->parent_overlap = 0;
-		first->parent = NULL;
 	}
 }

-- 
1.7.9.5


  parent reply	other threads:[~2013-04-27 12:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-27 12:35 [PATCH 0/6] rbd: parent probe cleanup Alex Elder
2013-04-27 12:36 ` [PATCH 1/6] rbd: encapsulate probing for parent devices Alex Elder
2013-04-27 12:36 ` [PATCH 2/6] rbd: encapsulate removing " Alex Elder
2013-04-27 12:37 ` [PATCH 3/6] rbd: kill __rbd_remove() Alex Elder
2013-04-27 12:37 ` Alex Elder [this message]
2013-04-27 12:37 ` [PATCH 5/6] rbd: remove parent devices on probe error Alex Elder
2013-04-27 12:38 ` [PATCH 6/6] rbd: probe for the parent earlier Alex Elder
2013-04-30 18:45 ` [PATCH 0/6] rbd: parent probe cleanup 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=517BC68B.3040806@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.