diff options
-rw-r--r-- | fs/ceph/mds_client.c | 30 | ||||
-rw-r--r-- | fs/ceph/messenger.h | 1 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 4 |
3 files changed, 19 insertions, 16 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 44cac576f15e..fdecf9984180 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -274,10 +274,8 @@ void ceph_put_mds_session(struct ceph_mds_session *s) | |||
274 | { | 274 | { |
275 | dout("mdsc put_session %p %d -> %d\n", s, | 275 | dout("mdsc put_session %p %d -> %d\n", s, |
276 | atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); | 276 | atomic_read(&s->s_ref), atomic_read(&s->s_ref)-1); |
277 | if (atomic_dec_and_test(&s->s_ref)) { | 277 | if (atomic_dec_and_test(&s->s_ref)) |
278 | ceph_con_shutdown(&s->s_con); | ||
279 | kfree(s); | 278 | kfree(s); |
280 | } | ||
281 | } | 279 | } |
282 | 280 | ||
283 | /* | 281 | /* |
@@ -326,7 +324,6 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, | |||
326 | s->s_con.ops = &mds_con_ops; | 324 | s->s_con.ops = &mds_con_ops; |
327 | s->s_con.peer_name.type = CEPH_ENTITY_TYPE_MDS; | 325 | s->s_con.peer_name.type = CEPH_ENTITY_TYPE_MDS; |
328 | s->s_con.peer_name.num = cpu_to_le64(mds); | 326 | s->s_con.peer_name.num = cpu_to_le64(mds); |
329 | ceph_con_open(&s->s_con, ceph_mdsmap_get_addr(mdsc->mdsmap, mds)); | ||
330 | 327 | ||
331 | spin_lock_init(&s->s_cap_lock); | 328 | spin_lock_init(&s->s_cap_lock); |
332 | s->s_cap_gen = 0; | 329 | s->s_cap_gen = 0; |
@@ -352,7 +349,7 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, | |||
352 | dout("register_session realloc to %d\n", newmax); | 349 | dout("register_session realloc to %d\n", newmax); |
353 | sa = kcalloc(newmax, sizeof(void *), GFP_NOFS); | 350 | sa = kcalloc(newmax, sizeof(void *), GFP_NOFS); |
354 | if (sa == NULL) | 351 | if (sa == NULL) |
355 | return ERR_PTR(-ENOMEM); | 352 | goto fail_realloc; |
356 | if (mdsc->sessions) { | 353 | if (mdsc->sessions) { |
357 | memcpy(sa, mdsc->sessions, | 354 | memcpy(sa, mdsc->sessions, |
358 | mdsc->max_sessions * sizeof(void *)); | 355 | mdsc->max_sessions * sizeof(void *)); |
@@ -363,17 +360,26 @@ static struct ceph_mds_session *register_session(struct ceph_mds_client *mdsc, | |||
363 | } | 360 | } |
364 | mdsc->sessions[mds] = s; | 361 | mdsc->sessions[mds] = s; |
365 | atomic_inc(&s->s_ref); /* one ref to sessions[], one to caller */ | 362 | atomic_inc(&s->s_ref); /* one ref to sessions[], one to caller */ |
363 | |||
364 | ceph_con_open(&s->s_con, ceph_mdsmap_get_addr(mdsc->mdsmap, mds)); | ||
365 | |||
366 | return s; | 366 | return s; |
367 | |||
368 | fail_realloc: | ||
369 | kfree(s); | ||
370 | return ERR_PTR(-ENOMEM); | ||
367 | } | 371 | } |
368 | 372 | ||
369 | /* | 373 | /* |
370 | * called under mdsc->mutex | 374 | * called under mdsc->mutex |
371 | */ | 375 | */ |
372 | static void unregister_session(struct ceph_mds_client *mdsc, int mds) | 376 | static void unregister_session(struct ceph_mds_client *mdsc, |
377 | struct ceph_mds_session *s) | ||
373 | { | 378 | { |
374 | dout("unregister_session mds%d %p\n", mds, mdsc->sessions[mds]); | 379 | dout("unregister_session mds%d %p\n", s->s_mds, s); |
375 | ceph_put_mds_session(mdsc->sessions[mds]); | 380 | mdsc->sessions[s->s_mds] = NULL; |
376 | mdsc->sessions[mds] = NULL; | 381 | ceph_con_close(&s->s_con); |
382 | ceph_put_mds_session(s); | ||
377 | } | 383 | } |
378 | 384 | ||
379 | /* | 385 | /* |
@@ -1870,7 +1876,7 @@ static void handle_session(struct ceph_mds_session *session, | |||
1870 | break; | 1876 | break; |
1871 | 1877 | ||
1872 | case CEPH_SESSION_CLOSE: | 1878 | case CEPH_SESSION_CLOSE: |
1873 | unregister_session(mdsc, mds); | 1879 | unregister_session(mdsc, session); |
1874 | remove_session_caps(session); | 1880 | remove_session_caps(session); |
1875 | wake = 1; /* for good measure */ | 1881 | wake = 1; /* for good measure */ |
1876 | complete(&mdsc->session_close_waiters); | 1882 | complete(&mdsc->session_close_waiters); |
@@ -2199,7 +2205,7 @@ static void check_new_map(struct ceph_mds_client *mdsc, | |||
2199 | /* the session never opened, just close it | 2205 | /* the session never opened, just close it |
2200 | * out now */ | 2206 | * out now */ |
2201 | __wake_requests(mdsc, &s->s_waiting); | 2207 | __wake_requests(mdsc, &s->s_waiting); |
2202 | unregister_session(mdsc, i); | 2208 | unregister_session(mdsc, s); |
2203 | } else { | 2209 | } else { |
2204 | /* just close it */ | 2210 | /* just close it */ |
2205 | mutex_unlock(&mdsc->mutex); | 2211 | mutex_unlock(&mdsc->mutex); |
@@ -2724,7 +2730,7 @@ void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc) | |||
2724 | for (i = 0; i < mdsc->max_sessions; i++) { | 2730 | for (i = 0; i < mdsc->max_sessions; i++) { |
2725 | if (mdsc->sessions[i]) { | 2731 | if (mdsc->sessions[i]) { |
2726 | session = get_session(mdsc->sessions[i]); | 2732 | session = get_session(mdsc->sessions[i]); |
2727 | unregister_session(mdsc, i); | 2733 | unregister_session(mdsc, session); |
2728 | mutex_unlock(&mdsc->mutex); | 2734 | mutex_unlock(&mdsc->mutex); |
2729 | mutex_lock(&session->s_mutex); | 2735 | mutex_lock(&session->s_mutex); |
2730 | remove_session_caps(session); | 2736 | remove_session_caps(session); |
diff --git a/fs/ceph/messenger.h b/fs/ceph/messenger.h index 80f7e1e94448..4bd85c36308e 100644 --- a/fs/ceph/messenger.h +++ b/fs/ceph/messenger.h | |||
@@ -212,7 +212,6 @@ extern void ceph_messenger_destroy(struct ceph_messenger *); | |||
212 | 212 | ||
213 | extern void ceph_con_init(struct ceph_messenger *msgr, | 213 | extern void ceph_con_init(struct ceph_messenger *msgr, |
214 | struct ceph_connection *con); | 214 | struct ceph_connection *con); |
215 | extern void ceph_con_shutdown(struct ceph_connection *con); | ||
216 | extern void ceph_con_open(struct ceph_connection *con, | 215 | extern void ceph_con_open(struct ceph_connection *con, |
217 | struct ceph_entity_addr *addr); | 216 | struct ceph_entity_addr *addr); |
218 | extern void ceph_con_close(struct ceph_connection *con); | 217 | extern void ceph_con_close(struct ceph_connection *con); |
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index 7db14ba6261c..bcb9fe693076 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -350,10 +350,8 @@ static void put_osd(struct ceph_osd *osd) | |||
350 | { | 350 | { |
351 | dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), | 351 | dout("put_osd %p %d -> %d\n", osd, atomic_read(&osd->o_ref), |
352 | atomic_read(&osd->o_ref) - 1); | 352 | atomic_read(&osd->o_ref) - 1); |
353 | if (atomic_dec_and_test(&osd->o_ref)) { | 353 | if (atomic_dec_and_test(&osd->o_ref)) |
354 | ceph_con_shutdown(&osd->o_con); | ||
355 | kfree(osd); | 354 | kfree(osd); |
356 | } | ||
357 | } | 355 | } |
358 | 356 | ||
359 | /* | 357 | /* |