Whamcloud - gitweb
LU-12707 obdecho: avoid panic with partially object init 17/36317/2
authorAlexey Lyashkov <c17817@cray.com>
Wed, 28 Aug 2019 15:06:43 +0000 (18:06 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 21 Nov 2019 07:31:32 +0000 (07:31 +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.

Lustre-change: https://review.whamcloud.com/35950
Lustre-commit: 1a9ca8417c60f04a9aa719b7254372e2d18a6b0a

Signed-off-by: Alexey Lyashkov <c17817@cray.com>
Change-Id: I1fca56423de9a045aac2c495fbc45069c3bbc97c
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36317
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 563300d..202c4ed 100644 (file)
@@ -507,11 +507,18 @@ 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;
-        ENTRY;
+       struct echo_object *eco    = cl2echo_obj(lu2cl(obj));
+       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);
 
@@ -519,11 +526,18 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj)
        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 != NULL)
                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;
@@ -538,12 +552,12 @@ 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_release   = NULL,
-        .loo_object_free      = echo_object_free,
-        .loo_object_print     = echo_object_print,
-        .loo_object_invariant = NULL
+       .loo_object_init      = echo_object_init,
+       .loo_object_delete    = echo_object_delete,
+       .loo_object_release   = NULL,
+       .loo_object_free      = echo_object_free,
+       .loo_object_print     = echo_object_print,
+       .loo_object_invariant = NULL
 };
 /** @} echo_lu_ops */