Whamcloud - gitweb
filefrag: fix fm_start in filefrag_fiemap loop
authorPeng Tao <bergwolf@gmail.com>
Thu, 2 Jul 2009 04:24:15 +0000 (00:24 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 2 Jul 2009 04:24:15 +0000 (00:24 -0400)
commitf97ea10fde6d8bee670d388f02cf9524b8f2d7da
tree58ff3fce418bd6c2e48dcb3f52a9608b92b86066
parentca4d95a9328af89a9f8fa490fc37115eb80524ba
filefrag: fix fm_start in filefrag_fiemap loop

When used with -v and the targeted file has more than 144
extents(double of the length of fm_extents array provided by buf),
filefrag_fiemap loops and calls fiemap ioctl() multiple times to
calculate the actual number of extents in a file. Each call to fiemap
ioctl() uses fm_start as the starting logical offset. The patch fixes
fm_start in each loop( except for the first one) and makes the extent
calculation correct for files with more that 144 extents.

To produce the problem, first run filefrag -v on a highly fragmented
file.  Then change the buf size in filefrag_fiemap to make it large
enough to have all the extent mapped in a single loop and run filefrag
-v after recompiling.  The former will produce a much smaller extent
count because of the false fm_start used in the loop. And the two will
produce different extent output since the 145th extent.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/filefrag.c