FSTests Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly
@ 2020-07-02  6:35 Xiao Yang
  2020-07-02  7:08 ` Xiao Yang
  2020-07-02 15:18 ` Darrick J. Wong
  0 siblings, 2 replies; 5+ messages in thread
From: Xiao Yang @ 2020-07-02  6:35 UTC (permalink / raw)
  To: fstests; +Cc: darrick.wong, ira.weiny, Xiao Yang

With new kernel(e.g. v5.8-rc1), statx() can be used to qurey S_SAX flag
on regular file, so add a test to verify the feature.

Reference:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=712b2698e4c024b561694cbcc1abba13eb0fd9ce

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---

Note: this patch depends on the following patch set:
https://www.spinics.net/lists/fstests/msg14252.html

 tests/generic/604     | 100 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/604.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 103 insertions(+)
 create mode 100644 tests/generic/604
 create mode 100644 tests/generic/604.out

diff --git a/tests/generic/604 b/tests/generic/604
new file mode 100644
index 00000000..b0baa781
--- /dev/null
+++ b/tests/generic/604
@@ -0,0 +1,100 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Fujitsu.  All Rights Reserved.
+#
+# FS QA Test 604
+#
+# By the following cases, verify if statx() can query S_SAX flag
+# on regular file correctly.
+# 1) With dax=always option, FS_XFLAG_DAX is ignored and S_SAX flag
+#    always exists on regular file.
+# 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
+#    S_SAX flag on regular file.
+# 3) With dax=never option, FS_XFLAG_DAX is ignored and S_SAX flag
+#    never exists on regular file.
+#
+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
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+_supported_fs generic
+_supported_os Linux
+_require_scratch_dax_mountopt "dax=always"
+_require_scratch_dax_iflag
+_require_xfs_io_command "statx" "-r"
+
+PARENT_DIR=$SCRATCH_MNT/testdir
+TEST_FILE=$PARENT_DIR/testfile
+
+check_s_dax()
+{
+	local exp_s_dax=$1
+
+	local attributes=$($XFS_IO_PROG -c 'statx -r' $TEST_FILE | awk '/stat.attributes / { print $3 }')
+	if [ $exp_s_dax -eq 0 ]; then
+		(( attributes & 0x2000 )) && echo "$TEST_FILE has unexpected S_DAX flag"
+	else
+		(( attributes & 0x2000 )) || echo "$TEST_FILE doen't have expected S_DAX flag"
+	fi
+}
+
+test_s_dax()
+{
+	local dax_option=$1
+	local exp_s_dax1=$2
+	local exp_s_dax2=$3
+
+	# Mount with specified dax option
+	_scratch_mount "-o $dax_option"
+
+	# Prepare directory
+	mkdir -p $PARENT_DIR
+
+	rm -f $TEST_FILE
+	$XFS_IO_PROG -c "chattr +x" $PARENT_DIR
+	touch $TEST_FILE
+	# Check if setting FS_XFLAG_DAX changes S_DAX flag
+	check_s_dax $exp_s_dax1
+
+	rm -f $TEST_FILE
+	$XFS_IO_PROG -c "chattr -x" $PARENT_DIR
+	touch $TEST_FILE
+	# Check if clearing FS_XFLAG_DAX changes S_DAX flag
+	check_s_dax $exp_s_dax2
+
+	_scratch_unmount
+}
+
+do_tests()
+{
+	test_s_dax "dax=always" 1 1
+	test_s_dax "dax=inode" 1 0
+	test_s_dax "dax=never" 0 0
+}
+
+_scratch_mkfs >> $seqres.full 2>&1
+
+do_tests
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/generic/604.out b/tests/generic/604.out
new file mode 100644
index 00000000..c06a1c7f
--- /dev/null
+++ b/tests/generic/604.out
@@ -0,0 +1,2 @@
+QA output created by 604
+Silence is golden
diff --git a/tests/generic/group b/tests/generic/group
index 1d0d5606..676e0d2e 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -606,3 +606,4 @@
 601 auto quick quota
 602 auto quick encrypt
 603 auto attr quick dax
+604 auto attr quick dax
-- 
2.21.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly
  2020-07-02  6:35 [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly Xiao Yang
@ 2020-07-02  7:08 ` Xiao Yang
  2020-07-02 15:57   ` Darrick J. Wong
  2020-07-02 15:18 ` Darrick J. Wong
  1 sibling, 1 reply; 5+ messages in thread
From: Xiao Yang @ 2020-07-02  7:08 UTC (permalink / raw)
  To: Xiao Yang; +Cc: fstests, darrick.wong, ira.weiny

Hi Ira, Darrick

I have one question about S_DAX flag:
Current statx() can only query S_DAX flag on regular file,
why don't we set S_DAX flag for directory in kernel? :-)

Best Regards,
Xiao Yang
On 2020/7/2 14:35, Xiao Yang wrote:
> With new kernel(e.g. v5.8-rc1), statx() can be used to qurey S_SAX flag
> on regular file, so add a test to verify the feature.
>
> Reference:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=712b2698e4c024b561694cbcc1abba13eb0fd9ce
>
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
>
> Note: this patch depends on the following patch set:
> https://www.spinics.net/lists/fstests/msg14252.html
>
>  tests/generic/604     | 100 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/604.out |   2 +
>  tests/generic/group   |   1 +
>  3 files changed, 103 insertions(+)
>  create mode 100644 tests/generic/604
>  create mode 100644 tests/generic/604.out
>
> diff --git a/tests/generic/604 b/tests/generic/604
> new file mode 100644
> index 00000000..b0baa781
> --- /dev/null
> +++ b/tests/generic/604
> @@ -0,0 +1,100 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Fujitsu.  All Rights Reserved.
> +#
> +# FS QA Test 604
> +#
> +# By the following cases, verify if statx() can query S_SAX flag
> +# on regular file correctly.
> +# 1) With dax=always option, FS_XFLAG_DAX is ignored and S_SAX flag
> +#    always exists on regular file.
> +# 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
> +#    S_SAX flag on regular file.
> +# 3) With dax=never option, FS_XFLAG_DAX is ignored and S_SAX flag
> +#    never exists on regular file.
> +#
> +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
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch_dax_mountopt "dax=always"
> +_require_scratch_dax_iflag
> +_require_xfs_io_command "statx" "-r"
> +
> +PARENT_DIR=$SCRATCH_MNT/testdir
> +TEST_FILE=$PARENT_DIR/testfile
> +
> +check_s_dax()
> +{
> +	local exp_s_dax=$1
> +
> +	local attributes=$($XFS_IO_PROG -c 'statx -r' $TEST_FILE | awk '/stat.attributes / { print $3 }')
> +	if [ $exp_s_dax -eq 0 ]; then
> +		(( attributes & 0x2000 )) && echo "$TEST_FILE has unexpected S_DAX flag"
> +	else
> +		(( attributes & 0x2000 )) || echo "$TEST_FILE doen't have expected S_DAX flag"
> +	fi
> +}
> +
> +test_s_dax()
> +{
> +	local dax_option=$1
> +	local exp_s_dax1=$2
> +	local exp_s_dax2=$3
> +
> +	# Mount with specified dax option
> +	_scratch_mount "-o $dax_option"
> +
> +	# Prepare directory
> +	mkdir -p $PARENT_DIR
> +
> +	rm -f $TEST_FILE
> +	$XFS_IO_PROG -c "chattr +x" $PARENT_DIR
> +	touch $TEST_FILE
> +	# Check if setting FS_XFLAG_DAX changes S_DAX flag
> +	check_s_dax $exp_s_dax1
> +
> +	rm -f $TEST_FILE
> +	$XFS_IO_PROG -c "chattr -x" $PARENT_DIR
> +	touch $TEST_FILE
> +	# Check if clearing FS_XFLAG_DAX changes S_DAX flag
> +	check_s_dax $exp_s_dax2
> +
> +	_scratch_unmount
> +}
> +
> +do_tests()
> +{
> +	test_s_dax "dax=always" 1 1
> +	test_s_dax "dax=inode" 1 0
> +	test_s_dax "dax=never" 0 0
> +}
> +
> +_scratch_mkfs >> $seqres.full 2>&1
> +
> +do_tests
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/generic/604.out b/tests/generic/604.out
> new file mode 100644
> index 00000000..c06a1c7f
> --- /dev/null
> +++ b/tests/generic/604.out
> @@ -0,0 +1,2 @@
> +QA output created by 604
> +Silence is golden
> diff --git a/tests/generic/group b/tests/generic/group
> index 1d0d5606..676e0d2e 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -606,3 +606,4 @@
>  601 auto quick quota
>  602 auto quick encrypt
>  603 auto attr quick dax
> +604 auto attr quick dax




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly
  2020-07-02  6:35 [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly Xiao Yang
  2020-07-02  7:08 ` Xiao Yang
@ 2020-07-02 15:18 ` Darrick J. Wong
  2020-07-03  1:16   ` Xiao Yang
  1 sibling, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2020-07-02 15:18 UTC (permalink / raw)
  To: Xiao Yang; +Cc: fstests, ira.weiny

On Thu, Jul 02, 2020 at 02:35:44PM +0800, Xiao Yang wrote:
> With new kernel(e.g. v5.8-rc1), statx() can be used to qurey S_SAX flag

No, we don't have a VFS flag for saxomophone. ;)

Maybe you meant S_DAX?

--D

> on regular file, so add a test to verify the feature.
> 
> Reference:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=712b2698e4c024b561694cbcc1abba13eb0fd9ce
> 
> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
> 
> Note: this patch depends on the following patch set:
> https://www.spinics.net/lists/fstests/msg14252.html
> 
>  tests/generic/604     | 100 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/604.out |   2 +
>  tests/generic/group   |   1 +
>  3 files changed, 103 insertions(+)
>  create mode 100644 tests/generic/604
>  create mode 100644 tests/generic/604.out
> 
> diff --git a/tests/generic/604 b/tests/generic/604
> new file mode 100644
> index 00000000..b0baa781
> --- /dev/null
> +++ b/tests/generic/604
> @@ -0,0 +1,100 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Fujitsu.  All Rights Reserved.
> +#
> +# FS QA Test 604
> +#
> +# By the following cases, verify if statx() can query S_SAX flag
> +# on regular file correctly.
> +# 1) With dax=always option, FS_XFLAG_DAX is ignored and S_SAX flag
> +#    always exists on regular file.
> +# 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
> +#    S_SAX flag on regular file.
> +# 3) With dax=never option, FS_XFLAG_DAX is ignored and S_SAX flag
> +#    never exists on regular file.
> +#
> +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
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch_dax_mountopt "dax=always"
> +_require_scratch_dax_iflag
> +_require_xfs_io_command "statx" "-r"
> +
> +PARENT_DIR=$SCRATCH_MNT/testdir
> +TEST_FILE=$PARENT_DIR/testfile
> +
> +check_s_dax()
> +{
> +	local exp_s_dax=$1
> +
> +	local attributes=$($XFS_IO_PROG -c 'statx -r' $TEST_FILE | awk '/stat.attributes / { print $3 }')
> +	if [ $exp_s_dax -eq 0 ]; then
> +		(( attributes & 0x2000 )) && echo "$TEST_FILE has unexpected S_DAX flag"
> +	else
> +		(( attributes & 0x2000 )) || echo "$TEST_FILE doen't have expected S_DAX flag"
> +	fi
> +}
> +
> +test_s_dax()
> +{
> +	local dax_option=$1
> +	local exp_s_dax1=$2
> +	local exp_s_dax2=$3
> +
> +	# Mount with specified dax option
> +	_scratch_mount "-o $dax_option"
> +
> +	# Prepare directory
> +	mkdir -p $PARENT_DIR
> +
> +	rm -f $TEST_FILE
> +	$XFS_IO_PROG -c "chattr +x" $PARENT_DIR
> +	touch $TEST_FILE
> +	# Check if setting FS_XFLAG_DAX changes S_DAX flag
> +	check_s_dax $exp_s_dax1
> +
> +	rm -f $TEST_FILE
> +	$XFS_IO_PROG -c "chattr -x" $PARENT_DIR
> +	touch $TEST_FILE
> +	# Check if clearing FS_XFLAG_DAX changes S_DAX flag
> +	check_s_dax $exp_s_dax2
> +
> +	_scratch_unmount
> +}
> +
> +do_tests()
> +{
> +	test_s_dax "dax=always" 1 1
> +	test_s_dax "dax=inode" 1 0
> +	test_s_dax "dax=never" 0 0
> +}
> +
> +_scratch_mkfs >> $seqres.full 2>&1
> +
> +do_tests
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/generic/604.out b/tests/generic/604.out
> new file mode 100644
> index 00000000..c06a1c7f
> --- /dev/null
> +++ b/tests/generic/604.out
> @@ -0,0 +1,2 @@
> +QA output created by 604
> +Silence is golden
> diff --git a/tests/generic/group b/tests/generic/group
> index 1d0d5606..676e0d2e 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -606,3 +606,4 @@
>  601 auto quick quota
>  602 auto quick encrypt
>  603 auto attr quick dax
> +604 auto attr quick dax
> -- 
> 2.21.0
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly
  2020-07-02  7:08 ` Xiao Yang
@ 2020-07-02 15:57   ` Darrick J. Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2020-07-02 15:57 UTC (permalink / raw)
  To: Xiao Yang; +Cc: fstests, ira.weiny

On Thu, Jul 02, 2020 at 03:08:01PM +0800, Xiao Yang wrote:
> Hi Ira, Darrick
> 
> I have one question about S_DAX flag:
> Current statx() can only query S_DAX flag on regular file,
> why don't we set S_DAX flag for directory in kernel? :-)

This was the kind of confusion I was trying to avoid by having dax.txt
spell out exactly what S_DAX meant (it's the incore flag that means that
*regular file access* is done via direct CPU access and not via
pagecache.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/filesystems/dax.txt

--D

> 
> Best Regards,
> Xiao Yang
> On 2020/7/2 14:35, Xiao Yang wrote:
> > With new kernel(e.g. v5.8-rc1), statx() can be used to qurey S_SAX flag
> > on regular file, so add a test to verify the feature.
> >
> > Reference:
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=712b2698e4c024b561694cbcc1abba13eb0fd9ce
> >
> > Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> > ---
> >
> > Note: this patch depends on the following patch set:
> > https://www.spinics.net/lists/fstests/msg14252.html
> >
> >  tests/generic/604     | 100 ++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/604.out |   2 +
> >  tests/generic/group   |   1 +
> >  3 files changed, 103 insertions(+)
> >  create mode 100644 tests/generic/604
> >  create mode 100644 tests/generic/604.out
> >
> > diff --git a/tests/generic/604 b/tests/generic/604
> > new file mode 100644
> > index 00000000..b0baa781
> > --- /dev/null
> > +++ b/tests/generic/604
> > @@ -0,0 +1,100 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2020 Fujitsu.  All Rights Reserved.
> > +#
> > +# FS QA Test 604
> > +#
> > +# By the following cases, verify if statx() can query S_SAX flag
> > +# on regular file correctly.
> > +# 1) With dax=always option, FS_XFLAG_DAX is ignored and S_SAX flag
> > +#    always exists on regular file.
> > +# 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
> > +#    S_SAX flag on regular file.
> > +# 3) With dax=never option, FS_XFLAG_DAX is ignored and S_SAX flag
> > +#    never exists on regular file.
> > +#
> > +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
> > +. ./common/filter
> > +
> > +# remove previous $seqres.full before test
> > +rm -f $seqres.full
> > +
> > +_supported_fs generic
> > +_supported_os Linux
> > +_require_scratch_dax_mountopt "dax=always"
> > +_require_scratch_dax_iflag
> > +_require_xfs_io_command "statx" "-r"
> > +
> > +PARENT_DIR=$SCRATCH_MNT/testdir
> > +TEST_FILE=$PARENT_DIR/testfile
> > +
> > +check_s_dax()
> > +{
> > +	local exp_s_dax=$1
> > +
> > +	local attributes=$($XFS_IO_PROG -c 'statx -r' $TEST_FILE | awk '/stat.attributes / { print $3 }')
> > +	if [ $exp_s_dax -eq 0 ]; then
> > +		(( attributes & 0x2000 )) && echo "$TEST_FILE has unexpected S_DAX flag"
> > +	else
> > +		(( attributes & 0x2000 )) || echo "$TEST_FILE doen't have expected S_DAX flag"
> > +	fi
> > +}
> > +
> > +test_s_dax()
> > +{
> > +	local dax_option=$1
> > +	local exp_s_dax1=$2
> > +	local exp_s_dax2=$3
> > +
> > +	# Mount with specified dax option
> > +	_scratch_mount "-o $dax_option"
> > +
> > +	# Prepare directory
> > +	mkdir -p $PARENT_DIR
> > +
> > +	rm -f $TEST_FILE
> > +	$XFS_IO_PROG -c "chattr +x" $PARENT_DIR
> > +	touch $TEST_FILE
> > +	# Check if setting FS_XFLAG_DAX changes S_DAX flag
> > +	check_s_dax $exp_s_dax1
> > +
> > +	rm -f $TEST_FILE
> > +	$XFS_IO_PROG -c "chattr -x" $PARENT_DIR
> > +	touch $TEST_FILE
> > +	# Check if clearing FS_XFLAG_DAX changes S_DAX flag
> > +	check_s_dax $exp_s_dax2
> > +
> > +	_scratch_unmount
> > +}
> > +
> > +do_tests()
> > +{
> > +	test_s_dax "dax=always" 1 1
> > +	test_s_dax "dax=inode" 1 0
> > +	test_s_dax "dax=never" 0 0
> > +}
> > +
> > +_scratch_mkfs >> $seqres.full 2>&1
> > +
> > +do_tests
> > +
> > +# success, all done
> > +echo "Silence is golden"
> > +status=0
> > +exit
> > diff --git a/tests/generic/604.out b/tests/generic/604.out
> > new file mode 100644
> > index 00000000..c06a1c7f
> > --- /dev/null
> > +++ b/tests/generic/604.out
> > @@ -0,0 +1,2 @@
> > +QA output created by 604
> > +Silence is golden
> > diff --git a/tests/generic/group b/tests/generic/group
> > index 1d0d5606..676e0d2e 100644
> > --- a/tests/generic/group
> > +++ b/tests/generic/group
> > @@ -606,3 +606,4 @@
> >  601 auto quick quota
> >  602 auto quick encrypt
> >  603 auto attr quick dax
> > +604 auto attr quick dax
> 
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly
  2020-07-02 15:18 ` Darrick J. Wong
@ 2020-07-03  1:16   ` Xiao Yang
  0 siblings, 0 replies; 5+ messages in thread
From: Xiao Yang @ 2020-07-03  1:16 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, ira.weiny

On 2020/7/2 23:18, Darrick J. Wong wrote:
> On Thu, Jul 02, 2020 at 02:35:44PM +0800, Xiao Yang wrote:
>> With new kernel(e.g. v5.8-rc1), statx() can be used to qurey S_SAX flag
> No, we don't have a VFS flag for saxomophone. ;)
>
> Maybe you meant S_DAX?
Hi Darrick,

Yes, this is an obvious typo(S_SAX->S_DAX). :-(

Thanks,
Xiao Yang
> --D
>
>> on regular file, so add a test to verify the feature.
>>
>> Reference:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=712b2698e4c024b561694cbcc1abba13eb0fd9ce
>>
>> Signed-off-by: Xiao Yang<yangx.jy@cn.fujitsu.com>
>> ---
>>
>> Note: this patch depends on the following patch set:
>> https://www.spinics.net/lists/fstests/msg14252.html
>>
>>   tests/generic/604     | 100 ++++++++++++++++++++++++++++++++++++++++++
>>   tests/generic/604.out |   2 +
>>   tests/generic/group   |   1 +
>>   3 files changed, 103 insertions(+)
>>   create mode 100644 tests/generic/604
>>   create mode 100644 tests/generic/604.out
>>
>> diff --git a/tests/generic/604 b/tests/generic/604
>> new file mode 100644
>> index 00000000..b0baa781
>> --- /dev/null
>> +++ b/tests/generic/604
>> @@ -0,0 +1,100 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2020 Fujitsu.  All Rights Reserved.
>> +#
>> +# FS QA Test 604
>> +#
>> +# By the following cases, verify if statx() can query S_SAX flag
>> +# on regular file correctly.
>> +# 1) With dax=always option, FS_XFLAG_DAX is ignored and S_SAX flag
>> +#    always exists on regular file.
>> +# 2) With dax=inode option, setting/clearing FS_XFLAG_DAX can change
>> +#    S_SAX flag on regular file.
>> +# 3) With dax=never option, FS_XFLAG_DAX is ignored and S_SAX flag
>> +#    never exists on regular file.
>> +#
>> +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
>> +. ./common/filter
>> +
>> +# remove previous $seqres.full before test
>> +rm -f $seqres.full
>> +
>> +_supported_fs generic
>> +_supported_os Linux
>> +_require_scratch_dax_mountopt "dax=always"
>> +_require_scratch_dax_iflag
>> +_require_xfs_io_command "statx" "-r"
>> +
>> +PARENT_DIR=$SCRATCH_MNT/testdir
>> +TEST_FILE=$PARENT_DIR/testfile
>> +
>> +check_s_dax()
>> +{
>> +	local exp_s_dax=$1
>> +
>> +	local attributes=$($XFS_IO_PROG -c 'statx -r' $TEST_FILE | awk '/stat.attributes / { print $3 }')
>> +	if [ $exp_s_dax -eq 0 ]; then
>> +		(( attributes&  0x2000 ))&&  echo "$TEST_FILE has unexpected S_DAX flag"
>> +	else
>> +		(( attributes&  0x2000 )) || echo "$TEST_FILE doen't have expected S_DAX flag"
>> +	fi
>> +}
>> +
>> +test_s_dax()
>> +{
>> +	local dax_option=$1
>> +	local exp_s_dax1=$2
>> +	local exp_s_dax2=$3
>> +
>> +	# Mount with specified dax option
>> +	_scratch_mount "-o $dax_option"
>> +
>> +	# Prepare directory
>> +	mkdir -p $PARENT_DIR
>> +
>> +	rm -f $TEST_FILE
>> +	$XFS_IO_PROG -c "chattr +x" $PARENT_DIR
>> +	touch $TEST_FILE
>> +	# Check if setting FS_XFLAG_DAX changes S_DAX flag
>> +	check_s_dax $exp_s_dax1
>> +
>> +	rm -f $TEST_FILE
>> +	$XFS_IO_PROG -c "chattr -x" $PARENT_DIR
>> +	touch $TEST_FILE
>> +	# Check if clearing FS_XFLAG_DAX changes S_DAX flag
>> +	check_s_dax $exp_s_dax2
>> +
>> +	_scratch_unmount
>> +}
>> +
>> +do_tests()
>> +{
>> +	test_s_dax "dax=always" 1 1
>> +	test_s_dax "dax=inode" 1 0
>> +	test_s_dax "dax=never" 0 0
>> +}
>> +
>> +_scratch_mkfs>>  $seqres.full 2>&1
>> +
>> +do_tests
>> +
>> +# success, all done
>> +echo "Silence is golden"
>> +status=0
>> +exit
>> diff --git a/tests/generic/604.out b/tests/generic/604.out
>> new file mode 100644
>> index 00000000..c06a1c7f
>> --- /dev/null
>> +++ b/tests/generic/604.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 604
>> +Silence is golden
>> diff --git a/tests/generic/group b/tests/generic/group
>> index 1d0d5606..676e0d2e 100644
>> --- a/tests/generic/group
>> +++ b/tests/generic/group
>> @@ -606,3 +606,4 @@
>>   601 auto quick quota
>>   602 auto quick encrypt
>>   603 auto attr quick dax
>> +604 auto attr quick dax
>> -- 
>> 2.21.0
>>
>>
>>
>
> .
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02  6:35 [PATCH] generic: Verify if statx() can qurey S_SAX flag on regular file correctly Xiao Yang
2020-07-02  7:08 ` Xiao Yang
2020-07-02 15:57   ` Darrick J. Wong
2020-07-02 15:18 ` Darrick J. Wong
2020-07-03  1:16   ` Xiao Yang

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git