* [PATCH] xfs: don't forbid setting dax flag on directories if device doesn't dax
@ 2018-05-31 22:19 Darrick J. Wong
0 siblings, 0 replies; only message in thread
From: Darrick J. Wong @ 2018-05-31 22:19 UTC (permalink / raw)
To: xfs
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(-)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 3d72dfc9c83f..78b2e29ffae3 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1086,12 +1086,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;
}
@@ -1102,6 +1104,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);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-05-31 22:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-31 22:19 [PATCH] xfs: don't forbid setting dax flag on directories if device doesn't dax Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox