All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/5] mballoc: don't change cpa if cur_distance is equal to new_distance
@ 2011-02-06  4:54 Coly Li
  2011-02-24 19:10 ` Ted Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Coly Li @ 2011-02-06  4:54 UTC (permalink / raw)
  To: linux-ext4; +Cc: Alex Tomas, Theodore Tso

In ext4_mb_check_group_pa(), cur_distance is selected to return only
when it's smaller than new_distance, this is unreasonable. If
cur_distance is equal to new_distance, current code will return
new_distance to update cpa from ext4_mb_use_preallocated(), which doesn't
make any sense.

This patch makes new_distance to return only when it's smaller then
cur_distance, which avoids unnecessary cpa update in
ext4_mb_use_preallocated().

Signed-off-by: Coly Li <bosong.ly@taobao.com>
Cc: Alex Tomas <alex@clusterfs.com>
Cc: Theodore Tso <tytso@google.com>
---
  fs/ext4/mballoc.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 569cff6..af706f6 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -3181,7 +3181,7 @@ ext4_mb_check_group_pa(ext4_fsblk_t goal_block,
  	cur_distance = abs(goal_block - cpa->pa_pstart);
  	new_distance = abs(goal_block - pa->pa_pstart);

-	if (cur_distance < new_distance)
+	if (cur_distance <= new_distance)
  		return cpa;

  	/* drop the previous reference */
-- 
1.7.3.4

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

* Re: [PATCH 5/5] mballoc: don't change cpa if cur_distance is equal to new_distance
  2011-02-06  4:54 [PATCH 5/5] mballoc: don't change cpa if cur_distance is equal to new_distance Coly Li
@ 2011-02-24 19:10 ` Ted Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2011-02-24 19:10 UTC (permalink / raw)
  To: Coly Li; +Cc: linux-ext4, Alex Tomas, Theodore Tso

Added to the ext4 patch queue, albeit with a rewritten patch
description.

					- Ted

commit 5a54b2f199fdf19533f96c3e285b70c6729e1e4a
Author: Coly Li <colyli@gmail.com>
Date:   Thu Feb 24 14:10:05 2011 -0500

    ext4: mballoc: don't replace the current preallocation group unnecessarily
    
    In ext4_mb_check_group_pa(), the current preallocation space is
    replaced with a new preallocation space when the two have the same
    distance from the goal block.
    
    This doesn't actually gain us anything, so change things so that the
    function only switches to the new preallocation group if its distance
    from the goal block is strictly smaller than the current preallocaiton
    group's distance from the goal block.
    
    Signed-off-by: Coly Li <bosong.ly@taobao.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

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

end of thread, other threads:[~2011-02-24 19:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-06  4:54 [PATCH 5/5] mballoc: don't change cpa if cur_distance is equal to new_distance Coly Li
2011-02-24 19:10 ` Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.