Whamcloud - gitweb
LU-6142 osc: tidy up osc_init()
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 194e8cd..56e8b7d 100644 (file)
@@ -3891,14 +3891,9 @@ static int __init osc_init(void)
        if (rc)
                RETURN(rc);
 
-       rc = class_register_type(&osc_obd_ops, NULL, true,
-                                LUSTRE_OSC_NAME, &osc_device_type);
-       if (rc)
-               GOTO(out_kmem, rc);
-
        rc = register_shrinker(&osc_cache_shrinker);
        if (rc)
-               GOTO(out_type, rc);
+               GOTO(out_kmem, rc);
 
        /* This is obviously too much memory, only prevent overflow here */
        if (osc_reqpool_mem_max >= 1 << 12 || osc_reqpool_mem_max == 0)
@@ -3929,14 +3924,19 @@ static int __init osc_init(void)
        if (rc != 0)
                GOTO(out_req_pool, rc);
 
+       rc = class_register_type(&osc_obd_ops, NULL, true,
+                                LUSTRE_OSC_NAME, &osc_device_type);
+       if (rc < 0)
+               GOTO(out_stop_grant, rc);
+
        RETURN(rc);
 
+out_stop_grant:
+       osc_stop_grant_work();
 out_req_pool:
        ptlrpc_free_rq_pool(osc_rq_pool);
 out_shrinker:
        unregister_shrinker(&osc_cache_shrinker);
-out_type:
-       class_unregister_type(LUSTRE_OSC_NAME);
 out_kmem:
        lu_kmem_fini(osc_caches);
 
@@ -3945,11 +3945,11 @@ out_kmem:
 
 static void __exit osc_exit(void)
 {
+       class_unregister_type(LUSTRE_OSC_NAME);
+       ptlrpc_free_rq_pool(osc_rq_pool);
        osc_stop_grant_work();
        unregister_shrinker(&osc_cache_shrinker);
-       class_unregister_type(LUSTRE_OSC_NAME);
        lu_kmem_fini(osc_caches);
-       ptlrpc_free_rq_pool(osc_rq_pool);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");