Whamcloud - gitweb
LU-3321 clio: revert LU-2622 for removing global env list
[fs/lustre-release.git] / lustre / lclient / lcommon_misc.c
index 9dd8918..2ba559e 100644 (file)
@@ -142,10 +142,11 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
 
        rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
        if (rc) {
+               cl_io_fini(env, io);
+               cl_env_put(env, &refcheck);
                /* Does not make sense to take GL for released layout */
                if (rc > 0)
                        rc = -ENOTSUPP;
-               cl_env_put(env, &refcheck);
                return rc;
         }
 
@@ -156,15 +157,15 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
         descr->cld_gid = gid;
         descr->cld_mode = CLM_GROUP;
 
-        enqflags = CEF_MUST | (nonblock ? CEF_NONBLOCK : 0);
-        descr->cld_enq_flags = enqflags;
+       enqflags = CEF_MUST | (nonblock ? CEF_NONBLOCK : 0);
+       descr->cld_enq_flags = enqflags;
 
-        lock = cl_lock_request(env, io, descr, GROUPLOCK_SCOPE, cfs_current());
-        if (IS_ERR(lock)) {
-                cl_io_fini(env, io);
-                cl_env_put(env, &refcheck);
-                return PTR_ERR(lock);
-        }
+       lock = cl_lock_request(env, io, descr, GROUPLOCK_SCOPE, current);
+       if (IS_ERR(lock)) {
+               cl_io_fini(env, io);
+               cl_env_put(env, &refcheck);
+               return PTR_ERR(lock);
+       }
 
         cg->cg_env  = cl_env_get(&refcheck);
         cg->cg_io   = io;
@@ -178,20 +179,20 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock,
 
 void cl_put_grouplock(struct ccc_grouplock *cg)
 {
-        struct lu_env  *env  = cg->cg_env;
-        struct cl_io   *io   = cg->cg_io;
-        struct cl_lock *lock = cg->cg_lock;
-        int             refcheck;
+       struct lu_env  *env  = cg->cg_env;
+       struct cl_io   *io   = cg->cg_io;
+       struct cl_lock *lock = cg->cg_lock;
+       int             refcheck;
 
-        LASSERT(cg->cg_env);
-        LASSERT(cg->cg_gid);
+       LASSERT(cg->cg_env);
+       LASSERT(cg->cg_gid);
 
-        cl_env_implant(env, &refcheck);
-        cl_env_put(env, &refcheck);
+       cl_env_implant(env, &refcheck);
+       cl_env_put(env, &refcheck);
 
-        cl_unuse(env, lock);
-        cl_lock_release(env, lock, GROUPLOCK_SCOPE, cfs_current());
-        cl_io_fini(env, io);
-        cl_env_put(env, NULL);
+       cl_unuse(env, lock);
+       cl_lock_release(env, lock, GROUPLOCK_SCOPE, current);
+       cl_io_fini(env, io);
+       cl_env_put(env, NULL);
 }