From 294b4090131fddbb2632cfaf6f97e28ad1ba62a4 Mon Sep 17 00:00:00 2001 From: Yu Jian Date: Mon, 21 May 2012 14:23:28 +0800 Subject: [PATCH] LU-458 debug: print client profile name correctly This patch reverts commit 48c2f667236e2f41f9fd0224b5de7a83517b3180, which does not print client profile name correctly and introduces a new defect that the client profile is not deleted properly. In ll_put_super(), the memory space pointed to by profilenm is in fact freed inside lustre_common_put_super(sb), which is called before LCONSOLE_WARN(). In order to print the client profile name in LCONSOLE_WARN(), we need copy the contents of profilenm to a temporary storage before freeing profilenm. Signed-off-by: Yu Jian Change-Id: I9ce2f304f3bad4761d2e3c857e4cdd5df6269c38 Reviewed-on: http://review.whamcloud.com/2841 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Johann Lombardi --- lustre/llite/llite_lib.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index a83a06b..0995701 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1187,6 +1187,8 @@ void ll_put_super(struct super_block *sb) struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); char *profilenm = get_profile_name(sb); + char *tmp_name = NULL; + int tmp_name_len = 0; int force = 1, next; ENTRY; @@ -1222,6 +1224,15 @@ void ll_put_super(struct super_block *sb) class_manual_cleanup(obd); } + /* Temp storage for client profile name */ + tmp_name_len = strlen(profilenm) + 1; + OBD_ALLOC(tmp_name, tmp_name_len); + if (tmp_name != NULL) + memcpy(tmp_name, profilenm, tmp_name_len); + + if (profilenm) + class_del_profile(profilenm); + #ifdef HAVE_BDI_INIT if (lsi->lsi_flags & LSI_BDI_INITIALIZED) { bdi_destroy(&lsi->lsi_bdi); @@ -1234,10 +1245,13 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); + if (tmp_name != NULL) + profilenm = tmp_name; + LCONSOLE_WARN("client %s(%p) umount complete\n", profilenm, sb); - if (profilenm) - class_del_profile(profilenm); + if (tmp_name != NULL) + OBD_FREE(tmp_name, tmp_name_len); cfs_module_put(); -- 1.8.3.1