aboutsummaryrefslogtreecommitdiffstats
path: root/net/ceph
diff options
context:
space:
mode:
authorAlex Elder <elder@dreamhost.com>2012-02-14 15:05:33 -0500
committerAlex Elder <elder@dreamhost.com>2012-03-22 11:47:50 -0400
commit6173d1f02fb19c0fba02857ae4e1109b5ec95034 (patch)
treec837bfe920220d138ba99d8fac2ac781bb2a44ac /net/ceph
parente0f43c9419c1900e5b50de4261e9686a45a0a2b8 (diff)
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 31f59ac03d8a..c3023a600ad2 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -99,6 +99,20 @@ static void encode_my_addr(struct ceph_messenger *msgr)
99 */ 99 */
100static struct workqueue_struct *ceph_msgr_wq; 100static struct workqueue_struct *ceph_msgr_wq;
101 101
102void _ceph_msgr_exit(void)
103{
104 if (ceph_msgr_wq)
105 destroy_workqueue(ceph_msgr_wq);
106
107 BUG_ON(zero_page_address == NULL);
108 zero_page_address = NULL;
109
110 BUG_ON(zero_page == NULL);
111 kunmap(zero_page);
112 page_cache_release(zero_page);
113 zero_page = NULL;
114}
115
102int ceph_msgr_init(void) 116int ceph_msgr_init(void)
103{ 117{
104 BUG_ON(zero_page != NULL); 118 BUG_ON(zero_page != NULL);
@@ -109,33 +123,21 @@ int ceph_msgr_init(void)
109 zero_page_address = kmap(zero_page); 123 zero_page_address = kmap(zero_page);
110 124
111 ceph_msgr_wq = alloc_workqueue("ceph-msgr", WQ_NON_REENTRANT, 0); 125 ceph_msgr_wq = alloc_workqueue("ceph-msgr", WQ_NON_REENTRANT, 0);
112 if (!ceph_msgr_wq) { 126 if (ceph_msgr_wq)
113 pr_err("msgr_init failed to create workqueue\n"); 127 return 0;
114
115 zero_page_address = NULL;
116 kunmap(zero_page);
117 page_cache_release(zero_page);
118 zero_page = NULL;
119 128
120 return -ENOMEM; 129 pr_err("msgr_init failed to create workqueue\n");
121 } 130 _ceph_msgr_exit();
122 131
123 return 0; 132 return -ENOMEM;
124} 133}
125EXPORT_SYMBOL(ceph_msgr_init); 134EXPORT_SYMBOL(ceph_msgr_init);
126 135
127void ceph_msgr_exit(void) 136void ceph_msgr_exit(void)
128{ 137{
129 BUG_ON(ceph_msgr_wq == NULL); 138 BUG_ON(ceph_msgr_wq == NULL);
130 destroy_workqueue(ceph_msgr_wq);
131 139
132 BUG_ON(zero_page_address == NULL); 140 _ceph_msgr_exit();
133 zero_page_address = NULL;
134
135 BUG_ON(zero_page == NULL);
136 kunmap(zero_page);
137 page_cache_release(zero_page);
138 zero_page = NULL;
139} 141}
140EXPORT_SYMBOL(ceph_msgr_exit); 142EXPORT_SYMBOL(ceph_msgr_exit);
141 143