Skip to content

Commit 1c37441

Browse files
djwonggregkh
authored andcommitted
xfs: force the log after remapping a synchronous-writes file
[ Upstream commit 5ffce3c ] Commit 5833112 tried to make it so that a remap operation would force the log out to disk if the filesystem is mounted with mandatory synchronous writes. Unfortunately, that commit failed to handle the case where the inode or the file descriptor require mandatory synchronous writes. Refactor the check into into a helper that will look for all three conditions, and now we can treat reflink just like any other synchronous write. Fixes: 5833112 ("xfs: reflink should force the log out if mounted with wsync") Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2826999 commit 1c37441

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎fs/xfs/xfs_file.c‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,21 @@ xfs_file_fadvise(
10081008
return ret;
10091009
}
10101010

1011+
/* Does this file, inode, or mount want synchronous writes? */
1012+
static inline bool xfs_file_sync_writes(struct file *filp)
1013+
{
1014+
struct xfs_inode *ip = XFS_I(file_inode(filp));
1015+
1016+
if (ip->i_mount->m_flags & XFS_MOUNT_WSYNC)
1017+
return true;
1018+
if (filp->f_flags & (__O_SYNC | O_DSYNC))
1019+
return true;
1020+
if (IS_SYNC(file_inode(filp)))
1021+
return true;
1022+
1023+
return false;
1024+
}
1025+
10111026
STATIC loff_t
10121027
xfs_file_remap_range(
10131028
struct file *file_in,
@@ -1065,7 +1080,7 @@ xfs_file_remap_range(
10651080
if (ret)
10661081
goto out_unlock;
10671082

1068-
if (mp->m_flags & XFS_MOUNT_WSYNC)
1083+
if (xfs_file_sync_writes(file_in) || xfs_file_sync_writes(file_out))
10691084
xfs_log_force_inode(dest);
10701085
out_unlock:
10711086
xfs_iunlock2_io_mmap(src, dest);

0 commit comments

Comments
 (0)