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

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