This is the v5 patch set for xfs_seek_data/xfs_seek_hole refinements with lookup
the offset from page cache for desired type.
I split those changes to 4 patches this time, maybe it could facilitate the
* Introduce a new routine xfs_find_get_desired_pgoff() to search the desired
offset from page cache
for unwritten and delayed-allocation extents. This function is mainly based
on the original xfs_has_unwritten_buffer() but
revised to be able to fetch a hole offset directly for the refinement of
* Remove type argument from xfs_seek_data()/xfs_seek_hole() as it is already
indicated by those function naming explicitly.
xfs_seek_hole() refinement, suggested by Mark and Christoph.
* refine xfs_seek_hole() with unwritten extents search, treat it as a hole if
no data buffer was found from page cache.
* s/goto out/break/g, break out of the extent maps reading loop rather than 'go
to', I must have got my head up in the clouds when writing v3.
* xfs_has_unwritten_buffer(), remove 'offset <= XFS_FSB_TO_B(mp, last))' from
BH state checking branch.
The page index offset might less than '*start', so we will miss a data extent
* xfs_has_unwritten_buffer(), don't reset '*offset' to ZERO if no data buffer
was found because of xfs_seek_hole() will call this function to
examine an unwritten extent has data or not. If not, it will use the
returned '*offset' as a hole offset. So set '*offset' to zero in
xfs_has_unwritten_buffer() will lead to wrong result.
* avoid re-starting the next round search in both xfs_seek_data() and
xfs_seek_hole() if the end offset of the 2nd extent map is hit the EOF.
So for SEEK_DATA, it means there is no data extent beyond the current offset
and return ENXIO, for SEEK_HOLE, return the file size to
indicate hitting EOF. The comments were also changed(s/reading offset not
beyond/reading offset not beyond or hit EOF/)accordingly.
Tested by Mark, hit BUG() for continuous unwritten extents without data wrote.
* xfs_seek_data(), remove BUG() and having extents map search in loop.
suggested by Mark.
* xfs_has_unwritten_buffer(), use the input offset instead of bmap->br_startoff
to calculate page index for data buffer probing.