@@ -1038,6 +1038,9 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index,
* it's from lov_io_sub and not fully initialized.
*/
env = cl_env_get(&refcheck);
+ if (IS_ERR(env))
+ return PTR_ERR(env);
+
io = &osc_env_info(env)->oti_io;
io->ci_obj = cl_object_top(osc2cl(obj));
io->ci_ignore_layout = 1;
@@ -297,9 +297,8 @@ static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh,
struct cl_lock_slice *slice = &oscl->ols_cl;
struct lu_env *env;
int rc;
- u16 refcheck;
- env = cl_env_get(&refcheck);
+ env = cl_env_percpu_get();
/* should never happen, similar to osc_ldlm_blocking_ast(). */
LASSERT(!IS_ERR(env));
@@ -338,7 +337,7 @@ static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh,
if (oscl->ols_owner)
cl_sync_io_note(env, oscl->ols_owner, rc);
- cl_env_put(env, &refcheck);
+ cl_env_percpu_put(env);
return rc;
}