Whamcloud - gitweb
LU-12034 obdclass: put all service's env on the list
[fs/lustre-release.git] / lustre / include / obd_class.h
index 359e7ef..a4e64b2 100644 (file)
@@ -576,12 +576,19 @@ static inline int obd_precleanup(struct obd_device *obd)
        ENTRY;
 
        if (ldt != NULL && d != NULL) {
-               struct lu_env env;
-
-               rc = lu_env_init(&env, ldt->ldt_ctx_tags);
-               if (rc == 0) {
-                       ldt->ldt_ops->ldto_device_fini(&env, d);
-                       lu_env_fini(&env);
+               struct lu_env *env = lu_env_find();
+               struct lu_env _env;
+
+               if (!env) {
+                       env = &_env;
+                       rc = lu_env_init(env, ldt->ldt_ctx_tags);
+                       LASSERT(rc == 0);
+                       lu_env_add(env);
+               }
+               ldt->ldt_ops->ldto_device_fini(env, d);
+               if (env == &_env) {
+                       lu_env_remove(env);
+                       lu_env_fini(env);
                }
        }