CEPH filesystem development
 help / color / mirror / Atom feed
From: Guanjun He <heguanbo@gmail.com>
To: ceph-devel@vger.kernel.org
Cc: Guanjun He <heguanbo@gmail.com>
Subject: [PATCH] fix ceph client crash when try to remove a rbd device
Date: Fri,  8 Jun 2012 15:56:56 +0800	[thread overview]
Message-ID: <1339142216-26426-1-git-send-email-heguanbo@gmail.com> (raw)

	Create a rbd image and map it to client,then stop ceph cluster through 
'/etc/init.d/ceph -a stop', then in client side, run command 'echo id > /sys/bus/rbd/remove',
and this command can not return. Checking dmesg, seems like it enters an endless loop, 
try to re-connect osds and mons.Then press keys 'CTRL + C' to send an INT signal to 
'echo id > /sys/bus/rbd/remove',then kernel crash.

	Kernel crash because ceph_osd's o_requests list is not empty.
	This fix is to clean ceph_osd's o_requests list when it's forced to remove a rbd device(triggered
by /sys/bus/rbs/remove).

Signed-off-by: Guanjun He <heguanbo@gmail.com>
---
 net/ceph/osd_client.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 1ffebed..4dba062 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -688,11 +688,20 @@ static void __remove_osd(struct ceph_osd_client *osdc, struct ceph_osd *osd)
 
 static void remove_all_osds(struct ceph_osd_client *osdc)
 {
+	struct list_head *pos, *q;
+	struct ceph_osd_request *req;
+
 	dout("__remove_old_osds %p\n", osdc);
 	mutex_lock(&osdc->request_mutex);
 	while (!RB_EMPTY_ROOT(&osdc->osds)) {
 		struct ceph_osd *osd = rb_entry(rb_first(&osdc->osds),
 						struct ceph_osd, o_node);
+		list_for_each_safe(pos, q, &osd->o_requests) {
+			req = list_entry(pos, struct ceph_osd_request,
+							r_osd_item);
+			list_del(pos);
+			kfree(req);
+		}
 		__remove_osd(osdc, osd);
 	}
 	mutex_unlock(&osdc->request_mutex);
-- 
1.7.3.4


                 reply	other threads:[~2012-06-08  7:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1339142216-26426-1-git-send-email-heguanbo@gmail.com \
    --to=heguanbo@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox