diff options
author | Sage Weil <sage@newdream.net> | 2009-11-18 17:52:18 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-11-18 18:02:36 -0500 |
commit | 5f44f142601bf94c448e2d463f0f18fd159da164 (patch) | |
tree | 773b4677c536519435f073b27873212f705c9c3c /fs/ceph | |
parent | 71ececdacae24be333c534869cb1b06357f0e215 (diff) |
ceph: handle errors during osd client init
Unwind initializing if we get ENOMEM during client initialization.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph')
-rw-r--r-- | fs/ceph/mds_client.c | 3 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 2 | ||||
-rw-r--r-- | fs/ceph/osd_client.c | 15 | ||||
-rw-r--r-- | fs/ceph/super.c | 6 |
4 files changed, 19 insertions, 7 deletions
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index fdecf9984180..69feeb1c9819 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -2552,7 +2552,7 @@ static void delayed_work(struct work_struct *work) | |||
2552 | } | 2552 | } |
2553 | 2553 | ||
2554 | 2554 | ||
2555 | void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client) | 2555 | int ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client) |
2556 | { | 2556 | { |
2557 | mdsc->client = client; | 2557 | mdsc->client = client; |
2558 | mutex_init(&mdsc->mutex); | 2558 | mutex_init(&mdsc->mutex); |
@@ -2582,6 +2582,7 @@ void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client) | |||
2582 | init_waitqueue_head(&mdsc->cap_flushing_wq); | 2582 | init_waitqueue_head(&mdsc->cap_flushing_wq); |
2583 | spin_lock_init(&mdsc->dentry_lru_lock); | 2583 | spin_lock_init(&mdsc->dentry_lru_lock); |
2584 | INIT_LIST_HEAD(&mdsc->dentry_lru); | 2584 | INIT_LIST_HEAD(&mdsc->dentry_lru); |
2585 | return 0; | ||
2585 | } | 2586 | } |
2586 | 2587 | ||
2587 | /* | 2588 | /* |
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 0751b821f231..7c439488cfab 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -282,7 +282,7 @@ extern void ceph_put_mds_session(struct ceph_mds_session *s); | |||
282 | extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc, | 282 | extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc, |
283 | struct ceph_msg *msg, int mds); | 283 | struct ceph_msg *msg, int mds); |
284 | 284 | ||
285 | extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, | 285 | extern int ceph_mdsc_init(struct ceph_mds_client *mdsc, |
286 | struct ceph_client *client); | 286 | struct ceph_client *client); |
287 | extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc); | 287 | extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc); |
288 | extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc); | 288 | extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc); |
diff --git a/fs/ceph/osd_client.c b/fs/ceph/osd_client.c index bcb9fe693076..0a16c4f951f9 100644 --- a/fs/ceph/osd_client.c +++ b/fs/ceph/osd_client.c | |||
@@ -1127,19 +1127,26 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client) | |||
1127 | osdc->num_requests = 0; | 1127 | osdc->num_requests = 0; |
1128 | INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout); | 1128 | INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout); |
1129 | 1129 | ||
1130 | err = -ENOMEM; | ||
1130 | osdc->req_mempool = mempool_create_kmalloc_pool(10, | 1131 | osdc->req_mempool = mempool_create_kmalloc_pool(10, |
1131 | sizeof(struct ceph_osd_request)); | 1132 | sizeof(struct ceph_osd_request)); |
1132 | if (!osdc->req_mempool) | 1133 | if (!osdc->req_mempool) |
1133 | return -ENOMEM; | 1134 | goto out; |
1134 | 1135 | ||
1135 | err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true); | 1136 | err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true); |
1136 | if (err < 0) | 1137 | if (err < 0) |
1137 | return -ENOMEM; | 1138 | goto out_mempool; |
1138 | err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false); | 1139 | err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false); |
1139 | if (err < 0) | 1140 | if (err < 0) |
1140 | return -ENOMEM; | 1141 | goto out_msgpool; |
1141 | |||
1142 | return 0; | 1142 | return 0; |
1143 | |||
1144 | out_msgpool: | ||
1145 | ceph_msgpool_destroy(&osdc->msgpool_op); | ||
1146 | out_mempool: | ||
1147 | mempool_destroy(osdc->req_mempool); | ||
1148 | out: | ||
1149 | return err; | ||
1143 | } | 1150 | } |
1144 | 1151 | ||
1145 | void ceph_osdc_stop(struct ceph_osd_client *osdc) | 1152 | void ceph_osdc_stop(struct ceph_osd_client *osdc) |
diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 1ac7b07214f3..fe0a5962a082 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c | |||
@@ -530,9 +530,13 @@ static struct ceph_client *ceph_create_client(struct ceph_mount_args *args) | |||
530 | err = ceph_osdc_init(&client->osdc, client); | 530 | err = ceph_osdc_init(&client->osdc, client); |
531 | if (err < 0) | 531 | if (err < 0) |
532 | goto fail_monc; | 532 | goto fail_monc; |
533 | ceph_mdsc_init(&client->mdsc, client); | 533 | err = ceph_mdsc_init(&client->mdsc, client); |
534 | if (err < 0) | ||
535 | goto fail_osdc; | ||
534 | return client; | 536 | return client; |
535 | 537 | ||
538 | fail_osdc: | ||
539 | ceph_osdc_stop(&client->osdc); | ||
536 | fail_monc: | 540 | fail_monc: |
537 | ceph_monc_stop(&client->monc); | 541 | ceph_monc_stop(&client->monc); |
538 | fail_trunc_wq: | 542 | fail_trunc_wq: |