@@ -1180,10 +1180,6 @@ xfs_ioctl_setattr_dax_invalidate(
*join_flags = 0;
- if ((fa->fsx_xflags & FS_XFLAG_DAX) == FS_XFLAG_DAX &&
- !xfs_inode_supports_dax(ip))
- return -EINVAL;
-
/* If the DAX state is not changing, we have nothing to do here. */
if ((fa->fsx_xflags & FS_XFLAG_DAX) &&
(ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
@@ -1197,6 +1193,13 @@ xfs_ioctl_setattr_dax_invalidate(
/* lock, flush and invalidate mapping in preparation for flag change */
xfs_ilock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL);
+
+ if ((fa->fsx_xflags & FS_XFLAG_DAX) == FS_XFLAG_DAX &&
+ !xfs_inode_supports_dax(ip)) {
+ error = -EINVAL;
+ goto out_unlock;
+ }
+
error = filemap_write_and_wait(inode->i_mapping);
if (error)
goto out_unlock;