aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-29 18:44:14 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2017-09-01 16:08:26 -0400
commite17a5c6f0e3609da83270f42698b1dfedde86f44 (patch)
tree06e618698006a524252781215dc293a832d59abf
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>
-rw-r--r--fs/xfs/xfs_bmap_util.c21
-rw-r--r--fs/xfs/xfs_bmap_util.h1
2 files changed, 11 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(
222 * Count leaf blocks given a range of extent records. Delayed allocation 222 * Count leaf blocks given a range of extent records. Delayed allocation
223 * extents are not counted towards the totals. 223 * extents are not counted towards the totals.
224 */ 224 */
225STATIC void 225xfs_extnum_t
226xfs_bmap_count_leaves( 226xfs_bmap_count_leaves(
227 struct xfs_ifork *ifp, 227 struct xfs_ifork *ifp,
228 xfs_extnum_t *numrecs,
229 xfs_filblks_t *count) 228 xfs_filblks_t *count)
230{ 229{
231 xfs_extnum_t i; 230 struct xfs_bmbt_irec got;
232 xfs_extnum_t nr_exts = xfs_iext_count(ifp); 231 xfs_extnum_t numrecs = 0, i = 0;
233 232
234 for (i = 0; i < nr_exts; i++) { 233 while (xfs_iext_get_extent(ifp, i++, &got)) {
235 xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, i); 234 if (!isnullstartblock(got.br_startblock)) {
236 if (!isnullstartblock(xfs_bmbt_get_startblock(frp))) { 235 *count += got.br_blockcount;
237 (*numrecs)++; 236 numrecs++;
238 *count += xfs_bmbt_get_blockcount(frp);
239 } 237 }
240 } 238 }
239 return numrecs;
241} 240}
242 241
243/* 242/*
@@ -370,7 +369,7 @@ xfs_bmap_count_blocks(
370 369
371 switch (XFS_IFORK_FORMAT(ip, whichfork)) { 370 switch (XFS_IFORK_FORMAT(ip, whichfork)) {
372 case XFS_DINODE_FMT_EXTENTS: 371 case XFS_DINODE_FMT_EXTENTS:
373 xfs_bmap_count_leaves(ifp, nextents, count); 372 *nextents = xfs_bmap_count_leaves(ifp, count);
374 return 0; 373 return 0;
375 case XFS_DINODE_FMT_BTREE: 374 case XFS_DINODE_FMT_BTREE:
376 if (!(ifp->if_flags & XFS_IFEXTENTS)) { 375 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h
index 0cede1043571..0eaa81dc49be 100644
--- a/fs/xfs/xfs_bmap_util.h
+++ b/fs/xfs/xfs_bmap_util.h
@@ -70,6 +70,7 @@ int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,
70 70
71xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb); 71xfs_daddr_t xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb);
72 72
73xfs_extnum_t xfs_bmap_count_leaves(struct xfs_ifork *ifp, xfs_filblks_t *count);
73int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, 74int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip,
74 int whichfork, xfs_extnum_t *nextents, 75 int whichfork, xfs_extnum_t *nextents,
75 xfs_filblks_t *count); 76 xfs_filblks_t *count);