Whamcloud - gitweb
LU-458 debug: print client profile name correctly
authorYu Jian <yujian@whamcloud.com>
Mon, 21 May 2012 06:23:28 +0000 (14:23 +0800)
committerJohann Lombardi <johann@whamcloud.com>
Wed, 23 May 2012 11:56:54 +0000 (07:56 -0400)
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 <yujian@whamcloud.com>
Change-Id: I9ce2f304f3bad4761d2e3c857e4cdd5df6269c38
Reviewed-on: http://review.whamcloud.com/2841
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/llite/llite_lib.c

index a83a06b..0995701 100644 (file)
@@ -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();