Commit e67f133d authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman

staging: lustre: osc: tidy up osc_init()

A module_init() function that registers the services
of the module should do that last, after all other
initialization has succeeded.
This patch moves the class_register_type() call to the
end and ensures everything else that might have been
set up, is cleaned up on error.
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 03f17b5d
...@@ -2837,19 +2837,14 @@ static int __init osc_init(void) ...@@ -2837,19 +2837,14 @@ static int __init osc_init(void)
lprocfs_osc_init_vars(&lvars); lprocfs_osc_init_vars(&lvars);
rc = class_register_type(&osc_obd_ops, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
if (rc)
goto out_kmem;
rc = register_shrinker(&osc_cache_shrinker); rc = register_shrinker(&osc_cache_shrinker);
if (rc) if (rc)
goto out_type; goto err;
/* This is obviously too much memory, only prevent overflow here */ /* This is obviously too much memory, only prevent overflow here */
if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) { if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0) {
rc = -EINVAL; rc = -EINVAL;
goto out_type; goto err;
} }
reqpool_size = osc_reqpool_mem_max << 20; reqpool_size = osc_reqpool_mem_max << 20;
...@@ -2870,14 +2865,22 @@ static int __init osc_init(void) ...@@ -2870,14 +2865,22 @@ static int __init osc_init(void)
osc_rq_pool = ptlrpc_init_rq_pool(0, OST_MAXREQSIZE, osc_rq_pool = ptlrpc_init_rq_pool(0, OST_MAXREQSIZE,
ptlrpc_add_rqs_to_pool); ptlrpc_add_rqs_to_pool);
if (osc_rq_pool)
return 0;
rc = -ENOMEM; rc = -ENOMEM;
out_type: if (!osc_rq_pool)
class_unregister_type(LUSTRE_OSC_NAME); goto err;
out_kmem:
rc = class_register_type(&osc_obd_ops, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
if (rc)
goto err;
return rc;
err:
if (osc_rq_pool)
ptlrpc_free_rq_pool(osc_rq_pool);
unregister_shrinker(&osc_cache_shrinker);
lu_kmem_fini(osc_caches); lu_kmem_fini(osc_caches);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment