diff mbox series

[2/5] fs/xfs: Isolate the physical DAX flag from effective

Message ID 20191020155935.12297-3-ira.weiny@intel.com (mailing list archive)
State Superseded
Headers show
Series Enable per-file/directory DAX operations | expand

Commit Message

Ira Weiny Oct. 20, 2019, 3:59 p.m. UTC
From: Ira Weiny <ira.weiny@intel.com>

xfs_ioctl_setattr_dax_invalidate() currently checks if the DAX flag is
changing as a quick check.

But the implementation mixes the physical (XFS_DIFLAG2_DAX) and
effective (S_DAX) DAX flags.

Remove the use of the effective flag when determining if a change of the
physical flag is required.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 fs/xfs/xfs_ioctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Dave Chinner Oct. 21, 2019, 12:26 a.m. UTC | #1
On Sun, Oct 20, 2019 at 08:59:32AM -0700, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
> 
> xfs_ioctl_setattr_dax_invalidate() currently checks if the DAX flag is
> changing as a quick check.
> 
> But the implementation mixes the physical (XFS_DIFLAG2_DAX) and
> effective (S_DAX) DAX flags.

More nuanced than that.

The idea was that if the mount option was set, clearing the
per-inode flag would override the mount option. i.e. the mount
option sets the S_DAX flag at inode instantiation, so using
FSSETXATTR to ensure the FS_XFLAG_DAX is not set would override the
mount option setting, giving applications a way of guranteeing they
aren't using DAX to access the data.

So if the mount option is going to live on, I suspect that we want
to keep this code as it stands.

Cheers,

Dave.
Ira Weiny Oct. 21, 2019, 5:40 p.m. UTC | #2
On Mon, Oct 21, 2019 at 11:26:21AM +1100, Dave Chinner wrote:
> On Sun, Oct 20, 2019 at 08:59:32AM -0700, ira.weiny@intel.com wrote:
> > From: Ira Weiny <ira.weiny@intel.com>
> > 
> > xfs_ioctl_setattr_dax_invalidate() currently checks if the DAX flag is
> > changing as a quick check.
> > 
> > But the implementation mixes the physical (XFS_DIFLAG2_DAX) and
> > effective (S_DAX) DAX flags.
> 
> More nuanced than that.
> 
> The idea was that if the mount option was set, clearing the
> per-inode flag would override the mount option. i.e. the mount
> option sets the S_DAX flag at inode instantiation, so using
> FSSETXATTR to ensure the FS_XFLAG_DAX is not set would override the
> mount option setting, giving applications a way of guranteeing they
> aren't using DAX to access the data.

At LSF/MM we discussed keeping the mount option as a global "chicken bit" as
described by Matt Wilcox[1].  This preserves the existing behavior of turning
it on no matter what but offers an alternative with the per-file flag.

To do what you describe above, it was suggested, by Ted I believe, that an
admin can set DAX on the root directory which will enable DAX by default
through inheritance but allow users to turn it off if they desire.

I'm concerned that all users who currently use '-o dax' will expect their
current file systems to be using DAX when those mounts occur.  Their physical
inode flag is going to be 0 which, if we implement the 'turn off DAX' as you
describe will mean they will not get the behavior they expect when booting on a
new kernel.

> 
> So if the mount option is going to live on, I suspect that we want
> to keep this code as it stands.

I don't think we can get rid of it soon but I would be in favor of working
toward deprecating it.  Regardless I think this keeps the semantics simple WRT
the interaction of the mount and per-file flags.

Ira

[1] https://lwn.net/Articles/787973/

> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
diff mbox series

Patch

diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index d58f0d6a699e..0ea326290cca 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -1319,9 +1319,11 @@  xfs_ioctl_setattr_dax_invalidate(
 	}
 
 	/* If the DAX state is not changing, we have nothing to do here. */
-	if ((fa->fsx_xflags & FS_XFLAG_DAX) && IS_DAX(inode))
+	if ((fa->fsx_xflags & FS_XFLAG_DAX) &&
+	    (ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
 		return 0;
-	if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode))
+	if (!(fa->fsx_xflags & FS_XFLAG_DAX) &&
+	    !(ip->i_d.di_flags2 & XFS_DIFLAG2_DAX))
 		return 0;
 
 	if (S_ISDIR(inode->i_mode))