mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 07:23:14 +00:00
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>
This commit is contained in:
parent
9cb1397d58
commit
ff658e9c1a
@ -1733,16 +1733,15 @@ static int __init dm_multipath_init(void)
|
|||||||
r = dm_register_target(&multipath_target);
|
r = dm_register_target(&multipath_target);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
DMERR("register failed %d", r);
|
DMERR("register failed %d", r);
|
||||||
kmem_cache_destroy(_mpio_cache);
|
r = -EINVAL;
|
||||||
return -EINVAL;
|
goto bad_register_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0);
|
kmultipathd = alloc_workqueue("kmpathd", WQ_MEM_RECLAIM, 0);
|
||||||
if (!kmultipathd) {
|
if (!kmultipathd) {
|
||||||
DMERR("failed to create workqueue kmpathd");
|
DMERR("failed to create workqueue kmpathd");
|
||||||
dm_unregister_target(&multipath_target);
|
r = -ENOMEM;
|
||||||
kmem_cache_destroy(_mpio_cache);
|
goto bad_alloc_kmultipathd;
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1755,16 +1754,23 @@ static int __init dm_multipath_init(void)
|
|||||||
WQ_MEM_RECLAIM);
|
WQ_MEM_RECLAIM);
|
||||||
if (!kmpath_handlerd) {
|
if (!kmpath_handlerd) {
|
||||||
DMERR("failed to create workqueue kmpath_handlerd");
|
DMERR("failed to create workqueue kmpath_handlerd");
|
||||||
destroy_workqueue(kmultipathd);
|
r = -ENOMEM;
|
||||||
dm_unregister_target(&multipath_target);
|
goto bad_alloc_kmpath_handlerd;
|
||||||
kmem_cache_destroy(_mpio_cache);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DMINFO("version %u.%u.%u loaded",
|
DMINFO("version %u.%u.%u loaded",
|
||||||
multipath_target.version[0], multipath_target.version[1],
|
multipath_target.version[0], multipath_target.version[1],
|
||||||
multipath_target.version[2]);
|
multipath_target.version[2]);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
bad_alloc_kmpath_handlerd:
|
||||||
|
destroy_workqueue(kmultipathd);
|
||||||
|
bad_alloc_kmultipathd:
|
||||||
|
dm_unregister_target(&multipath_target);
|
||||||
|
bad_register_target:
|
||||||
|
kmem_cache_destroy(_mpio_cache);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user