ceph: handle errors during osd client init
Unwind initializing if we get ENOMEM during client initialization. Signed-off-by: Sage Weil <sage@newdream.net>
This commit is contained in:
@@ -2552,7 +2552,7 @@ static void delayed_work(struct work_struct *work)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client)
|
int ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client)
|
||||||
{
|
{
|
||||||
mdsc->client = client;
|
mdsc->client = client;
|
||||||
mutex_init(&mdsc->mutex);
|
mutex_init(&mdsc->mutex);
|
||||||
@@ -2582,6 +2582,7 @@ void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client)
|
|||||||
init_waitqueue_head(&mdsc->cap_flushing_wq);
|
init_waitqueue_head(&mdsc->cap_flushing_wq);
|
||||||
spin_lock_init(&mdsc->dentry_lru_lock);
|
spin_lock_init(&mdsc->dentry_lru_lock);
|
||||||
INIT_LIST_HEAD(&mdsc->dentry_lru);
|
INIT_LIST_HEAD(&mdsc->dentry_lru);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -282,7 +282,7 @@ extern void ceph_put_mds_session(struct ceph_mds_session *s);
|
|||||||
extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
|
extern int ceph_send_msg_mds(struct ceph_mds_client *mdsc,
|
||||||
struct ceph_msg *msg, int mds);
|
struct ceph_msg *msg, int mds);
|
||||||
|
|
||||||
extern void ceph_mdsc_init(struct ceph_mds_client *mdsc,
|
extern int ceph_mdsc_init(struct ceph_mds_client *mdsc,
|
||||||
struct ceph_client *client);
|
struct ceph_client *client);
|
||||||
extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc);
|
extern void ceph_mdsc_close_sessions(struct ceph_mds_client *mdsc);
|
||||||
extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc);
|
extern void ceph_mdsc_stop(struct ceph_mds_client *mdsc);
|
||||||
|
@@ -1127,19 +1127,26 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
|
|||||||
osdc->num_requests = 0;
|
osdc->num_requests = 0;
|
||||||
INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout);
|
INIT_DELAYED_WORK(&osdc->timeout_work, handle_timeout);
|
||||||
|
|
||||||
|
err = -ENOMEM;
|
||||||
osdc->req_mempool = mempool_create_kmalloc_pool(10,
|
osdc->req_mempool = mempool_create_kmalloc_pool(10,
|
||||||
sizeof(struct ceph_osd_request));
|
sizeof(struct ceph_osd_request));
|
||||||
if (!osdc->req_mempool)
|
if (!osdc->req_mempool)
|
||||||
return -ENOMEM;
|
goto out;
|
||||||
|
|
||||||
err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true);
|
err = ceph_msgpool_init(&osdc->msgpool_op, 4096, 10, true);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -ENOMEM;
|
goto out_mempool;
|
||||||
err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false);
|
err = ceph_msgpool_init(&osdc->msgpool_op_reply, 512, 0, false);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return -ENOMEM;
|
goto out_msgpool;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
out_msgpool:
|
||||||
|
ceph_msgpool_destroy(&osdc->msgpool_op);
|
||||||
|
out_mempool:
|
||||||
|
mempool_destroy(osdc->req_mempool);
|
||||||
|
out:
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ceph_osdc_stop(struct ceph_osd_client *osdc)
|
void ceph_osdc_stop(struct ceph_osd_client *osdc)
|
||||||
|
@@ -530,9 +530,13 @@ static struct ceph_client *ceph_create_client(struct ceph_mount_args *args)
|
|||||||
err = ceph_osdc_init(&client->osdc, client);
|
err = ceph_osdc_init(&client->osdc, client);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto fail_monc;
|
goto fail_monc;
|
||||||
ceph_mdsc_init(&client->mdsc, client);
|
err = ceph_mdsc_init(&client->mdsc, client);
|
||||||
|
if (err < 0)
|
||||||
|
goto fail_osdc;
|
||||||
return client;
|
return client;
|
||||||
|
|
||||||
|
fail_osdc:
|
||||||
|
ceph_osdc_stop(&client->osdc);
|
||||||
fail_monc:
|
fail_monc:
|
||||||
ceph_monc_stop(&client->monc);
|
ceph_monc_stop(&client->monc);
|
||||||
fail_trunc_wq:
|
fail_trunc_wq:
|
||||||
|
Reference in New Issue
Block a user