diff mbox series

[v5,3/3] xfs: reject removal of realtime flag when datadev doesn't support DAX

Message ID 151873085471.53899.4916392112937742603.stgit@djiang5-desk3.ch.intel.com
State Not Applicable, archived
Headers show
Series minimal DAX support for XFS realtime device | expand

Commit Message

Dave Jiang Feb. 15, 2018, 9:40 p.m. UTC
In a situation where the rt_dev is DAX and data_dev is not DAX, if the user
requests to remove the realtime flag via ioctl we can no longer support DAX
for that file. Dynamic changing of S_DAX on the inode is not supported due
to various complications in the existing implementation. Therefore until we
address the dynamic S_DAX change issues, we must disallow realtime flag
being removed.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 fs/xfs/xfs_ioctl.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Christoph Hellwig Feb. 15, 2018, 9:47 p.m. UTC | #1
> +	if ((XFS_IS_REALTIME_INODE(ip)) &&

No need for the inner braces.

Except for that the whole series looks fine to me.
Dave Jiang Feb. 15, 2018, 10:44 p.m. UTC | #2
On 02/15/2018 02:47 PM, Christoph Hellwig wrote:
>> +	if ((XFS_IS_REALTIME_INODE(ip)) &&
> 
> No need for the inner braces.

Ok I'll fix

> 
> Except for that the whole series looks fine to me.
> 

Can I add your reviewed-by? Thanks for reviewing.
Christoph Hellwig Feb. 15, 2018, 10:48 p.m. UTC | #3
On Thu, Feb 15, 2018 at 03:44:48PM -0700, Dave Jiang wrote:
> > 
> > Except for that the whole series looks fine to me.
> > 
> 
> Can I add your reviewed-by? Thanks for reviewing.

Yes:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 2c70a0a4f59f..59ec742de692 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1030,6 +1030,20 @@  xfs_ioctl_setattr_xflags(
 {
 	struct xfs_mount	*mp = ip->i_mount;
 	uint64_t		di_flags2;
+	struct inode		*inode = VFS_I(ip);
+	struct super_block	*sb = inode->i_sb;
+
+	/*
+	 * In the case that the inode is realtime, and we are trying to remove
+	 * the realtime flag, and the rtdev supports DAX but the datadev does
+	 * not support DAX, we can't allow the realtime flag to be removed
+	 * since we do not support dynamic S_DAX flag removal yet.
+	 */
+	if ((XFS_IS_REALTIME_INODE(ip)) &&
+	    !(fa->fsx_xflags & FS_XFLAG_REALTIME) &&
+	    bdev_dax_supported(mp->m_rtdev_targp->bt_bdev, sb->s_blocksize) &&
+	    !bdev_dax_supported(mp->m_ddev_targp->bt_bdev, sb->s_blocksize))
+		return -ENOTSUPP;
 
 	/* Can't change realtime flag if any extents are allocated. */
 	if ((ip->i_d.di_nextents || ip->i_delayed_blks) &&