linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: group cache is added in ext4_mb_discard_preallocations()
@ 2010-03-30 12:36 jing zhang
  2010-03-30 18:37 ` Aneesh Kumar K. V
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: jing zhang @ 2010-03-30 12:36 UTC (permalink / raw)
  To: linux-ext4, zj.barak
  Cc: Theodore Ts'o, Andreas Dilger, Dave Kleikamp,
	Aneesh Kumar K. V

From: Jing Zhang <zj.barak@gmail.com>

Date: Tue Mar 30 20:35:22     2010

With the added cache, better group locality may be earned when
allocating blocks.

Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Andreas Dilger <adilger@sun.com>
Cc: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: "Aneesh Kumar K. V" <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Jing Zhang <zj.barak@gmail.com>

---

--- linux-2.6.32/fs/ext4/mballoc.c	2009-12-03 11:51:22.000000000 +0800
+++ ext4_mm_leak/mballoc-13.c	2010-03-30 20:28:08.000000000 +0800
@@ -4183,12 +4183,20 @@ static int ext4_mb_discard_preallocation
 	ext4_group_t i, ngroups = ext4_get_groups_count(sb);
 	int ret;
 	int freed = 0;
+	static ext4_group_t grp_cache = 0;

 	trace_ext4_mb_discard_preallocations(sb, needed);
-	for (i = 0; i < ngroups && needed > 0; i++) {
-		ret = ext4_mb_discard_group_preallocations(sb, i, needed);
+	if (needed <= 0)
+		return freed;
+	for (i = 0; i < ngroups; i++) {
+		if (grp_cache >= ngroups)
+			grp_cache -= ngroups;
+		ret = ext4_mb_discard_group_preallocations(sb, grp_cache, needed);
 		freed += ret;
 		needed -= ret;
+		if (needed <= 0)
+			break;
+		grp_cache++;
 	}

 	return freed;

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-04-07 14:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-30 12:36 [PATCH] ext4: group cache is added in ext4_mb_discard_preallocations() jing zhang
2010-03-30 18:37 ` Aneesh Kumar K. V
2010-03-31 15:10   ` jing zhang
2010-03-31 15:03 ` Andreas Dilger
2010-04-01 12:34   ` jing zhang
2010-04-06 18:49     ` tytso
2010-04-07 12:58       ` jing zhang
2010-04-07 14:46         ` tytso
2010-04-06 18:31 ` tytso
2010-04-07 12:50   ` jing zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).