There are a few problems with the new xfs_bmap_search_multi_extents()
wrapper function that I introduced in mod xfs-linux:xfs-kern:207393a.
The function was added as a wrapper around xfs_bmap_do_search_extents()
to avoid breaking the top-of-tree CXFS interface. The idea of the
function was basically to extract the target extent buffer (if muli-
level extent allocation mode), then call xfs_bmap_do_search_extents()
with either a pointer to the first extent in the target buffer or a
pointer to the first extent in the file, depending on which extent
mode was being used. However, in addition to locating the target
extent record for block bno, xfs_bmap_do_search_extents() also sets
four parameters needed by the caller: *lastx, *eofp, *gotp, *prevp.
Passing only the target extent buffer to xfs_bmap_do_search_extents()
causes *eofp to be set incorrectly if the extent is at the end of the
target list but there are actually more extents in the next er_extbuf.
Likewise, if the extent is the first one in the buffer but NOT the
first in the file, *prevp is incorrectly set to NULL. Adding the
needed functionality to xfs_bmap_search_multi_extents() to re-set
any incorrectly set fields is redundant and makes the call to
xfs_bmap_do_search_extents() not make much sense when multi-level
extent allocation mode is being used.
This mod basically extracts the two functional components from
xfs_bmap_do_search_extents(), with the intent of obsoleting/removing
xfs_bmap_do_search_extents() after the CXFS mult-level in-core extent
changes are checked in. The two components are: 1) The binary search
to locate the target extent record, and 2) Setting the four parameters
needed by the caller (*lastx, *eofp, *gotp, *prevp).
I created a new function in xfs_inode.c called xfs_iext_bno_to_ext(),
which executes the binary search to find the target extent record.
xfs_bmap_search_multi_extents() has been modified to call
xfs_iext_bno_to_ext() rather than xfs_bmap_do_search_extents().
The parameter setting functionality has been added to
xfs_bmap_search_multi_extents(), eliminating the need for
These changes make the removal of xfs_bmap_do_search_extents() trival
once the CXFS changes are in place. They also allow us to maintain
the current XFS interface, using the new search function introduced
in mod xfs-linux:xfs-kern:207393a.
Date: Tue Mar 14 13:49:17 PST 2006
Inspected by: nathans,cattelan
The following file(s) were checked into:
fs/xfs/xfs_inode.c - 1.428 - changed
- Add new binary search function, xfs_iext_bno_to_ext(), which finds
and returns a pointer to the target extent record for block bno.
xfs_iext_bno_to_ext() takes a pointer to an xfs_ifork_t rather than
a pointer to the first xfs_bmbt_rec_t extent record so the target
extent record can be found in both linear and indirect extent
fs/xfs/xfs_inode.h - 1.210 - changed
- Add prototype for new search function, xfs_iext_bno_to_ext().
fs/xfs/xfs_bmap.c - 1.345 - changed
- Modify xfs_bmap_search_multi_extents() to call the new
xfs_iext_bno_to_ext() binary search function, then set the
four parameters needed by the caller. Remove the call to
xfs_bmap_do_search_extents(), which will eventually be removed.