If FIEMAP returns a single extent after the first call, no extent
boundary is detected and the first extent is not counted by the
normal mechanism.
In this case, increment nr_extents at the same time the extent is
added to the region table, before returning.
* If the file only has a single extent, no boundary is ever
* detected to trigger addition of the first extent.
*/
- if (fm_ext[i - 1].fe_logical == 0)
+ if (fm_ext[i - 1].fe_logical == 0) {
_stats_add_extent(mem, fm_pending, nr_extents);
+ nr_extents++;
+ }
fiemap->fm_start = (fm_ext[i - 1].fe_logical +
fm_ext[i - 1].fe_length);