diff mbox

[01/10] xfs: don't forbid setting dax flag on directories if device doesn't dax

Message ID 152806814871.18187.4240645095990301961.stgit@magnolia (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong June 3, 2018, 11:22 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

On a directory, the DAX flag is merely a hint that files created in the
directory should have the DAX flag set at creation time.  We don't care
if the underlying device supports DAX or not because directory metadata
are always cached in DRAM.  We don't care if new files get the flag even
if the device doesn't support DAX because we always check for DAX
support before setting the VFS flag (S_DAX).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_ioctl.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dave Chinner June 3, 2018, 11:41 p.m. UTC | #1
On Sun, Jun 03, 2018 at 04:22:28PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> On a directory, the DAX flag is merely a hint that files created in the
> directory should have the DAX flag set at creation time.  We don't care
> if the underlying device supports DAX or not because directory metadata
> are always cached in DRAM.  We don't care if new files get the flag even
> if the device doesn't support DAX because we always check for DAX
> support before setting the VFS flag (S_DAX).
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Am I correct in assuming this allows directory hints to work on
a filesystem with a DAX capable RT device, but a normal data device?

Regardless, behaviour seems sensible to me.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Darrick J. Wong June 4, 2018, 4:25 a.m. UTC | #2
On Mon, Jun 04, 2018 at 09:41:36AM +1000, Dave Chinner wrote:
> On Sun, Jun 03, 2018 at 04:22:28PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > On a directory, the DAX flag is merely a hint that files created in the
> > directory should have the DAX flag set at creation time.  We don't care
> > if the underlying device supports DAX or not because directory metadata
> > are always cached in DRAM.  We don't care if new files get the flag even
> > if the device doesn't support DAX because we always check for DAX
> > support before setting the VFS flag (S_DAX).
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Am I correct in assuming this allows directory hints to work on
> a filesystem with a DAX capable RT device, but a normal data device?

Correct.

--D

> Regardless, behaviour seems sensible to me.
> 
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 5dd9e22b4a4c..82f7c83c1dad 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1098,12 +1098,14 @@  xfs_ioctl_setattr_dax_invalidate(
 	/*
 	 * It is only valid to set the DAX flag on regular files and
 	 * directories on filesystems where the block size is equal to the page
-	 * size. On directories it serves as an inherit hint.
+	 * size. On directories it serves as an inherited hint so we don't
+	 * have to check the device for dax support or flush pagecache.
 	 */
 	if (fa->fsx_xflags & FS_XFLAG_DAX) {
 		if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
 			return -EINVAL;
-		if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
+		if (S_ISREG(inode->i_mode) &&
+		    !bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
 				sb->s_blocksize))
 			return -EINVAL;
 	}
@@ -1114,6 +1116,9 @@  xfs_ioctl_setattr_dax_invalidate(
 	if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode))
 		return 0;
 
+	if (S_ISDIR(inode->i_mode))
+		return 0;
+
 	/* lock, flush and invalidate mapping in preparation for flag change */
 	xfs_ilock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL);
 	error = filemap_write_and_wait(inode->i_mapping);