diff options
author | Johannes Thumshirn <morbidrsa@gmail.com> | 2015-01-11 06:45:23 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2015-02-09 13:06:49 -0500 |
commit | ff658e9c1aae9a84dd06d46f847dc0cd2bf0dd11 (patch) | |
tree | 22a1811d1087f6581f4bedbb535626779570d7c8 /drivers/md | |
parent | 9cb1397d585c28c2acff06a6002fc2c8db19a80d (diff) |
dm mpath: simplify failure path of dm_multipath_init()
Currently the cleanup of all error cases are open-coded. Introduce a
common exit path and labels.
Signed-off-by: Johannes Thumshirn <morbidrsa@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-mpath.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 863fc8c1ac06..d376dc87716e 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -1733,16 +1733,15 @@ static int __init dm_multipath_init(void) | |||
1733 | r = dm_register_target(&multipath_target); | 1733 | r = dm_register_target(&multipath_target); |
1734 | if (r < 0) { | 1734 | if (r < 0) { |
1735 | DMERR("register failed %d", r); | 1735 | DMERR("register failed %d", r); |
1736 | kmem_cache_destroy(_mpio_cache); | 1736 | r = -EINVAL; |
1737 | return -EINVAL; | 1737 | goto bad_register_target; |
1738 | } | 1738 | } |
1739 | 1739 | ||
1740 | kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0); | 1740 | kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0); |
1741 | if (!kmultipathd) { | 1741 | if (!kmultipathd) { |
1742 | DMERR("failed to create workqueue kmpathd"); | 1742 | DMERR("failed to create workqueue kmpathd"); |
1743 | dm_unregister_target(&multipath_target); | 1743 | r = -ENOMEM; |
1744 | kmem_cache_destroy(_mpio_cache); | 1744 | goto bad_alloc_kmultipathd; |
1745 | return -ENOMEM; | ||
1746 | } | 1745 | } |
1747 | 1746 | ||
1748 | /* | 1747 | /* |
@@ -1755,16 +1754,23 @@ static int __init dm_multipath_init(void) | |||
1755 | WQ_MEM_RECLAIM); | 1754 | WQ_MEM_RECLAIM); |
1756 | if (!kmpath_handlerd) { | 1755 | if (!kmpath_handlerd) { |
1757 | DMERR("failed to create workqueue kmpath_handlerd"); | 1756 | DMERR("failed to create workqueue kmpath_handlerd"); |
1758 | destroy_workqueue(kmultipathd); | 1757 | r = -ENOMEM; |
1759 | dm_unregister_target(&multipath_target); | 1758 | goto bad_alloc_kmpath_handlerd; |
1760 | kmem_cache_destroy(_mpio_cache); | ||
1761 | return -ENOMEM; | ||
1762 | } | 1759 | } |
1763 | 1760 | ||
1764 | DMINFO("version %u.%u.%u loaded", | 1761 | DMINFO("version %u.%u.%u loaded", |
1765 | multipath_target.version[0], multipath_target.version[1], | 1762 | multipath_target.version[0], multipath_target.version[1], |
1766 | multipath_target.version[2]); | 1763 | multipath_target.version[2]); |
1767 | 1764 | ||
1765 | return 0; | ||
1766 | |||
1767 | bad_alloc_kmpath_handlerd: | ||
1768 | destroy_workqueue(kmultipathd); | ||
1769 | bad_alloc_kmultipathd: | ||
1770 | dm_unregister_target(&multipath_target); | ||
1771 | bad_register_target: | ||
1772 | kmem_cache_destroy(_mpio_cache); | ||
1773 | |||
1768 | return r; | 1774 | return r; |
1769 | } | 1775 | } |
1770 | 1776 | ||