diff mbox

[2/3] DAX-DIO: skip DAX to non-DAX if unsupported

Message ID 1491551764-18779-2-git-send-email-xzhou@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Murphy Zhou April 7, 2017, 7:56 a.m. UTC
By tweaking SCRATCH_DEV by ndctl, only run DAX mapped
area DIO to non-DAX area tests when pmem device is in
"memory mode".

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
---
 tests/generic/413 | 25 ++++++++++++++++++++++++-
 tests/xfs/260     | 25 ++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 2 deletions(-)

Comments

Ross Zwisler April 12, 2017, 3:30 a.m. UTC | #1
On Fri, Apr 07, 2017 at 03:56:03PM +0800, Xiong Zhou wrote:
> By tweaking SCRATCH_DEV by ndctl, only run DAX mapped
> area DIO to non-DAX area tests when pmem device is in
> "memory mode".
> 
> Signed-off-by: Xiong Zhou <xzhou@redhat.com>
> ---
>  tests/generic/413 | 25 ++++++++++++++++++++++++-
>  tests/xfs/260     | 25 ++++++++++++++++++++++++-
>  2 files changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/generic/413 b/tests/generic/413
> index a1cc514..55a871f 100755
> --- a/tests/generic/413
> +++ b/tests/generic/413
> @@ -34,6 +34,11 @@ _cleanup()
>  {
>  	cd /
>  	rm -f $tmp.*
> +	_check_scratch_fs
> +	# umount and restore SCRATCH_DEV to original mode
> +	_scratch_unmount
> +	$NDCTL_PROG create-namespace -f -e $scns -m $scmode \
> +	  > /dev/null 2>&1

If we are running on a system where the PMEM namespace was created with the
memmap kernel command line parameter (which is how I usually test), we don't
want to do any reconfig (our namespaces are already in "memory" mode), and
indeed the NDCTL and JSON commands will fail.  Really we can even run the test
without requiring these guys to be there.

We need to detect this situation, and only do NDCTL & JSON commands if we're
running against PMEM that came from an NFIT.

Perhaps it's as easy as just grepping for "memmap" in /proc/cmdline?  IMO we
don't need to worry too much about people running with both an memmap command
line *and* a valid NFIT...

This comment applies to patches 2 and 3 in this series.
--
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
diff mbox

Patch

diff --git a/tests/generic/413 b/tests/generic/413
index a1cc514..55a871f 100755
--- a/tests/generic/413
+++ b/tests/generic/413
@@ -34,6 +34,11 @@  _cleanup()
 {
 	cd /
 	rm -f $tmp.*
+	_check_scratch_fs
+	# umount and restore SCRATCH_DEV to original mode
+	_scratch_unmount
+	$NDCTL_PROG create-namespace -f -e $scns -m $scmode \
+	  > /dev/null 2>&1
 }
 
 # get standard environment, filters and checks
@@ -47,9 +52,13 @@  _supported_fs generic
 _supported_os Linux
 _require_test
 _require_scratch_dax
+# fsck manually in cleanup as we will reconfig SCRATCH_DEV
+_require_scratch_nocheck
 _require_test_program "feature"
 _require_test_program "t_mmap_dio"
 _require_xfs_io_command "falloc"
+_require_ndctl
+_require_jq
 
 prep_files()
 {
@@ -110,7 +119,7 @@  t_both_nondax()
 t_mmap_dio_dax()
 {
 	t_both_dax $1
-	t_dax_to_nondax $1
+	[ $skipdmd -eq 0 ] && t_dax_to_nondax $1
 	t_nondax_to_dax $1
 	t_both_nondax $1
 }
@@ -126,6 +135,20 @@  do_tests()
 	t_mmap_dio_dax $((64 * 1024 * 1024))
 }
 
+skipdmd=0
+# config SCRATCH_DEV to memory mode to support DAX mapped
+# area DIO to non-DAX area.
+
+# save original mode
+scmode=$(_ndctl_get_pmem_key_value $SCRATCH_DEV mode)
+
+# get its namespace
+scns=$(_ndctl_get_pmem_key_value $SCRATCH_DEV dev)
+
+# skip dax to non-dax dio if config fails
+$NDCTL_PROG create-namespace -f -e $scns -m memory \
+  > /dev/null 2>&1 || skipdmd=1
+
 # make fs 2Mb aligned for PMD fault testing
 mkfs_opts=""
 if [ "$FSTYP" == "ext4" ]; then
diff --git a/tests/xfs/260 b/tests/xfs/260
index e613cc0..d07b273 100755
--- a/tests/xfs/260
+++ b/tests/xfs/260
@@ -34,6 +34,11 @@  _cleanup()
 {
 	cd /
 	rm -f $tmp.*
+	_check_scratch_fs
+	# umount and restore SCRATCH_DEV to original mode
+	_scratch_unmount
+	$NDCTL_PROG create-namespace -f -e $scns -m $scmode \
+	  > /dev/null 2>&1
 }
 
 # get standard environment, filters and checks
@@ -46,10 +51,14 @@  rm -f $seqres.full
 _supported_fs xfs
 _supported_os Linux
 _require_scratch_dax
+# fsck manually in cleanup as we will reconfig SCRATCH_DEV
+_require_scratch_nocheck
 _require_test_program "feature"
 _require_test_program "t_mmap_dio"
 _require_xfs_io_command "chattr" "+/-x"
 _require_xfs_io_command "falloc"
+_require_ndctl
+_require_jq
 
 prep_files()
 {
@@ -120,7 +129,7 @@  t_both_nondax()
 t_dax_flag_mmap_dio()
 {
 	t_both_dax $1
-	t_dax_to_nondax $1
+	[ $skipdmd -eq 0 ] && t_dax_to_nondax $1
 	t_nondax_to_dax $1
 	t_both_nondax $1
 }
@@ -136,6 +145,20 @@  do_tests()
 	t_dax_flag_mmap_dio $((64 * 1024 * 1024))
 }
 
+skipdmd=0
+# config SCRATCH_DEV to memory mode to support DAX mapped
+# area DIO to non-DAX area.
+
+# save original mode
+scmode=$(_ndctl_get_pmem_key_value $SCRATCH_DEV mode)
+
+# get its namespace
+scns=$(_ndctl_get_pmem_key_value $SCRATCH_DEV dev)
+
+# skip dax to non-dax dio if config fails
+$NDCTL_PROG create-namespace -f -e $scns -m memory \
+  > /dev/null 2>&1 || skipdmd=1
+
 # make xfs 2Mb aligned for PMD fault testing
 _scratch_mkfs "-d su=2m,sw=1" > /dev/null 2>&1