Whamcloud - gitweb
LU-9065 osc: fix for cl_env_get in low memory 71/25171/7
authorAlexander Boyko <alexander.boyko@seagate.com>
Tue, 31 Jan 2017 11:26:24 +0000 (14:26 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Apr 2017 04:43:41 +0000 (04:43 +0000)
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 <alexander.boyko@seagate.com>
Change-Id: I4fbca9f3bdc77a5c52979eeb0e00e915ff9ad9b0
Seagate-bug-id: MRP-4120
Reviewed-on: https://review.whamcloud.com/25171
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@seagate.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_cache.c
lustre/osc/osc_lock.c

index 96d13ca..43c4b6f 100644 (file)
@@ -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;
index 6069c21..f0f5d00 100644 (file)
@@ -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);
 }