linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Zheng Liu <gnehzuil.liu@gmail.com>
Cc: linux-ext4@vger.kernel.org, Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH 1/2] e4defrag: defrag a file when orig_physical_cnt == donor_physical_cnt
Date: Wed, 13 Mar 2013 15:54:22 -0400	[thread overview]
Message-ID: <20130313195422.GG5604@thunk.org> (raw)
In-Reply-To: <1362327978-30423-2-git-send-email-wenqing.lz@taobao.com>

On Mon, Mar 04, 2013 at 12:26:17AM +0800, Zheng Liu wrote:
> From: Zheng Liu <wenqing.lz@taobao.com>
> 
> When orig_physical_cnt == donor_physical_cnt, we need to defrag a file
> because a file could be written backwards.  So that will make it look
> like a contiguous extent but actually the physical blocks are reversed.

The problem with your change is in the case where orig_physical_cnt
and donor_physical_cnt are 1 (i.e., the file is perfectly defragged),
we will still try to swap the extents.

The fundamental problem is that we are using a metric which is flawed;
in the case of the following file:

> File size of /mnt/sda3/testfile is 40960 (10 blocks of 4096 bytes)
>  ext:     logical_offset:        physical_offset: length:   expected: flags:
>    0:        0..       0:      34825..     34825:      1:
>    1:        1..       1:      34824..     34824:      1:      34826:
>    2:        2..       2:      34823..     34823:      1:      34825:
>    3:        3..       3:      34822..     34822:      1:      34824:
>    4:        4..       4:      34821..     34821:      1:      34823:
>    5:        5..       5:      34820..     34820:      1:      34822:
>    6:        6..       6:      34819..     34819:      1:      34821:
>    7:        7..       7:      34818..     34818:      1:      34820:
>    8:        8..       8:      34817..     34817:      1:      34819:
>    9:        9..       9:      34816..     34816:      1:      34818: eof

We should be counting this as having 10 extents, not 1.

   	     	      	      	     		     - Ted

  reply	other threads:[~2013-03-13 19:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-03 16:26 [PATCH 0/2] fixup bugs in e2fsprogs that is reported by xfstests #218 Zheng Liu
2013-03-03 16:26 ` [PATCH 1/2] e4defrag: defrag a file when orig_physical_cnt == donor_physical_cnt Zheng Liu
2013-03-13 19:54   ` Theodore Ts'o [this message]
2013-03-03 16:26 ` [PATCH 2/2] filefrag: count a contiguous extent when both logical and physical blocks are contiguous Zheng Liu
2013-03-13 20:16   ` Theodore Ts'o
2013-03-14 12:54     ` Zheng Liu
2013-03-17 23:11       ` Dave Chinner
2013-03-19 18:44     ` Phillip Susi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130313195422.GG5604@thunk.org \
    --to=tytso@mit.edu \
    --cc=gnehzuil.liu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=wenqing.lz@taobao.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).