libceph: Avoid holding the zero page on ceph_msgr_slab_init errors
authorBenoît Canet <benoit.canet@nodalink.com>
Thu, 25 Jun 2015 19:02:57 +0000 (21:02 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 8 Sep 2015 20:14:28 +0000 (23:14 +0300)
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>
net/ceph/messenger.c

index e3be1d22a2477dd2d9e271a4594d70ebdb1148e7..0f9ea60a897127d35d95b52955c7a612e3ed4f5b 100644 (file)
@@ -276,22 +276,22 @@ static void _ceph_msgr_exit(void)
                ceph_msgr_wq = NULL;
        }
 
-       ceph_msgr_slab_exit();
-
        BUG_ON(zero_page == NULL);
        page_cache_release(zero_page);
        zero_page = NULL;
+
+       ceph_msgr_slab_exit();
 }
 
 int ceph_msgr_init(void)
 {
+       if (ceph_msgr_slab_init())
+               return -ENOMEM;
+
        BUG_ON(zero_page != NULL);
        zero_page = ZERO_PAGE(0);
        page_cache_get(zero_page);
 
-       if (ceph_msgr_slab_init())
-               return -ENOMEM;
-
        /*
         * The number of active work items is limited by the number of
         * connections, so leave @max_active at default.