xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
PATCH 1/1 xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
From: Darrick J. Wong <[email protected]>
If a file has the S_DAX flag (aka fsdax access mode) set, we cannot allow users to change the realtime flag unless the datadev and rtdev both support fsdax access modes. Even if there are no extents allocated to the file, the setattr thread could be racing with another thread that has already started down the write code paths.
--- fs/xfs/xfs_ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/xfs/xfs_ioctl.c +11 -0
@@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(/* Can't change realtime flag if any extents are allocated. */ if (ip->i_df.if_nextents || ip->i_delayed_blks)return -EINVAL ; + +/* +* If S_DAX is enabled on this file, we can only switch the +* device if both support fsdax. We can't update S_DAX because +* there might be other threads walking down the access paths. +*/ +if (IS_DAX (VFS_I (ip)) && + (mp->m_ddev_targp->bt_daxdev ==NULL || + (mp->m_rtdev_targp && + mp->m_rtdev_targp->bt_daxdev ==NULL ))) +return -EINVAL ; }if (rtflag) {
Looks good:
Quoted 24 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
If a file has the
S_DAXflag (aka fsdax access mode) set, we cannot allow users to change the realtime flag unless the datadev and rtdev both support fsdax access modes. Even if there are no extents allocated to the file, the setattr thread could be racing with another thread that has already started down the write code paths.Fixes ba23cba9b3bdc ("fs: allow per-device dax status checking for filesystems")Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)fs/xfs/xfs_ioctl.c +1
-0@@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(/* Can't change realtime flag if any extents are allocated. */ if (ip->i_df.if_nextents || ip->i_delayed_blks)return -EINVAL ; +
fs/xfs/xfs_ioctl.c xfs_ioctl_setattr_xflags( · line 496
Quoted 10 lines
fs/xfs/xfs_ioctl.c +10
-0+/* +* If S_DAX is enabled on this file, we can only switch the +* device if both support fsdax. We can't update S_DAX because +* there might be other threads walking down the access paths. +*/ +if (IS_DAX (VFS_I (ip)) && + (mp->m_ddev_targp->bt_daxdev ==NULL || + (mp->m_rtdev_targp && + mp->m_rtdev_targp->bt_daxdev ==NULL ))) +return -EINVAL ;
Any chance of mp->m_ddev_targp == NULL ?
Quoted 4 lines
fs/xfs/xfs_ioctl.c +0
-0}if (rtflag) {
Quoted 28 lines · Souptick Joarder
Quoted 27 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
If a file has the
S_DAXflag (aka fsdax access mode) set, we cannot allow users to change the realtime flag unless the datadev and rtdev both support fsdax access modes. Even if there are no extents allocated to the file, the setattr thread could be racing with another thread that has already started down the write code paths.Fixes ba23cba9b3bdc ("fs: allow per-device dax status checking for filesystems")Signed-off-by Darrick J. Wong <[email protected]>--- fs/xfs/xfs_ioctl.c | 11 +++++++++++ 1 file changed, 11 insertions(+)fs/xfs/xfs_ioctl.c +4
-0@@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(/* Can't change realtime flag if any extents are allocated. */ if (ip->i_df.if_nextents || ip->i_delayed_blks)return -EINVAL ; + +/* +* If S_DAX is enabled on this file, we can only switch the +* device if both support fsdax. We can't update S_DAX because
Quoted 8 lines
fs/xfs/xfs_ioctl.c xfs_ioctl_setattr_xflags( · line 496
Quoted 7 lines
fs/xfs/xfs_ioctl.c +7
-0+* there might be other threads walking down the access paths. +*/ +if (IS_DAX (VFS_I (ip)) && + (mp->m_ddev_targp->bt_daxdev ==NULL || + (mp->m_rtdev_targp && + mp->m_rtdev_targp->bt_daxdev ==NULL ))) +return -EINVAL ;Any chance of
mp->m_ddev_targp== NULL ?
No, m_ddev_targp is the device you give to mount. e.g. if you do
# mount /dev/sda /mnt
then m_ddev_targp is the block_device /dev/sda.
--D
Quoted 4 lines
Quoted 4 lines
fs/xfs/xfs_ioctl.c +0
-0}if (rtflag) {