Message ID | 20170911200103.28226-1-ross.zwisler@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Ross, On Mon, Sep 11, 2017 at 02:01:03PM -0600, Ross Zwisler wrote: > This adds a regression test for the following kernel patch: > > xfs: always use DAX if mount option is used > > This test will also pass with kernel v4.14-rc1 and beyond because the XFS > DAX I/O mount option has been disabled (but not removed), so the > "chattr -x" to turn off DAX doesn't actually do anything. > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> > Suggested-by: Christoph Hellwig <hch@infradead.org> > --- > > Changes since v1: > - Use perf instead of tracepoints to detect whether DAX is used. (Dan) Thanks for the test! But I agreed with Dave here, it doesn't seem like a good idea to depend on the kernel tracepoints in a test, but I can't think of a better solution either, so I didn't get to this patch earlier.. Before XFS disabled the ability to switch on & off per-inode DAX flag, the x flag was only shown after an explicit 'chattr +x', even if XFS was mounted with dax option, e.g. # mkfs -t xfs -f /dev/ram0 # mount -o dax /dev/ram0 /mnt/xfs # echo "test" > /mnt/xfs/testfile # xfs_io -c "lsattr" /mnt/xfs/testfile ---------------- /mnt/xfs/testfile # xfs_io -c "chattr +x" /mnt/xfs/testfile # xfs_io -c "lsattr" /mnt/xfs/testfile ---------------x /mnt/xfs/testfile I'm wondering if it makes sense to make lsattr print the x flag by default when XFS is mounted with dax option, that way, we have a method to know whether dax is used or not on a particular file too. Thanks, Eryu -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Sep 14, 2017 at 02:57:41PM +0800, Eryu Guan wrote: > Hi Ross, > > On Mon, Sep 11, 2017 at 02:01:03PM -0600, Ross Zwisler wrote: > > This adds a regression test for the following kernel patch: > > > > xfs: always use DAX if mount option is used > > > > This test will also pass with kernel v4.14-rc1 and beyond because the XFS > > DAX I/O mount option has been disabled (but not removed), so the > > "chattr -x" to turn off DAX doesn't actually do anything. > > > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> > > Suggested-by: Christoph Hellwig <hch@infradead.org> > > --- > > > > Changes since v1: > > - Use perf instead of tracepoints to detect whether DAX is used. (Dan) > > Thanks for the test! But I agreed with Dave here, it doesn't seem like a > good idea to depend on the kernel tracepoints in a test, but I can't > think of a better solution either, so I didn't get to this patch > earlier.. > > Before XFS disabled the ability to switch on & off per-inode DAX flag, > the x flag was only shown after an explicit 'chattr +x', even if XFS was > mounted with dax option, e.g. > > # mkfs -t xfs -f /dev/ram0 > # mount -o dax /dev/ram0 /mnt/xfs > # echo "test" > /mnt/xfs/testfile > # xfs_io -c "lsattr" /mnt/xfs/testfile > ---------------- /mnt/xfs/testfile > # xfs_io -c "chattr +x" /mnt/xfs/testfile > # xfs_io -c "lsattr" /mnt/xfs/testfile > ---------------x /mnt/xfs/testfile XFS actually still works this way, you just don't get dax now when you chattr +x. :-/ But the inode flag is actually still there, gets updated by chattr and can be listed with lsattr. Actually, that feels like a really bad situation to be in - Christoph & Dave, should we do more to remove the flag as long as it's not working? i.e. remove it from the lsattr output and make "chattr +x" fail with -EINVAL or similar? > I'm wondering if it makes sense to make lsattr print the x flag by > default when XFS is mounted with dax option, that way, we have a method > to know whether dax is used or not on a particular file too. Well, the per-inode flag that gets set in the filesystem metadata and the actual S_DAX runtime flag which controls whether or not we do DAX I/O and page faults are different things, and as we've seen they aren't always synchronized. I think making the 'x' flag in lsattr reflect the current state of S_DAX is interesting, but it would suffer from the same TOCTOU races that Dave was concerned about for the proposed VM_DAX flag: https://lkml.org/lkml/2016/9/16/13 It could also be surprising to users - if they had mounted with -o dax, lsattr on each of their files would show the 'x' flag, but if they remount without that option those 'x' flags would go away. I think this is surprising because normally it takes a chattr to modify the flags. -- To unsubscribe from this list: send the line "unsubscribe fstests" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Sep 15, 2017 at 04:42:27PM -0600, Ross Zwisler wrote: > On Thu, Sep 14, 2017 at 02:57:41PM +0800, Eryu Guan wrote: > > Hi Ross, > > > > On Mon, Sep 11, 2017 at 02:01:03PM -0600, Ross Zwisler wrote: > > > This adds a regression test for the following kernel patch: > > > > > > xfs: always use DAX if mount option is used > > > > > > This test will also pass with kernel v4.14-rc1 and beyond because the XFS > > > DAX I/O mount option has been disabled (but not removed), so the > > > "chattr -x" to turn off DAX doesn't actually do anything. > > > > > > Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> > > > Suggested-by: Christoph Hellwig <hch@infradead.org> > > > --- > > > > > > Changes since v1: > > > - Use perf instead of tracepoints to detect whether DAX is used. (Dan) > > > > Thanks for the test! But I agreed with Dave here, it doesn't seem like a > > good idea to depend on the kernel tracepoints in a test, but I can't > > think of a better solution either, so I didn't get to this patch > > earlier.. > > > > Before XFS disabled the ability to switch on & off per-inode DAX flag, > > the x flag was only shown after an explicit 'chattr +x', even if XFS was > > mounted with dax option, e.g. Of course. lsattr reports the *on-disk inode flag state*. It does not report whether the file is using that feature or not, just whether the flag is set on disk. Remember, lsattr does not report a "sum of all config states for a feature". It reports on disk state and on disk state only. It follows the same semantics as other flags that have equivalent mount options like dirsync, sync, noatime, etc. > > # mkfs -t xfs -f /dev/ram0 > > # mount -o dax /dev/ram0 /mnt/xfs > > # echo "test" > /mnt/xfs/testfile > > # xfs_io -c "lsattr" /mnt/xfs/testfile > > ---------------- /mnt/xfs/testfile > > # xfs_io -c "chattr +x" /mnt/xfs/testfile > > # xfs_io -c "lsattr" /mnt/xfs/testfile > > ---------------x /mnt/xfs/testfile > > XFS actually still works this way, you just don't get dax now when you chattr > +x. :-/ But the inode flag is actually still there, gets updated by chattr > and can be listed with lsattr. > > Actually, that feels like a really bad situation to be in - Christoph & Dave, > should we do more to remove the flag as long as it's not working? i.e. remove > it from the lsattr output and make "chattr +x" fail with -EINVAL or similar? How about we concentrate on fixing the problem that led us to disable it temporarily in XFS? Then it can be re-enabled and problems like this go away... Cheers, Dave.
diff --git a/tests/xfs/431 b/tests/xfs/431 new file mode 100755 index 0000000..2865a6d --- /dev/null +++ b/tests/xfs/431 @@ -0,0 +1,77 @@ +#! /bin/bash +# FS QA Test xfs/431 +# +# This is a regression test for kernel patch: +# xfs: always use DAX if mount option is used +# created by Ross Zwisler <ross.zwisler@linux.intel.com> +# +#----------------------------------------------------------------------- +# Copyright (c) 2017 Intel Corporation. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc + +# remove previous $seqres.full before test +rm -f $seqres.full + +# Modify as appropriate. +_supported_os Linux +_supported_fs xfs +_require_scratch_dax + +# real QA test starts here +export PERF_PROG="`set_prog_path perf`" +[ "$PERF_PROG" = "" ] && _notrun "perf not found" + +_scratch_mkfs > $seqres.full 2>&1 +_scratch_mount "-o dax" >> $seqres.full 2>&1 + +pgsize=`$here/src/feature -s` + +PERF_OUTPUT=$tmp.perf + +$PERF_PROG record -o $PERF_OUTPUT -e 'fs_dax:dax_load_hole' \ + $XFS_IO_PROG -t -c "truncate $pgsize" \ + -c "chattr -x" \ + -c "mmap -r 0 $pgsize" -c "mread 0 $pgsize" -c "munmap" \ + -f $SCRATCH_MNT/testfile > /dev/null 2>&1 + +$PERF_PROG script -i $PERF_OUTPUT | grep -q 'fs_dax:dax_load_hole' +if [[ $? == 0 ]]; then + echo "DAX was used" +else + echo "DAX was NOT used" +fi + +# success, all done +status=0 +exit diff --git a/tests/xfs/431.out b/tests/xfs/431.out new file mode 100644 index 0000000..194ae1e --- /dev/null +++ b/tests/xfs/431.out @@ -0,0 +1,2 @@ +QA output created by 431 +DAX was used diff --git a/tests/xfs/group b/tests/xfs/group index 0a449b9..4e7019c 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -427,3 +427,4 @@ 428 dangerous_fuzzers dangerous_scrub dangerous_online_repair 429 dangerous_fuzzers dangerous_scrub dangerous_repair 430 dangerous_fuzzers dangerous_scrub dangerous_online_repair +431 auto quick
This adds a regression test for the following kernel patch: xfs: always use DAX if mount option is used This test will also pass with kernel v4.14-rc1 and beyond because the XFS DAX I/O mount option has been disabled (but not removed), so the "chattr -x" to turn off DAX doesn't actually do anything. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> Suggested-by: Christoph Hellwig <hch@infradead.org> --- Changes since v1: - Use perf instead of tracepoints to detect whether DAX is used. (Dan) --- tests/xfs/431 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/431.out | 2 ++ tests/xfs/group | 1 + 3 files changed, 80 insertions(+) create mode 100755 tests/xfs/431 create mode 100644 tests/xfs/431.out