| Submitter | Zheng Liu |
|---|---|
| Date | March 3, 2013, 4:26 p.m. |
| Message ID | <1362327978-30423-2-git-send-email-wenqing.lz@taobao.com> |
| Download | mbox | patch |
| Permalink | /patch/224555/ |
| State | New |
| Headers | show |
Comments
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 -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch
diff --git a/misc/e4defrag.c b/misc/e4defrag.c index 4b31d03..ae4e8d8 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -1649,7 +1649,7 @@ check_improvement: } if (file_frags_start <= best || - orig_physical_cnt <= donor_physical_cnt) { + orig_physical_cnt < donor_physical_cnt) { printf("\033[79;0H\033[K[%u/%u]%s:\t%3d%%", defraged_file_count, total_count, file, 100); if (mode_flag & DETAIL)