Skip to content

Commit d920ff6

Browse files
benoit-canetidryomov
authored andcommitted
libceph: Avoid holding the zero page on ceph_msgr_slab_init errors
ceph_msgr_slab_init may fail due to a temporary ENOMEM. Delay a bit the initialization of zero_page in ceph_msgr_init and reorder its cleanup in _ceph_msgr_exit so it's done in reverse order of setup. BUG_ON() will not suffer to be postponed in case it is triggered. Signed-off-by: Benoît Canet <benoit.canet@nodalink.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent b79b236 commit d920ff6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/ceph/messenger.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,22 +276,22 @@ static void _ceph_msgr_exit(void)
276276
ceph_msgr_wq = NULL;
277277
}
278278

279-
ceph_msgr_slab_exit();
280-
281279
BUG_ON(zero_page == NULL);
282280
page_cache_release(zero_page);
283281
zero_page = NULL;
282+
283+
ceph_msgr_slab_exit();
284284
}
285285

286286
int ceph_msgr_init(void)
287287
{
288+
if (ceph_msgr_slab_init())
289+
return -ENOMEM;
290+
288291
BUG_ON(zero_page != NULL);
289292
zero_page = ZERO_PAGE(0);
290293
page_cache_get(zero_page);
291294

292-
if (ceph_msgr_slab_init())
293-
return -ENOMEM;
294-
295295
/*
296296
* The number of active work items is limited by the number of
297297
* connections, so leave @max_active at default.

0 commit comments

Comments
 (0)