Skip to content

Commit 11f4c3a

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: simplify extent lookup in xfs_can_free_eofblocks
xfs_can_free_eofblocks just cares if there is an extent beyond EOF. Replace the call to xfs_bmapi_read with a xfs_iext_lookup_extent as we've already checked that extents are read in earlier. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent b717089 commit 11f4c3a

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

fs/xfs/xfs_bmap_util.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,12 @@ bool
492492
xfs_can_free_eofblocks(
493493
struct xfs_inode *ip)
494494
{
495-
struct xfs_bmbt_irec imap;
496495
struct xfs_mount *mp = ip->i_mount;
496+
bool found_blocks = false;
497497
xfs_fileoff_t end_fsb;
498498
xfs_fileoff_t last_fsb;
499-
int nimaps = 1;
500-
int error;
499+
struct xfs_bmbt_irec imap;
500+
struct xfs_iext_cursor icur;
501501

502502
/*
503503
* Caller must either hold the exclusive io lock; or be inactivating
@@ -544,21 +544,13 @@ xfs_can_free_eofblocks(
544544
return false;
545545

546546
/*
547-
* Look up the mapping for the first block past EOF. If we can't find
548-
* it, there's nothing to free.
547+
* Check if there is an post-EOF extent to free.
549548
*/
550549
xfs_ilock(ip, XFS_ILOCK_SHARED);
551-
error = xfs_bmapi_read(ip, end_fsb, last_fsb - end_fsb, &imap, &nimaps,
552-
0);
550+
if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap))
551+
found_blocks = true;
553552
xfs_iunlock(ip, XFS_ILOCK_SHARED);
554-
if (error || nimaps == 0)
555-
return false;
556-
557-
/*
558-
* If there's a real mapping there or there are delayed allocation
559-
* reservations, then we have post-EOF blocks to try to free.
560-
*/
561-
return imap.br_startblock != HOLESTARTBLOCK || ip->i_delayed_blks;
553+
return found_blocks;
562554
}
563555

564556
/*

0 commit comments

Comments
 (0)