All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guanjun He <heguanbo@gmail.com>
To: sage@inktank.com, ceph-devel@vger.kernel.org
Cc: Guanjun He <gjhe@suse.com>
Subject: Re: [PATCH 1/1] client: prevent the race of incoming work during teardown
Date: Mon,  2 Jul 2012 11:31:41 +0800	[thread overview]
Message-ID: <1341199901-16730-1-git-send-email-gjhe@suse.com> (raw)
In-Reply-To: <Re: [PATCH 1/1] client: prevent the race of incoming work during teardown>

	Reproduce the patch against the latest source repo.

	Add an atomic variable 'stopping' as flag in struct ceph_messenger,
 set this flag to 1 in function ceph_destroy_client(), and add the condition code
 in function ceph_data_ready() to test the flag value, if true(1), just return.

Signed-off-by: Guanjun He <gjhe@suse.com>
---
 include/linux/ceph/messenger.h |    1 +
 net/ceph/ceph_common.c         |    2 ++
 net/ceph/messenger.c           |    5 +++++
 3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h
index 2521a95..2586f34 100644
--- a/include/linux/ceph/messenger.h
+++ b/include/linux/ceph/messenger.h
@@ -53,6 +53,7 @@ struct ceph_messenger {
 	struct ceph_entity_inst inst;    /* my name+address */
 	struct ceph_entity_addr my_enc_addr;
 
+	atomic_t stopping;
 	bool nocrc;
 
 	/*
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index ba4323b..478f3a4 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -501,6 +501,8 @@ void ceph_destroy_client(struct ceph_client *client)
 {
 	dout("destroy_client %p\n", client);
 
+	atomic_set(&client->msgr->stopping, 1);
+
 	/* unmount */
 	ceph_osdc_stop(&client->osdc);
 
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index b332c3d..11ea62e 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -156,6 +156,9 @@ EXPORT_SYMBOL(ceph_msgr_flush);
 static void ceph_data_ready(struct sock *sk, int count_unused)
 {
 	struct ceph_connection *con = sk->sk_user_data;
+	if (atomic_read(&con->msgr->stopping)) {
+		return;
+	}
 
 	if (sk->sk_state != TCP_CLOSE_WAIT) {
 		dout("ceph_data_ready on %p state = %lu, queueing work\n",
@@ -2285,6 +2288,8 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr,
 	get_random_bytes(&msgr->inst.addr.nonce, sizeof(msgr->inst.addr.nonce));
 	encode_my_addr(msgr);
 
+	atomic_set(&msgr->stopping, 0);
+
 	dout("messenger_create %p\n", msgr);
 	return msgr;
 }
-- 
1.7.3.4


       reply	other threads:[~2012-07-02  3:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Re: [PATCH 1/1] client: prevent the race of incoming work during teardown>
2012-07-02  3:31 ` Guanjun He [this message]
2012-07-09  3:42   ` [PATCH 1/1] client: prevent the race of incoming work during teardown Guan Jun He
2012-07-11  2:21     ` Sage Weil
2012-06-21  8:20 Guanjun He
2012-06-25  5:56 ` Guan Jun He
2012-06-29  4:24 ` Sage Weil
2012-07-02  3:13   ` Guan Jun He

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=1341199901-16730-1-git-send-email-gjhe@suse.com \
    --to=heguanbo@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=gjhe@suse.com \
    --cc=sage@inktank.com \
    /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.