xfs
[Top] [All Lists]

[PATCH 1/4] xfs: XFS_DIFLAG_DAX is only for regular files or directories

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/4] xfs: XFS_DIFLAG_DAX is only for regular files or directories
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Mon, 15 Feb 2016 16:22:11 +1100
Cc: ross.zwisler@xxxxxxxxxxxxxxx, jack@xxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1455513734-15192-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1455513734-15192-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Only file data can use DAX, so we should onyl be able to set this
flag on regular files. However, the flag also serves as an "inherit"
flag at file create time when set on directories, so limit the
FS_IOC_FSSETXATTR ioctl to only set this flag on regular files and
directories.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/xfs_ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 81d6d62..0895967 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1051,6 +1051,14 @@ xfs_ioctl_setattr_xflags(
            !capable(CAP_LINUX_IMMUTABLE))
                return -EPERM;
 
+       /*
+        * It is only valid to set the DAX flag on regular files and
+        * directories. On directories it serves as an inherit hint.
+        */
+       if ((fa->fsx_xflags & FS_XFLAG_DAX) &&
+           !(S_ISREG(VFS_I(ip)->i_mode) || S_ISDIR(VFS_I(ip)->i_mode)))
+               return -EINVAL;
+
        xfs_set_diflags(ip, fa->fsx_xflags);
        xfs_diflags_to_linux(ip);
        xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
-- 
2.5.0

<Prev in Thread] Current Thread [Next in Thread>