From 51b5f17bba74ada397cbcff4944e5412fd126e00 Mon Sep 17 00:00:00 2001 From: tappro Date: Fri, 8 Sep 2006 00:36:38 +0000 Subject: [PATCH] fix several memleaks and small issues --- lustre/include/obd_class.h | 3 ++- lustre/mds/handler.c | 3 +++ lustre/mdt/mdt_handler.c | 1 + lustre/mdt/mdt_recovery.c | 3 +-- lustre/obdfilter/filter.c | 32 ++++++++++++++++---------------- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index b619a67..0d94bc0 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -411,7 +411,8 @@ static inline int obd_precleanup(struct obd_device *obd, lu_context_exit(&ctx); lu_context_fini(&ctx); } - } + } else + rc = 0; } else #endif { diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 0634e8b..9cf8423 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2869,6 +2869,9 @@ static int mds_cmd_cleanup(struct obd_device *obd) mds->mds_objects_dir = NULL; } + if (mds->mds_lov_objids != NULL) + OBD_FREE(mds->mds_lov_objids, mds->mds_lov_objids_size); + shrink_dcache_parent(mds->mds_fid_de); dput(mds->mds_fid_de); LL_DQUOT_OFF(obd->u.obt.obt_sb); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index b7b9eff..e90bc79 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2501,6 +2501,7 @@ static void mdt_stack_fini(const struct lu_context *ctx, } LASSERT(top); top->ld_ops->ldo_process_config(ctx, top, lcfg); + lustre_cfg_free(lcfg); lu_site_purge(ctx, top->ld_site, ~0); while (d != NULL) { diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 74e0766..7e21a15 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -191,9 +191,8 @@ static int mdt_init_clients_data(const struct lu_context *ctx, spin_unlock(&mdt->mdt_transno_lock); } -err_client: if (mcd) - OBD_FREE(mcd, sizeof(*mcd)); + OBD_FREE_PTR(mcd); RETURN(rc); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 203a704..b62f5e9 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -792,7 +792,7 @@ static int filter_cleanup_groups(struct obd_device *obd) } } OBD_FREE(filter->fo_dentry_O_sub, - filter->fo_subdir_count * + filter->fo_group_count * sizeof(*filter->fo_dentry_O_sub)); filter->fo_dentry_O_sub = NULL; } @@ -867,6 +867,7 @@ static int filter_read_group_internal(struct obd_device *obd, int group, char name[25]; __u64 last_objid; loff_t off = 0; + int len = group + 1; snprintf(name, 24, "%d", group); name[24] = '\0'; @@ -929,7 +930,6 @@ static int filter_read_group_internal(struct obd_device *obd, int group, /* 'group' is an index; we need an array of length 'group + 1' */ if (group + 1 > old_count) { - int len = group + 1; OBD_ALLOC(new_objids, len * sizeof(*new_objids)); OBD_ALLOC(new_subdirs, len * sizeof(*new_subdirs)); OBD_ALLOC(new_groups, len * sizeof(*new_groups)); @@ -939,16 +939,16 @@ static int filter_read_group_internal(struct obd_device *obd, int group, new_groups == NULL || new_files == NULL) GOTO(cleanup, rc = -ENOMEM); - memcpy(new_objids, filter->fo_last_objids, - old_count * sizeof(*new_objids)); - memcpy(new_subdirs, filter->fo_dentry_O_sub, - old_count * sizeof(*new_subdirs)); - memcpy(new_groups, filter->fo_dentry_O_groups, - old_count * sizeof(*new_groups)); - memcpy(new_files, filter->fo_last_objid_files, - old_count * sizeof(*new_files)); - if (old_count) { + memcpy(new_objids, filter->fo_last_objids, + old_count * sizeof(*new_objids)); + memcpy(new_subdirs, filter->fo_dentry_O_sub, + old_count * sizeof(*new_subdirs)); + memcpy(new_groups, filter->fo_dentry_O_groups, + old_count * sizeof(*new_groups)); + memcpy(new_files, filter->fo_last_objid_files, + old_count * sizeof(*new_files)); + OBD_FREE(filter->fo_last_objids, old_count * sizeof(*new_objids)); OBD_FREE(filter->fo_dentry_O_sub, @@ -988,13 +988,13 @@ static int filter_read_group_internal(struct obd_device *obd, int group, switch (stage) { case 4: if (new_objids != NULL) - OBD_FREE(new_objids, group * sizeof(*new_objids)); + OBD_FREE(new_objids, len * sizeof(*new_objids)); if (new_subdirs != NULL) - OBD_FREE(new_subdirs, group * sizeof(*new_subdirs)); + OBD_FREE(new_subdirs, len * sizeof(*new_subdirs)); if (new_groups != NULL) - OBD_FREE(new_groups, group * sizeof(*new_groups)); + OBD_FREE(new_groups, len * sizeof(*new_groups)); if (new_files != NULL) - OBD_FREE(new_files, group * sizeof(*new_files)); + OBD_FREE(new_files, len * sizeof(*new_files)); case 3: if (filter->fo_subdir_count) { for (i = 0; i < filter->fo_subdir_count; i++) { @@ -2316,7 +2316,7 @@ static int filter_connect(const struct lu_context *ctx, LASSERT(exp != NULL); fed = &exp->exp_filter_data; - + rc = filter_connect_internal(exp, data); if (rc) GOTO(cleanup, rc); -- 1.8.3.1