aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorGuanjun He <gjhe@suse.com>2012-07-08 22:50:33 -0400
committerSage Weil <sage@inktank.com>2012-07-30 12:29:53 -0400
commita2a3258417eb6a1799cf893350771428875a8287 (patch)
treef8906aa980d79af72e7e02d5592512a914c4b721 /net/ceph
parenta16cb1f70799c851410d9dca0a24122e258df06c (diff)
libceph: prevent the race of incoming work during teardown
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> Reviewed-by: Sage Weil <sage@inktank.com>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/ceph_common.c2
-rw-r--r--net/ceph/messenger.c5
2 files changed, 7 insertions, 0 deletions
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c
index 58b09efb528d..3b45e01fa8d1 100644
--- a/net/ceph/ceph_common.c
+++ b/net/ceph/ceph_common.c
@@ -495,6 +495,8 @@ void ceph_destroy_client(struct ceph_client *client)
495{ 495{
496 dout("destroy_client %p\n", client); 496 dout("destroy_client %p\n", client);
497 497
498 atomic_set(&client->msgr.stopping, 1);
499
498 /* unmount */ 500 /* unmount */
499 ceph_osdc_stop(&client->osdc); 501 ceph_osdc_stop(&client->osdc);
500 502
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 16814d1f4774..63e1252d3af5 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -254,6 +254,9 @@ static void con_sock_state_closed(struct ceph_connection *con)
254static void ceph_sock_data_ready(struct sock *sk, int count_unused) 254static void ceph_sock_data_ready(struct sock *sk, int count_unused)
255{ 255{
256 struct ceph_connection *con = sk->sk_user_data; 256 struct ceph_connection *con = sk->sk_user_data;
257 if (atomic_read(&con->msgr->stopping)) {
258 return;
259 }
257 260
258 if (sk->sk_state != TCP_CLOSE_WAIT) { 261 if (sk->sk_state != TCP_CLOSE_WAIT) {
259 dout("%s on %p state = %lu, queueing work\n", __func__, 262 dout("%s on %p state = %lu, queueing work\n", __func__,
@@ -2413,6 +2416,8 @@ void ceph_messenger_init(struct ceph_messenger *msgr,
2413 encode_my_addr(msgr); 2416 encode_my_addr(msgr);
2414 msgr->nocrc = nocrc; 2417 msgr->nocrc = nocrc;
2415 2418
2419 atomic_set(&msgr->stopping, 0);
2420
2416 dout("%s %p\n", __func__, msgr); 2421 dout("%s %p\n", __func__, msgr);
2417} 2422}
2418EXPORT_SYMBOL(ceph_messenger_init); 2423EXPORT_SYMBOL(ceph_messenger_init);