diff --git a/lustre/ChangeLog b/lustre/ChangeLog index a7f147926ad91d387115ecf72b8666ba3534aa50..f3df71ee4bbde2b68f44e1ae96537a1e46e1b825 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1458,7 +1458,12 @@ Bugzilla : 16450 Description: OSD_COUNTERS-mandatory Details : Make previously optional ->oti_{w,r}_locks sanity checks mandatory to simplify the code. - + +Severity : normal +Bugzilla : 16450 +Description: simplify cmm_device freeing logic. +Details : Call cmm_device_free() in the failure path of cmm_device_alloc(). + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com> diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index aef1da6fe8741cda81c0c69ec687208f7166121d..3cf494b6f6be7aa721ae13c309de5f16660335c9 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -359,6 +359,24 @@ int cmm_upcall(const struct lu_env *env, struct md_device *md, RETURN(rc); } +static struct lu_device *cmm_device_free(const struct lu_env *env, + struct lu_device *d) +{ + struct cmm_device *m = lu2cmm_dev(d); + struct lu_device *next = md2lu_dev(m->cmm_child); + ENTRY; + + LASSERT(m->cmm_tgt_count == 0); + LASSERT(list_empty(&m->cmm_targets)); + if (m->cmm_fld != NULL) { + OBD_FREE_PTR(m->cmm_fld); + m->cmm_fld = NULL; + } + md_device_fini(&m->cmm_md_dev); + OBD_FREE_PTR(m); + RETURN(next); +} + static struct lu_device *cmm_device_alloc(const struct lu_env *env, struct lu_device_type *t, struct lustre_cfg *cfg) @@ -378,32 +396,12 @@ static struct lu_device *cmm_device_alloc(const struct lu_env *env, l->ld_ops = &cmm_lu_ops; OBD_ALLOC_PTR(m->cmm_fld); - if (!m->cmm_fld) - GOTO(out_free_cmm, l = ERR_PTR(-ENOMEM)); + if (!m->cmm_fld) { + cmm_device_free(env, l); + l = ERR_PTR(-ENOMEM); } - - RETURN(l); -out_free_cmm: - OBD_FREE_PTR(m); - return l; -} - -static struct lu_device *cmm_device_free(const struct lu_env *env, - struct lu_device *d) -{ - struct cmm_device *m = lu2cmm_dev(d); - struct lu_device *next = md2lu_dev(m->cmm_child); - ENTRY; - - LASSERT(m->cmm_tgt_count == 0); - LASSERT(list_empty(&m->cmm_targets)); - if (m->cmm_fld != NULL) { - OBD_FREE_PTR(m->cmm_fld); - m->cmm_fld = NULL; } - md_device_fini(&m->cmm_md_dev); - OBD_FREE_PTR(m); - RETURN(next); + RETURN(l); } /* context key constructor/destructor: cmm_key_init, cmm_key_fini */