dm: tidy local_init
authorKiyoshi Ueda <k-ueda@ct.jp.nec.com>
Tue, 21 Oct 2008 16:45:08 +0000 (17:45 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Tue, 21 Oct 2008 16:45:08 +0000 (17:45 +0100)
This patch tidies local_init() in preparation for request-based dm.
No functional change.

Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
drivers/md/dm.c

index 6938bfe..d1d0cd0 100644 (file)
@@ -150,40 +150,40 @@ static struct kmem_cache *_tio_cache;
 
 static int __init local_init(void)
 {
-       int r;
+       int r = -ENOMEM;
 
        /* allocate a slab for the dm_ios */
        _io_cache = KMEM_CACHE(dm_io, 0);
        if (!_io_cache)
-               return -ENOMEM;
+               return r;
 
        /* allocate a slab for the target ios */
        _tio_cache = KMEM_CACHE(dm_target_io, 0);
-       if (!_tio_cache) {
-               kmem_cache_destroy(_io_cache);
-               return -ENOMEM;
-       }
+       if (!_tio_cache)
+               goto out_free_io_cache;
 
        r = dm_uevent_init();
-       if (r) {
-               kmem_cache_destroy(_tio_cache);
-               kmem_cache_destroy(_io_cache);
-               return r;
-       }
+       if (r)
+               goto out_free_tio_cache;
 
        _major = major;
        r = register_blkdev(_major, _name);
-       if (r < 0) {
-               kmem_cache_destroy(_tio_cache);
-               kmem_cache_destroy(_io_cache);
-               dm_uevent_exit();
-               return r;
-       }
+       if (r < 0)
+               goto out_uevent_exit;
 
        if (!_major)
                _major = r;
 
        return 0;
+
+out_uevent_exit:
+       dm_uevent_exit();
+out_free_tio_cache:
+       kmem_cache_destroy(_tio_cache);
+out_free_io_cache:
+       kmem_cache_destroy(_io_cache);
+
+       return r;
 }
 
 static void local_exit(void)