summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_bmap_util.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-29 15:44:14 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2017-09-01 13:08:26 -0700
commite17a5c6f0e3609da83270f42698b1dfedde86f44 (patch)
tree06e618698006a524252781215dc293a832d59abf /fs/xfs/xfs_bmap_util.c
parent4c35445b591ee669097c5b98e4bb677808e9f582 (diff)
xfs: rewrite xfs_bmap_count_leaves using xfs_iext_get_extent
This avoids poking into the internals of the extent list. Also return the number of extents as the return value instead of an additional by reference argument, and make it available to callers outside of xfs_bmap_util.c Signed-off-by: Christoph Hellwig <hch@lst.de> 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.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 8661be0aacaa..cd9a5400ba4f 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -222,22 +222,21 @@ xfs_bmap_eof(
* Count leaf blocks given a range of extent records. Delayed allocation
* extents are not counted towards the totals.
*/
-STATIC void
+xfs_extnum_t
xfs_bmap_count_leaves(
struct xfs_ifork *ifp,
- xfs_extnum_t *numrecs,
xfs_filblks_t *count)
{
- xfs_extnum_t i;
- xfs_extnum_t nr_exts = xfs_iext_count(ifp);
-
- for (i = 0; i < nr_exts; i++) {
- xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, i);
- if (!isnullstartblock(xfs_bmbt_get_startblock(frp))) {
- (*numrecs)++;
- *count += xfs_bmbt_get_blockcount(frp);
+ struct xfs_bmbt_irec got;
+ xfs_extnum_t numrecs = 0, i = 0;
+
+ while (xfs_iext_get_extent(ifp, i++, &got)) {
+ if (!isnullstartblock(got.br_startblock)) {
+ *count += got.br_blockcount;
+ numrecs++;
}
}
+ return numrecs;
}
/*
@@ -370,7 +369,7 @@ xfs_bmap_count_blocks(
switch (XFS_IFORK_FORMAT(ip, whichfork)) {
case XFS_DINODE_FMT_EXTENTS:
- xfs_bmap_count_leaves(ifp, nextents, count);
+ *nextents = xfs_bmap_count_leaves(ifp, count);
return 0;
case XFS_DINODE_FMT_BTREE:
if (!(ifp->if_flags & XFS_IFEXTENTS)) {