diff options
author | Christoph Hellwig <hch@lst.de> | 2017-11-03 20:34:43 +0300 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2017-11-06 22:53:40 +0300 |
commit | b2b1712a640824e7c131bfdd2585d57bf8ccb39a (patch) | |
tree | ad756c7caa0bb7252aaf444b077c518e0a5d9f0f /fs/xfs/xfs_bmap_util.c | |
parent | 906abed501bf5a2103946deb7a4a40b31c56f027 (diff) | |
download | linux-b2b1712a640824e7c131bfdd2585d57bf8ccb39a.tar.xz |
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>
Diffstat (limited to 'fs/xfs/xfs_bmap_util.c')
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 170b74c7f2d5..e748309e327d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -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; |