Message ID | 20241002145921.GA21853@frogsfrogsfrogs (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | xfs: fix simplify extent lookup in xfs_can_free_eofblocks | expand |
> + if (ip->i_delayed_blks) > + found_blocks = true; > + else if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) > found_blocks = true; This could be simplified a little bit by doing: if (ip->i_delayed_blks || xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) found_blocks = true; but otherwise looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Wed, Oct 02, 2024 at 08:11:17AM -0700, Christoph Hellwig wrote: > > + if (ip->i_delayed_blks) > > + found_blocks = true; > > + else if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) > > found_blocks = true; > > This could be simplified a little bit by doing: > > if (ip->i_delayed_blks || > xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) > found_blocks = true; > > but otherwise looks good: Oops, heh, I thought I'd forgotten something. :( V2 soon, though really there's a pile more fsdax corruption fixes so heh. > Reviewed-by: Christoph Hellwig <hch@lst.de> Thanks! --D
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 053d567c91084..b0e0f83ff348a 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -542,10 +542,15 @@ xfs_can_free_eofblocks( return false; /* - * Check if there is an post-EOF extent to free. + * Check if there is an post-EOF extent to free. If there are any + * delalloc blocks attached to the inode (data fork delalloc + * reservations or CoW extents of any kind), we need to free them so + * that inactivation doesn't fail to erase them. */ xfs_ilock(ip, XFS_ILOCK_SHARED); - if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) + if (ip->i_delayed_blks) + found_blocks = true; + else if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) found_blocks = true; xfs_iunlock(ip, XFS_ILOCK_SHARED); return found_blocks;