Skip to content

Commit 8d16762

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: conditionally allow FS_XFLAG_REALTIME changes if S_DAX is set
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. Fixes: ba23cba ("fs: allow per-device dax status checking for filesystems") Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent 04d6dbb commit 8d16762

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

fs/xfs/xfs_ioctl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,17 @@ xfs_ioctl_setattr_xflags(
483483
/* Can't change realtime flag if any extents are allocated. */
484484
if (ip->i_df.if_nextents || ip->i_delayed_blks)
485485
return -EINVAL;
486+
487+
/*
488+
* If S_DAX is enabled on this file, we can only switch the
489+
* device if both support fsdax. We can't update S_DAX because
490+
* there might be other threads walking down the access paths.
491+
*/
492+
if (IS_DAX(VFS_I(ip)) &&
493+
(mp->m_ddev_targp->bt_daxdev == NULL ||
494+
(mp->m_rtdev_targp &&
495+
mp->m_rtdev_targp->bt_daxdev == NULL)))
496+
return -EINVAL;
486497
}
487498

488499
if (rtflag) {

0 commit comments

Comments
 (0)