xfs: don't set DAX flag for v2 inodes
diff mbox

Message ID 20170830155517.GI4757@magnolia
State New
Headers show

Commit Message

Darrick J. Wong Aug. 30, 2017, 3:55 p.m. UTC
The DAX flag can only be persisted for v3 inodes, so don't allow users
to set the flag on older filesystems.

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

--
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

Christoph Hellwig Aug. 30, 2017, 4:15 p.m. UTC | #1
How about returning an error from xfs_set_diflags for
anything that would go into di_flags2 for v2 inodes?
--
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
Darrick J. Wong Aug. 30, 2017, 4:22 p.m. UTC | #2
On Wed, Aug 30, 2017 at 09:15:00AM -0700, Christoph Hellwig wrote:
> How about returning an error from xfs_set_diflags for
> anything that would go into di_flags2 for v2 inodes?

I had also thought about refactoring all those xfs_ioctl_setattr_xflags
validity checks into a single separate checking function, how about that?

--D

> --
> 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

Patch
diff mbox

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 9c0c7a9..fa17f89 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1043,6 +1043,10 @@  xfs_ioctl_setattr_xflags(
 	if ((fa->fsx_xflags & FS_XFLAG_DAX) && xfs_is_reflink_inode(ip))
 		return -EINVAL;
 
+	/* Don't allow us to set DAX mode for a non-v3 inode. */
+	if ((fa->fsx_xflags & FS_XFLAG_DAX) && ip->i_d.di_version < 3)
+		return -EINVAL;
+
 	/*
 	 * Can't modify an immutable/append-only file unless
 	 * we have appropriate permission.