Re: [PATCH] ext4: memory leakage in ext4_mb_init()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: jing zhang
Date: Sunday, March 28, 2010 - 1:13 am

2010/3/26, Aneesh Kumar K. V <aneesh.kumar@linux.vnet.ibm.com>:

cool idea, Aneesh, and I got it.

---

--- old-linux-2.6.32/fs/ext4/mballoc.c	2009-12-03 11:51:22.000000000 +0800
+++ ext4_mm_leak/mballoc3-2.c	2010-03-28 16:13:20.000000000 +0800
@@ -2397,11 +2397,27 @@ int ext4_mb_init(struct super_block *sb,
 		i++;
 	} while (i <= sb->s_blocksize_bits + 1);

+	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
+	if (sbi->s_locality_groups == NULL) {
+		kfree(sbi->s_mb_offsets);
+		kfree(sbi->s_mb_maxs);
+		return -ENOMEM;
+	}
+	for_each_possible_cpu(i) {
+		struct ext4_locality_group *lg;
+		lg = per_cpu_ptr(sbi->s_locality_groups, i);
+		mutex_init(&lg->lg_mutex);
+		for (j = 0; j < PREALLOC_TB_SIZE; j++)
+			INIT_LIST_HEAD(&lg->lg_prealloc_list[j]);
+		spin_lock_init(&lg->lg_prealloc_lock);
+	}
+
 	/* init file for buddy data */
 	ret = ext4_mb_init_backend(sb);
 	if (ret != 0) {
 		kfree(sbi->s_mb_offsets);
 		kfree(sbi->s_mb_maxs);
+		free_percpu(sbi->s_locality_groups);
 		return ret;
 	}

@@ -2415,20 +2431,6 @@ int ext4_mb_init(struct super_block *sb,
 	sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
 	sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC;

-	sbi->s_locality_groups = alloc_percpu(struct ext4_locality_group);
-	if (sbi->s_locality_groups == NULL) {
-		kfree(sbi->s_mb_offsets);
-		kfree(sbi->s_mb_maxs);
-		return -ENOMEM;
-	}
-	for_each_possible_cpu(i) {
-		struct ext4_locality_group *lg;
-		lg = per_cpu_ptr(sbi->s_locality_groups, i);
-		mutex_init(&lg->lg_mutex);
-		for (j = 0; j < PREALLOC_TB_SIZE; j++)
-			INIT_LIST_HEAD(&lg->lg_prealloc_list[j]);
-		spin_lock_init(&lg->lg_prealloc_lock);
-	}

 	if (sbi->s_proc)
 		proc_create_data("mb_groups", S_IRUGO, sbi->s_proc,


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Mar 21, 7:01 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Tue Mar 23, 5:47 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), Aneesh Kumar K. V, (Fri Mar 26, 1:54 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), Aneesh Kumar K. V, (Fri Mar 26, 1:57 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Fri Mar 26, 7:40 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Mar 28, 1:13 am)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sat Apr 3, 6:05 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Apr 4, 8:53 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), Eric Sandeen, (Sun Apr 4, 9:27 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Apr 4, 9:51 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), Eric Sandeen, (Sun Apr 4, 9:59 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Apr 4, 10:08 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Sun Apr 4, 10:18 pm)
Re: [PATCH] ext4: memory leakage in ext4_mb_init(), jing zhang, (Tue Apr 6, 6:43 am)