mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
xfs: introduce the xfs_iext_cursor abstraction
Add a new xfs_iext_cursor structure to hide the direct extent map index manipulations. In addition to the existing lookup/get/insert/ remove and update routines new primitives to get the first and last extent cursor, as well as moving up and down by one extent are provided. Also new are convenience to increment/decrement the cursor and retreive the new extent, as well as to peek into the previous/next extent without updating the cursor and last but not least a macro to iterate over all extents in a fork. [darrick: rename for_each_iext to for_each_xfs_iext] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:
committed by
Darrick J. Wong
parent
906abed501
commit
b2b1712a64
@@ -229,15 +229,17 @@ xfs_bmap_count_leaves(
|
||||
struct xfs_ifork *ifp,
|
||||
xfs_filblks_t *count)
|
||||
{
|
||||
struct xfs_iext_cursor icur;
|
||||
struct xfs_bmbt_irec got;
|
||||
xfs_extnum_t numrecs = 0, i = 0;
|
||||
xfs_extnum_t numrecs = 0;
|
||||
|
||||
while (xfs_iext_get_extent(ifp, i++, &got)) {
|
||||
for_each_xfs_iext(ifp, &icur, &got) {
|
||||
if (!isnullstartblock(got.br_startblock)) {
|
||||
*count += got.br_blockcount;
|
||||
numrecs++;
|
||||
}
|
||||
}
|
||||
|
||||
return numrecs;
|
||||
}
|
||||
|
||||
@@ -525,7 +527,7 @@ xfs_getbmap(
|
||||
struct xfs_ifork *ifp;
|
||||
struct xfs_bmbt_irec got, rec;
|
||||
xfs_filblks_t len;
|
||||
xfs_extnum_t idx;
|
||||
struct xfs_iext_cursor icur;
|
||||
|
||||
if (bmv->bmv_iflags & ~BMV_IF_VALID)
|
||||
return -EINVAL;
|
||||
@@ -629,7 +631,7 @@ xfs_getbmap(
|
||||
goto out_unlock_ilock;
|
||||
}
|
||||
|
||||
if (!xfs_iext_lookup_extent(ip, ifp, bno, &idx, &got)) {
|
||||
if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
|
||||
/*
|
||||
* Report a whole-file hole if the delalloc flag is set to
|
||||
* stay compatible with the old implementation.
|
||||
@@ -668,7 +670,7 @@ xfs_getbmap(
|
||||
goto out_unlock_ilock;
|
||||
} while (xfs_getbmap_next_rec(&rec, bno));
|
||||
|
||||
if (!xfs_iext_get_extent(ifp, ++idx, &got)) {
|
||||
if (!xfs_iext_next_extent(ifp, &icur, &got)) {
|
||||
xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
|
||||
|
||||
out[bmv->bmv_entries - 1].bmv_oflags |= BMV_OF_LAST;
|
||||
|
||||
Reference in New Issue
Block a user