From: Alexander Boyko Date: Tue, 31 Jan 2017 11:26:24 +0000 (+0300) Subject: LU-9065 osc: fix for cl_env_get in low memory X-Git-Tag: 2.9.56~28 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=fd1aafaf99b81c070a46e1481734932a0e53ef28 LU-9065 osc: fix for cl_env_get in low memory In low memory situation cl_env_get->cl_env_new->kmem_cache_alloc could fail with ENOMEM error. Some parts doesn`t handle error case, for example: ...(osc_lock_upcall()) ASSERTION( !IS_ERR(env) ) failed: ...(osc_lock.c:315:osc_lock_upcall()) LBUG For osc_lock_upcall() the patch changes cl_env_get to cl_env_percpu_peek, this prevents memory allocation and couldn`t fail in low memory case. For osc_extent_truncate() the patch adds error handle. Signed-off-by: Alexander Boyko Change-Id: I4fbca9f3bdc77a5c52979eeb0e00e915ff9ad9b0 Seagate-bug-id: MRP-4120 Reviewed-on: https://review.whamcloud.com/25171 Reviewed-by: Jinshan Xiong Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andrew Perepechko Reviewed-by: Oleg Drokin --- diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index 96d13ca..43c4b6f 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -991,6 +991,9 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, * We can't use that env from osc_cache_truncate_start() because * 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; diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index 6069c21..f0f5d00 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -302,11 +302,10 @@ 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; ENTRY; - env = cl_env_get(&refcheck); + env = cl_env_percpu_get(); /* should never happen, similar to osc_ldlm_blocking_ast(). */ LASSERT(!IS_ERR(env)); @@ -345,7 +344,7 @@ static int osc_lock_upcall(void *cookie, struct lustre_handle *lockh, if (oscl->ols_owner != NULL) cl_sync_io_note(env, oscl->ols_owner, rc); - cl_env_put(env, &refcheck); + cl_env_percpu_put(env); RETURN(rc); }