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