e4defrag: Use e2p_get_fragscore() for decision of whether to defrag
PATCH v3 4/11 e4defrag: Use e2p_get_fragscore() for decision of whether to defrag
This makes e4defrag use e2p_get_fragscore() to calculate fragmentation score. If the fragmentation score of the original file is non-zero and
the fragmentation score of donor file is zero, e4defrag calls EXT4_IOC_MOVE_EXT ioctl. Because the fragmentation will get better in this case.
e4defrag uses 4096 as the threshold of fragmentation because the bigger threshold(<4096) has little effect on the performance from the following results of my experiment.
METHOD
---
1) Created 4GB fragmented file in 16GB ext4 filesystem. The length of all extents in the created file was the same, and the physical block of each extents was allocated at random.
For examples, when the length of all extents is 512 blocks, filefrag shows the following extent information:
#filefrag -v /mnt/mp1/fragment
Filesystem type is: ef53
File size of /mnt/mp1/fragment is 4294967296 (1048576 blocks, blocksize 4096)
ext logical physical expected length flags
0 0 1852416 512
1 512 1584672 1852927 512
2 1024 644608 1585183 512
3 1536 3760128 645119 511
4 2048 3389952 3760638 512
<snip>
2057 1046016 1066016 3930111 512
2058 1046528 559104 1066527 512
2059 1047040 680960 559615 512
2060 1047552 1175552 681471 512
2061 1048064 2780672 1176063 512 eof /mnt/mp1/fragment: 2062 extents found
2) Read the file by cat command three times, and calculated the average of the read time.
RESULT
---
The following table is its result. It shows that read time is about the same when the length of the extents is bigger than 4096.
ext length | ext num | time (s)
---------------------------------
32768 | 37 | 85.94
16384 | 67 | 85.61
8192 | 131 | 86.60
4096 | 260 | 88.87
2048 | 519 | 95.31
1024 | 1031 | 105.96
512 | 2052 | 124.32
256 | 4120 | 160.44
128 | 8242 | 226.28--- misc/Makefile.in | 4 +-- misc/e4defrag.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 61 insertions(+), 7 deletions(-)
misc/Makefile.in +2 -2
@@ -200,9 +200,9 @@ e2undo.profiled: $(PROFILED_E2UNDO_OBJS) $(PROFILED_DEPLIBS) $(Q) $(CC) $(ALL_LDFLAGS) -g -pg -o e2undo.profiled \ $(PROFILED_E2UNDO_OBJS) $(PROFILED_LIBS) $(LIBINTL) -e4defrag: $(E4DEFRAG_OBJS) $(DEPLIBS) +e4defrag: $(E4DEFRAG_OBJS) $(DEPLIBS) $(DEPLIBS_E2P) $(E) " LD $@" - $(Q) $(CC) $(ALL_LDFLAGS) -o e4defrag $(E4DEFRAG_OBJS) $(LIBS) + $(Q) $(CC) $(ALL_LDFLAGS) -o e4defrag $(E4DEFRAG_OBJS) $(LIBS) $(LIBE2P) e4defrag.profiled: $(PROFILED_E4DEFRAG_OBJS) $(PROFILED_DEPLIBS) $(E) " LD $@"
misc/e4defrag.c +59 -5
134 lines not on this page · raw message