OSDN Git Service

filefrag: accommodate holes when calculating expected values
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 6 Mar 2016 01:01:35 +0000 (20:01 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 7 Mar 2016 01:08:53 +0000 (20:08 -0500)
commit84244683c03a6602e91043271206652a40149775
tree80bbfaedef8c6fdf9e51edb2e3e6917708e4f644
parent2b8772f522be1c82c92e7e0401126808431d06a2
filefrag: accommodate holes when calculating expected values

Currently, filefrag's "expected physical block" column expects extent
records to be physically adjacent regardless of the amount of logical
block space between the two records.  This means that if we punch a
hole in a file, we get reports like this:

ext:   logical_offset:   physical_offset: length:  expected: flags:
4:     4096..    8343:   57376..  61623:   4248:
5:     8345..   10313:   61625..  63593:   1969:   61624:

Notice how it expects 8345 to map to 61624, and scores this against
the fragmentation of the file.  Flagging this as "unexpected" is
incorrect because the gap in the logical mapping is exactly the same
size as the gap in the physical extents.

Furthermore, this particular mapping leaves the door open to the
optimal mapping -- if a write to block 8344 causes it to be mapped to
61624, the entire range 4096-10313 can be mapped with a single extent.
Until that happens, there's no way to combine extents 4 and 5 because
of the gap in the logical mapping at block 8344.

Therefore, tweak the extent report to account for holes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/filefrag.c