summaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-02-14 14:05:33 -0600
committerAlex Elder <elder@dreamhost.com>2012-03-22 10:47:50 -0500
commit6173d1f02fb19c0fba02857ae4e1109b5ec95034 (patch)
treec837bfe920220d138ba99d8fac2ac781bb2a44ac /net/ceph
parente0f43c9419c1900e5b50de4261e9686a45a0a2b8 (diff)
downloadop-kernel-dev-6173d1f02fb19c0fba02857ae4e1109b5ec95034.zip
op-kernel-dev-6173d1f02fb19c0fba02857ae4e1109b5ec95034.tar.gz
libceph: encapsulate some messenger cleanup code
Define a helper function to perform various cleanup operations. Use it both in the exit routine and in the init routine in the event of an error. Signed-off-by: Alex Elder <elder@dreamhost.com> Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net/ceph')
-rw-r--r--net/ceph/messenger.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 31f59ac..c3023a6 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -99,6 +99,20 @@ static void encode_my_addr(struct ceph_messenger *msgr)
*/
static struct workqueue_struct *ceph_msgr_wq;
+void _ceph_msgr_exit(void)
+{
+ if (ceph_msgr_wq)
+ destroy_workqueue(ceph_msgr_wq);
+
+ BUG_ON(zero_page_address == NULL);
+ zero_page_address = NULL;
+
+ BUG_ON(zero_page == NULL);
+ kunmap(zero_page);
+ page_cache_release(zero_page);
+ zero_page = NULL;
+}
+
int ceph_msgr_init(void)
{
BUG_ON(zero_page != NULL);
@@ -109,33 +123,21 @@ int ceph_msgr_init(void)
zero_page_address = kmap(zero_page);
ceph_msgr_wq = alloc_workqueue("ceph-msgr", WQ_NON_REENTRANT, 0);
- if (!ceph_msgr_wq) {
- pr_err("msgr_init failed to create workqueue\n");
-
- zero_page_address = NULL;
- kunmap(zero_page);
- page_cache_release(zero_page);
- zero_page = NULL;
+ if (ceph_msgr_wq)
+ return 0;
- return -ENOMEM;
- }
+ pr_err("msgr_init failed to create workqueue\n");
+ _ceph_msgr_exit();
- return 0;
+ return -ENOMEM;
}
EXPORT_SYMBOL(ceph_msgr_init);
void ceph_msgr_exit(void)
{
BUG_ON(ceph_msgr_wq == NULL);
- destroy_workqueue(ceph_msgr_wq);
- BUG_ON(zero_page_address == NULL);
- zero_page_address = NULL;
-
- BUG_ON(zero_page == NULL);
- kunmap(zero_page);
- page_cache_release(zero_page);
- zero_page = NULL;
+ _ceph_msgr_exit();
}
EXPORT_SYMBOL(ceph_msgr_exit);
OpenPOWER on IntegriCloud