Skip to content

Commit 21ab13a

Browse files
Andy Strohmangregkh
authored andcommitted
xfs: flush for older, xfs specific ioctls
837a6e7 ("fs: add generic UNRESVSP and ZERO_RANGE ioctl handlers") changed ioctls XFS_IOC_UNRESVSP XFS_IOC_UNRESVSP64 and XFS_IOC_ZERO_RANGE to be generic instead of xfs specific. Because of this change, 36f1177 ("xfs: properly serialise fallocate against AIO+DIO") needed adaptation, as 5.4 still uses the xfs specific ioctls. Without this, xfstests xfs/242 and xfs/290 fail. Both of these tests test XFS_IOC_ZERO_RANGE. Fixes: 36f1177 ("xfs: properly serialise fallocate against AIO+DIO") Tested-by: Andy Strohman <astroh@amazon.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 258d01b commit 21ab13a

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

fs/xfs/xfs_ioctl.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ xfs_ioc_space(
622622
error = xfs_break_layouts(inode, &iolock, BREAK_UNMAP);
623623
if (error)
624624
goto out_unlock;
625-
inode_dio_wait(inode);
626625

627626
switch (bf->l_whence) {
628627
case 0: /*SEEK_SET*/
@@ -668,6 +667,31 @@ xfs_ioc_space(
668667
goto out_unlock;
669668
}
670669

670+
/*
671+
* Must wait for all AIO to complete before we continue as AIO can
672+
* change the file size on completion without holding any locks we
673+
* currently hold. We must do this first because AIO can update both
674+
* the on disk and in memory inode sizes, and the operations that follow
675+
* require the in-memory size to be fully up-to-date.
676+
*/
677+
inode_dio_wait(inode);
678+
679+
/*
680+
* Now that AIO and DIO has drained we can flush and (if necessary)
681+
* invalidate the cached range over the first operation we are about to
682+
* run. We include zero range here because it starts with a hole punch
683+
* over the target range.
684+
*/
685+
switch (cmd) {
686+
case XFS_IOC_ZERO_RANGE:
687+
case XFS_IOC_UNRESVSP:
688+
case XFS_IOC_UNRESVSP64:
689+
error = xfs_flush_unmap_range(ip, bf->l_start, bf->l_len);
690+
if (error)
691+
goto out_unlock;
692+
break;
693+
}
694+
671695
switch (cmd) {
672696
case XFS_IOC_ZERO_RANGE:
673697
flags |= XFS_PREALLOC_SET;

0 commit comments

Comments
 (0)