diff options
author | Alex Elder <elder@dreamhost.com> | 2012-02-14 15:05:33 -0500 |
---|---|---|
committer | Alex Elder <elder@dreamhost.com> | 2012-03-22 11:47:50 -0400 |
commit | 6173d1f02fb19c0fba02857ae4e1109b5ec95034 (patch) | |
tree | c837bfe920220d138ba99d8fac2ac781bb2a44ac /net/ceph | |
parent | e0f43c9419c1900e5b50de4261e9686a45a0a2b8 (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.c | 38 |
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 | */ |
100 | static struct workqueue_struct *ceph_msgr_wq; | 100 | static struct workqueue_struct *ceph_msgr_wq; |
101 | 101 | ||
102 | void _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 | |||
102 | int ceph_msgr_init(void) | 116 | int 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 | } |
125 | EXPORT_SYMBOL(ceph_msgr_init); | 134 | EXPORT_SYMBOL(ceph_msgr_init); |
126 | 135 | ||
127 | void ceph_msgr_exit(void) | 136 | void 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 | } |
140 | EXPORT_SYMBOL(ceph_msgr_exit); | 142 | EXPORT_SYMBOL(ceph_msgr_exit); |
141 | 143 | ||