Blame SOURCES/e2fsprogs-1.42.9-defrag-backwards-files.patch

98901c
commit c7c539e8fd86de691475eea00409c6c030f312cd
98901c
Author: Darrick J. Wong <darrick.wong@oracle.com>
98901c
Date:   Tue Jul 22 12:40:56 2014 -0400
98901c
98901c
    e4defrag: backwards-allocated files should be defragmented too
98901c
    
98901c
    Currently, e4defrag avoids increasing file fragmentation by comparing
98901c
    the number of runs of physical extents of both the original and the
98901c
    donor files.  Unfortunately, there is a bug in the routine that counts
98901c
    physical extents, since it doesn't look at the logical block offsets
98901c
    of the extents.  Therefore, a file whose blocks were allocated in
98901c
    reverse order will be seen as only having one big physical extent, and
98901c
    therefore will not be defragmented.
98901c
    
98901c
    Fix the counting routine to consider logical extent offset so that we
98901c
    defragment backwards-allocated files.  This could be problematic if we
98901c
    ever gain the ability to lay out logically sparse extents in a
98901c
    physically contiguous manner, but presumably one wouldn't call defrag
98901c
    on such a file.
98901c
    
98901c
    Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
98901c
    Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
98901c
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
98901c
98901c
Index: e2fsprogs-1.42.9/misc/e4defrag.c
98901c
===================================================================
98901c
--- e2fsprogs-1.42.9.orig/misc/e4defrag.c
98901c
+++ e2fsprogs-1.42.9/misc/e4defrag.c
98901c
@@ -941,7 +941,9 @@ static int get_physical_count(struct fie
98901c
 
98901c
 	do {
98901c
 		if ((ext_list_tmp->data.physical + ext_list_tmp->data.len)
98901c
-				!= ext_list_tmp->next->data.physical) {
98901c
+				!= ext_list_tmp->next->data.physical ||
98901c
+		    (ext_list_tmp->data.logical + ext_list_tmp->data.len)
98901c
+				!= ext_list_tmp->next->data.logical) {
98901c
 			/* This extent and next extent are not continuous. */
98901c
 			ret++;
98901c
 		}