From: jxiong Date: Fri, 24 Apr 2009 01:05:55 +0000 (+0000) Subject: b=19104 X-Git-Tag: v1_9_170~20 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7f4f53ca6151ef5384181c02e9cf3ed5337314c6;p=fs%2Flustre-release.git b=19104 r=wangdi,fanyong we have to replace an entirely new environment for ptlrpc callbacks. Otherwise, in liblustre, the env running for IO would be used for callback. --- diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index e873554..8e013d5 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -879,7 +879,12 @@ struct lu_env *cl_env_nested_get(struct cl_env_nest *nest) } } env = cl_env_get(&nest->cen_refcheck); - LASSERT(ergo(!IS_ERR(env), !cl_io_is_going(env))); + if (IS_ERR(env)) { + cl_env_reexit(nest->cen_cookie); + return env; + } + + LASSERT(!cl_io_is_going(env)); return env; } EXPORT_SYMBOL(cl_env_nested_get); diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index c3b2fee..f611bf6 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -471,18 +471,14 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) */ static int osc_lock_upcall(void *cookie, int errcode) { - struct osc_lock *olck = cookie; - struct cl_lock_slice *slice = &olck->ols_cl; - struct cl_lock *lock = slice->cls_lock; - struct lu_env *env; - - int refcheck; + struct osc_lock *olck = cookie; + struct cl_lock_slice *slice = &olck->ols_cl; + struct cl_lock *lock = slice->cls_lock; + struct lu_env *env; + struct cl_env_nest nest; ENTRY; - /* - * XXX environment should be created in ptlrpcd. - */ - env = cl_env_get(&refcheck); + env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { int rc; @@ -548,7 +544,7 @@ static int osc_lock_upcall(void *cookie, int errcode) /* release cookie reference, acquired by osc_lock_enqueue() */ lu_ref_del(&lock->cll_reference, "upcall", lock); cl_lock_put(env, lock); - cl_env_put(env, &refcheck); + cl_env_nested_put(&nest, env); } else /* should never happen, similar to osc_ldlm_blocking_ast(). */ LBUG(); @@ -723,9 +719,10 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, * new environment has to be created to not corrupt outer context. */ env = cl_env_nested_get(&nest); - if (!IS_ERR(env)) + if (!IS_ERR(env)) { result = osc_dlm_blocking_ast0(env, dlmlock, data, flag); - else { + cl_env_nested_put(&nest, env); + } else { result = PTR_ERR(env); /* * XXX This should never happen, as cl_lock is @@ -740,26 +737,23 @@ static int osc_ldlm_blocking_ast(struct ldlm_lock *dlmlock, else CERROR("BAST failed: %d\n", result); } - cl_env_nested_put(&nest, env); return result; } static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, int flags, void *data) { - struct lu_env *env; - void *env_cookie; - struct osc_lock *olck; - struct cl_lock *lock; - int refcheck; + struct cl_env_nest nest; + struct lu_env *env; + struct osc_lock *olck; + struct cl_lock *lock; int result; int dlmrc; /* first, do dlm part of the work */ dlmrc = ldlm_completion_ast_async(dlmlock, flags, data); /* then, notify cl_lock */ - env_cookie = cl_env_reenter(); - env = cl_env_get(&refcheck); + env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { olck = osc_ast_data_get(dlmlock); if (olck != NULL) { @@ -793,10 +787,9 @@ static int osc_ldlm_completion_ast(struct ldlm_lock *dlmlock, result = 0; } else result = -ELDLM_NO_LOCK_DATA; - cl_env_put(env, &refcheck); + cl_env_nested_put(&nest, env); } else result = PTR_ERR(env); - cl_env_reexit(env_cookie); return dlmrc ?: result; } @@ -806,15 +799,15 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) struct osc_lock *olck; struct cl_lock *lock; struct cl_object *obj; + struct cl_env_nest nest; struct lu_env *env; struct ost_lvb *lvb; struct req_capsule *cap; int result; - int refcheck; LASSERT(lustre_msg_get_opc(req->rq_reqmsg) == LDLM_GL_CALLBACK); - env = cl_env_get(&refcheck); + env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { /* * osc_ast_data_get() has to go after environment is @@ -847,7 +840,7 @@ static int osc_ldlm_glimpse_ast(struct ldlm_lock *dlmlock, void *data) lustre_pack_reply(req, 1, NULL, NULL); result = -ELDLM_NO_LOCK_DATA; } - cl_env_put(env, &refcheck); + cl_env_nested_put(&nest, env); } else result = PTR_ERR(env); req->rq_status = result; @@ -871,16 +864,14 @@ static unsigned long osc_lock_weigh(const struct lu_env *env, */ static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) { + struct cl_env_nest nest; struct lu_env *env; - int refcheck; - void *cookie; struct osc_lock *lock; struct cl_lock *cll; unsigned long weight; ENTRY; might_sleep(); - cookie = cl_env_reenter(); /* * osc_ldlm_weigh_ast has a complex context since it might be called * because of lock canceling, or from user's input. We have to make @@ -888,12 +879,10 @@ static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) * the upper context because cl_lock_put don't modify environment * variables. But in case of .. */ - env = cl_env_get(&refcheck); - if (IS_ERR(env)) { + env = cl_env_nested_get(&nest); + if (IS_ERR(env)) /* Mostly because lack of memory, tend to eliminate this lock*/ - cl_env_reexit(cookie); RETURN(0); - } LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT); lock = osc_ast_data_get(dlmlock); @@ -913,8 +902,7 @@ static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) EXIT; out: - cl_env_put(env, &refcheck); - cl_env_reexit(cookie); + cl_env_nested_put(&nest, env); return weight; }