Skip to content

Commit

Permalink
xfs: force the log after remapping a synchronous-writes file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
djwong committed Sep 16, 2020
1 parent e01b7ee commit 5ffce3c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion fs/xfs/xfs_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,21 @@ xfs_file_fadvise(
return ret;
}

/* Does this file, inode, or mount want synchronous writes? */
static inline bool xfs_file_sync_writes(struct file *filp)
{
struct xfs_inode *ip = XFS_I(file_inode(filp));

if (ip->i_mount->m_flags & XFS_MOUNT_WSYNC)
return true;
if (filp->f_flags & (__O_SYNC | O_DSYNC))
return true;
if (IS_SYNC(file_inode(filp)))
return true;

return false;
}

STATIC loff_t
xfs_file_remap_range(
struct file *file_in,
Expand Down Expand Up @@ -1065,7 +1080,7 @@ xfs_file_remap_range(
if (ret)
goto out_unlock;

if (mp->m_flags & XFS_MOUNT_WSYNC)
if (xfs_file_sync_writes(file_in) || xfs_file_sync_writes(file_out))
xfs_log_force_inode(dest);
out_unlock:
xfs_iunlock2_io_mmap(src, dest);
Expand Down

0 comments on commit 5ffce3c

Please sign in to comment.