Skip to content

Commit cea267c

Browse files
Dave ChinnerDarrick J. Wong
authored andcommitted
xfs: ensure log flush at the end of a synchronous fallocate call
Since we've started treating fallocate more like a file write, we should flush the log to disk if the user has asked for synchronous writes either by setting it via fcntl flags, or inode flags, or with the sync mount option. We've already got a helper for this, so use it. [The original patch by Darrick was massaged by Dave to fit this patchset] Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
1 parent b39a046 commit cea267c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

fs/xfs/xfs_file.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,21 @@ xfs_break_layouts(
861861
return error;
862862
}
863863

864+
/* Does this file, inode, or mount want synchronous writes? */
865+
static inline bool xfs_file_sync_writes(struct file *filp)
866+
{
867+
struct xfs_inode *ip = XFS_I(file_inode(filp));
868+
869+
if (xfs_has_wsync(ip->i_mount))
870+
return true;
871+
if (filp->f_flags & (__O_SYNC | O_DSYNC))
872+
return true;
873+
if (IS_SYNC(file_inode(filp)))
874+
return true;
875+
876+
return false;
877+
}
878+
864879
#define XFS_FALLOC_FL_SUPPORTED \
865880
(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | \
866881
FALLOC_FL_COLLAPSE_RANGE | FALLOC_FL_ZERO_RANGE | \
@@ -1048,7 +1063,7 @@ xfs_file_fallocate(
10481063
goto out_unlock;
10491064
}
10501065

1051-
if (file->f_flags & O_DSYNC)
1066+
if (xfs_file_sync_writes(file))
10521067
error = xfs_log_force_inode(ip);
10531068

10541069
out_unlock:
@@ -1081,21 +1096,6 @@ xfs_file_fadvise(
10811096
return ret;
10821097
}
10831098

1084-
/* Does this file, inode, or mount want synchronous writes? */
1085-
static inline bool xfs_file_sync_writes(struct file *filp)
1086-
{
1087-
struct xfs_inode *ip = XFS_I(file_inode(filp));
1088-
1089-
if (xfs_has_wsync(ip->i_mount))
1090-
return true;
1091-
if (filp->f_flags & (__O_SYNC | O_DSYNC))
1092-
return true;
1093-
if (IS_SYNC(file_inode(filp)))
1094-
return true;
1095-
1096-
return false;
1097-
}
1098-
10991099
STATIC loff_t
11001100
xfs_file_remap_range(
11011101
struct file *file_in,

0 commit comments

Comments
 (0)