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

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