xfs: S_DAX is only for regular files
authorDave Chinner <dchinner@redhat.com>
Mon, 29 Feb 2016 22:41:33 +0000 (09:41 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 29 Feb 2016 22:41:33 +0000 (09:41 +1100)
Only regular files can use DAX for data operations, so we should
restrict setting it on the VFS inode to regular files. Setting it on
metadata inodes may cause the VFS to do the wrong thing for such
inodes, so avoid potential problems by restricting the scope of the
flag to what we know is supported.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Tested-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_iops.c

index 76b71a1c6c323e2043aeab1e93fb5a66db9f39d0..5d4f9739d4a4c86fafbd37fa04be4336ed40f8a3 100644 (file)
@@ -1205,8 +1205,9 @@ xfs_diflags_to_iflags(
                inode->i_flags |= S_SYNC;
        if (flags & XFS_DIFLAG_NOATIME)
                inode->i_flags |= S_NOATIME;
-       if (ip->i_mount->m_flags & XFS_MOUNT_DAX ||
-           ip->i_d.di_flags2 & XFS_DIFLAG2_DAX)
+       if (S_ISREG(inode->i_mode) &&
+           (ip->i_mount->m_flags & XFS_MOUNT_DAX ||
+            ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
                inode->i_flags |= S_DAX;
 }