RE: [PATCH 01/24] e4defrag: backwards-allocated files should be defragmented too

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>-----Original Message-----
>From: linux-ext4-owner@xxxxxxxxxxxxxxx [mailto:linux-ext4-owner@xxxxxxxxxxxxxxx] On Behalf Of
>Darrick J. Wong
>Sent: Saturday, July 19, 2014 7:52 AM
>To: tytso@xxxxxxx; darrick.wong@xxxxxxxxxx
>Cc: Xiaoguang Wang; linux-ext4@xxxxxxxxxxxxxxx
>Subject: [PATCH 01/24] e4defrag: backwards-allocated files should be defragmented too
>
>Currently, e4defrag avoids increasing file fragmentation by comparing
>the number of runs of physical extents of both the original and the
>donor files.  Unfortunately, there is a bug in the routine that counts
>physical extents, since it doesn't look at the logical block offsets
>of the extents.  Therefore, a file whose blocks were allocated in
>reverse order will be seen as only having one big physical extent, and
>therefore will not be defragmented.
>
>Fix the counting routine to consider logical extent offset so that we
>defragment backwards-allocated files.  This could be problematic if we
>ever gain the ability to lay out logically sparse extents in a
>physically contiguous manner, but presumably one wouldn't call defrag
>on such a file.
>
>Reported-by: Xiaoguang Wang <wangxg.fnst@xxxxxxxxxxxxxx>
>Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
>---
> misc/e4defrag.c |    4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>
>diff --git a/misc/e4defrag.c b/misc/e4defrag.c
>index a204793..d0eac60 100644
>--- a/misc/e4defrag.c
>+++ b/misc/e4defrag.c
>@@ -888,7 +888,9 @@ static int get_physical_count(struct fiemap_extent_list *physical_list_head)
>
> 	do {
> 		if ((ext_list_tmp->data.physical + ext_list_tmp->data.len)
>-				!= ext_list_tmp->next->data.physical) {
>+				!= ext_list_tmp->next->data.physical ||
>+		    (ext_list_tmp->data.logical + ext_list_tmp->data.len)
>+				!= ext_list_tmp->next->data.logical) {
> 			/* This extent and next extent are not continuous. */
> 			ret++;
> 		}

It looks good to me.

Reviewed-by: Akira Fujita <a-fujita@xxxxxxxxxxxxx>

Thanks,
Akira Fujita
��.n��������+%������w��{.n�����{�����ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f





[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux