From: Alexey Lyashkov Date: Wed, 28 Aug 2019 15:06:43 +0000 (+0300) Subject: LU-12707 obdecho: avoid panic with partially object init X-Git-Tag: 2.12.4-RC1~109 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=362e9365699abf08d17044c3c9dd60acfb332a9a;p=fs%2Flustre-release.git LU-12707 obdecho: avoid panic with partially object init 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 Change-Id: I1fca56423de9a045aac2c495fbc45069c3bbc97c Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/36317 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 563300d..202c4ed 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -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 */