From: Christoph Hellwig Date: Sun, 23 Jun 2024 05:44:27 +0000 (+0200) Subject: xfs: cleanup xfs_ilock_iocb_for_write X-Git-Tag: v6.11-rc1~155^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29bc0dd0a2f6d738fd339826af57cd17f7a39bd9;p=thirdparty%2Fkernel%2Flinux.git xfs: cleanup xfs_ilock_iocb_for_write Move the relock path out of the straight line and add a comment explaining why it exists. 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 b240ea5241dc9..74c2c8d253e69 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -213,14 +213,18 @@ xfs_ilock_iocb_for_write( if (ret) return ret; - if (*lock_mode == XFS_IOLOCK_EXCL) - return 0; - if (!xfs_iflags_test(ip, XFS_IREMAPPING)) - return 0; + /* + * If a reflink remap is in progress we always need to take the iolock + * exclusively to wait for it to finish. + */ + if (*lock_mode == XFS_IOLOCK_SHARED && + xfs_iflags_test(ip, XFS_IREMAPPING)) { + xfs_iunlock(ip, *lock_mode); + *lock_mode = XFS_IOLOCK_EXCL; + return xfs_ilock_iocb(iocb, *lock_mode); + } - xfs_iunlock(ip, *lock_mode); - *lock_mode = XFS_IOLOCK_EXCL; - return xfs_ilock_iocb(iocb, *lock_mode); + return 0; } static unsigned int