From: Christoph Hellwig Date: Tue, 13 Aug 2024 07:39:40 +0000 (+0200) Subject: xfs: check XFS_EOFBLOCKS_RELEASED earlier in xfs_release_eofblocks X-Git-Tag: v6.12-rc1~138^2~12 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b717089efe47bb0894d3deb016fecfc09ae586c6;p=thirdparty%2Flinux.git xfs: check XFS_EOFBLOCKS_RELEASED earlier in xfs_release_eofblocks If the XFS_EOFBLOCKS_RELEASED flag is set, we are not going to free the eofblocks, so don't bother locking the inode or performing the checks in xfs_can_free_eofblocks. Also switch to a test_and_set operation once the iolock has been acquire so that only the caller that sets it actually frees the post-EOF blocks. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 30b553ac8f56b..986448d1ff3c0 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -1234,12 +1234,11 @@ xfs_file_release( */ if (inode->i_nlink && (file->f_mode & FMODE_WRITE) && + !xfs_iflags_test(ip, XFS_EOFBLOCKS_RELEASED) && xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) { if (xfs_can_free_eofblocks(ip) && - !xfs_iflags_test(ip, XFS_EOFBLOCKS_RELEASED)) { + !xfs_iflags_test_and_set(ip, XFS_EOFBLOCKS_RELEASED)) xfs_free_eofblocks(ip); - xfs_iflags_set(ip, XFS_EOFBLOCKS_RELEASED); - } xfs_iunlock(ip, XFS_IOLOCK_EXCL); }