Whamcloud - gitweb
LU-12707 obdecho: avoid panic with partially object init 50/35950/5
authorAlexey Lyashkov <c17817@cray.com>
Wed, 28 Aug 2019 15:06:43 +0000 (18:06 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 20 Sep 2019 07:55:04 +0000 (07:55 +0000)
in some cases (like ENOMEM) init function can't called, so
any init related code should placed in the object delete handler,
not in the object free.

Signed-off-by: Alexey Lyashkov <c17817@cray.com>
Change-Id: I1fca56423de9a045aac2c495fbc45069c3bbc97c
Reviewed-on: https://review.whamcloud.com/35950
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/obdecho/echo_client.c

index ed6fd8c..2acc4a0 100644 (file)
@@ -524,23 +524,37 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj,
        RETURN(0);
 }
 
-static void echo_object_free(const struct lu_env *env, struct lu_object *obj)
+static void echo_object_delete(const struct lu_env *env, struct lu_object *obj)
 {
        struct echo_object *eco    = cl2echo_obj(lu2cl(obj));
-       struct echo_client_obd *ec = eco->eo_dev->ed_ec;
+       struct echo_client_obd *ec;
 
        ENTRY;
+
+       /* object delete called unconditolally - layer init or not */
+       if (eco->eo_dev == NULL)
+               return;
+
+       ec = eco->eo_dev->ed_ec;
+
        LASSERT(atomic_read(&eco->eo_npages) == 0);
 
        spin_lock(&ec->ec_lock);
        list_del_init(&eco->eo_obj_chain);
        spin_unlock(&ec->ec_lock);
 
-       lu_object_fini(obj);
-       lu_object_header_fini(obj->lo_header);
-
        if (eco->eo_oinfo)
                OBD_FREE_PTR(eco->eo_oinfo);
+}
+
+static void echo_object_free(const struct lu_env *env, struct lu_object *obj)
+{
+       struct echo_object *eco    = cl2echo_obj(lu2cl(obj));
+
+       ENTRY;
+
+       lu_object_fini(obj);
+       lu_object_header_fini(obj->lo_header);
 
        OBD_SLAB_FREE_PTR(eco, echo_object_kmem);
        EXIT;
@@ -556,7 +570,7 @@ static int echo_object_print(const struct lu_env *env, void *cookie,
 
 static const struct lu_object_operations echo_lu_obj_ops = {
        .loo_object_init      = echo_object_init,
-       .loo_object_delete    = NULL,
+       .loo_object_delete    = echo_object_delete,
        .loo_object_release   = NULL,
        .loo_object_free      = echo_object_free,
        .loo_object_print     = echo_object_print,