linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs
@ 2020-04-14 12:07 Jeff Layton
  2020-04-14 12:25 ` Jeff Layton
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jeff Layton @ 2020-04-14 12:07 UTC (permalink / raw)
  To: guaneryu; +Cc: fstests, linux-fsdevel

From: Jeff Layton <jlayton@redhat.com>

Add a test for new syncfs error reporting behavior. When an inode fails
to be written back, ensure that a subsequent call to syncfs() will also
report an error.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 tests/generic/999     | 98 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  8 ++++
 tests/generic/group   |  1 +
 3 files changed, 107 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

diff --git a/tests/generic/999 b/tests/generic/999
new file mode 100755
index 000000000000..7383ce24c8fd
--- /dev/null
+++ b/tests/generic/999
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 999
+#
+# Open a file and write to it and fsync. Then, flip the data device to throw
+# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
+# the same file and call syncfs against it and ensure that an error is reported.
+# Then call syncfs again and ensure that no error is reported. Finally, repeat
+# the open and syncfs and ensure that there is no error reported.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2020, Jeff Layton <jlayton@kernel.org>
+#
+# 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.*
+	_dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_nocheck
+# This test uses "dm" without taking into account the data could be on
+# realtime subvolume, thus the test will fail with rtinherit=1
+_require_no_rtinherit
+_require_dm_target error
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_dmerror_init
+_dmerror_mount
+
+datalen=65536
+_require_fs_space $SCRATCH_MNT $datalen
+
+# use fd 5 to hold file open
+testfile=$SCRATCH_MNT/syncfs-reports-errors
+exec 5>$testfile
+
+# write some data to file and fsync it out
+$XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
+
+# flip device to non-working mode
+_dmerror_load_error_table
+
+# rewrite the data, and do fdatasync
+$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
+
+# heal the device error
+_dmerror_load_working_table
+
+# open again and call syncfs twice
+echo "One of the following syncfs calls should fail with EIO:"
+$XFS_IO_PROG -r -c syncfs -c syncfs $testfile
+echo "done"
+
+echo "This syncfs call should succeed:"
+$XFS_IO_PROG -r -c syncfs $testfile
+echo "done"
+
+# close file
+exec 5>&-
+
+# success, all done
+_dmerror_cleanup
+
+status=0
+exit
diff --git a/tests/generic/999.out b/tests/generic/999.out
new file mode 100644
index 000000000000..950a2ba42503
--- /dev/null
+++ b/tests/generic/999.out
@@ -0,0 +1,8 @@
+QA output created by 999
+Format and mount
+fdatasync: Input/output error
+One of the following syncfs calls should fail with EIO:
+syncfs: Input/output error
+done
+This syncfs call should succeed:
+done
diff --git a/tests/generic/group b/tests/generic/group
index 99d06c9ad945..028cdbd0d52b 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -598,3 +598,4 @@
 594 auto quick quota
 595 auto quick encrypt
 596 auto quick
+999 auto quick
-- 
2.25.2


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

* Re: [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs
  2020-04-14 12:07 [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs Jeff Layton
@ 2020-04-14 12:25 ` Jeff Layton
  2020-04-17 15:36 ` Brian Foster
  2020-04-20 16:21 ` [RFC PATCH v2] " Jeff Layton
  2 siblings, 0 replies; 7+ messages in thread
From: Jeff Layton @ 2020-04-14 12:25 UTC (permalink / raw)
  To: guaneryu; +Cc: fstests, linux-fsdevel

On Tue, 2020-04-14 at 08:07 -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> Add a test for new syncfs error reporting behavior. When an inode fails
> to be written back, ensure that a subsequent call to syncfs() will also
> report an error.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  tests/generic/999     | 98 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  8 ++++
>  tests/generic/group   |  1 +
>  3 files changed, 107 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
> 

I should note that I sent this as an RFC as it will fail until this
series is merged:

    Subject: [PATCH v4 RESEND 0/2] vfs: have syncfs() return error when there are writeback errors

...which I've just recently re-posted to linux-fsdevel, et. al.

> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 000000000000..7383ce24c8fd
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# FS QA Test No. 999
> +#
> +# Open a file and write to it and fsync. Then, flip the data device to throw
> +# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
> +# the same file and call syncfs against it and ensure that an error is reported.
> +# Then call syncfs again and ensure that no error is reported. Finally, repeat
> +# the open and syncfs and ensure that there is no error reported.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2020, Jeff Layton <jlayton@kernel.org>
> +#
> +# 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.*
> +	_dmerror_cleanup
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +# real QA test starts here
> +_supported_os Linux
> +_require_scratch_nocheck
> +# This test uses "dm" without taking into account the data could be on
> +# realtime subvolume, thus the test will fail with rtinherit=1
> +_require_no_rtinherit
> +_require_dm_target error
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs > $seqres.full 2>&1
> +_dmerror_init
> +_dmerror_mount
> +
> +datalen=65536
> +_require_fs_space $SCRATCH_MNT $datalen
> +
> +# use fd 5 to hold file open
> +testfile=$SCRATCH_MNT/syncfs-reports-errors
> +exec 5>$testfile
> +
> +# write some data to file and fsync it out
> +$XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
> +
> +# flip device to non-working mode
> +_dmerror_load_error_table
> +
> +# rewrite the data, and do fdatasync
> +$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
> +
> +# heal the device error
> +_dmerror_load_working_table
> +
> +# open again and call syncfs twice
> +echo "One of the following syncfs calls should fail with EIO:"
> +$XFS_IO_PROG -r -c syncfs -c syncfs $testfile
> +echo "done"
> +
> +echo "This syncfs call should succeed:"
> +$XFS_IO_PROG -r -c syncfs $testfile
> +echo "done"
> +
> +# close file
> +exec 5>&-
> +
> +# success, all done
> +_dmerror_cleanup
> +
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 000000000000..950a2ba42503
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,8 @@
> +QA output created by 999
> +Format and mount
> +fdatasync: Input/output error
> +One of the following syncfs calls should fail with EIO:
> +syncfs: Input/output error
> +done
> +This syncfs call should succeed:
> +done
> diff --git a/tests/generic/group b/tests/generic/group
> index 99d06c9ad945..028cdbd0d52b 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -598,3 +598,4 @@
>  594 auto quick quota
>  595 auto quick encrypt
>  596 auto quick
> +999 auto quick

-- 
Jeff Layton <jlayton@kernel.org>


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

* Re: [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs
  2020-04-14 12:07 [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs Jeff Layton
  2020-04-14 12:25 ` Jeff Layton
@ 2020-04-17 15:36 ` Brian Foster
  2020-04-20 11:33   ` Jeff Layton
  2020-04-20 16:21 ` [RFC PATCH v2] " Jeff Layton
  2 siblings, 1 reply; 7+ messages in thread
From: Brian Foster @ 2020-04-17 15:36 UTC (permalink / raw)
  To: Jeff Layton; +Cc: guaneryu, fstests, linux-fsdevel

On Tue, Apr 14, 2020 at 08:07:40AM -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> Add a test for new syncfs error reporting behavior. When an inode fails
> to be written back, ensure that a subsequent call to syncfs() will also
> report an error.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  tests/generic/999     | 98 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  8 ++++
>  tests/generic/group   |  1 +
>  3 files changed, 107 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
> 
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 000000000000..7383ce24c8fd
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,98 @@
> +#! /bin/bash
> +# FS QA Test No. 999
> +#
> +# Open a file and write to it and fsync. Then, flip the data device to throw
> +# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
> +# the same file and call syncfs against it and ensure that an error is reported.
> +# Then call syncfs again and ensure that no error is reported. Finally, repeat
> +# the open and syncfs and ensure that there is no error reported.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2020, Jeff Layton <jlayton@kernel.org>
> +#
> +# 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
> +#-----------------------------------------------------------------------

I think the big copyright hunk has been replaced with the
SPDX-License-Identifier thing (see other tests for reference).

> +
> +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.*
> +	_dmerror_cleanup
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +# real QA test starts here
> +_supported_os Linux
> +_require_scratch_nocheck
> +# This test uses "dm" without taking into account the data could be on
> +# realtime subvolume, thus the test will fail with rtinherit=1
> +_require_no_rtinherit
> +_require_dm_target error
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs > $seqres.full 2>&1
> +_dmerror_init
> +_dmerror_mount
> +
> +datalen=65536
> +_require_fs_space $SCRATCH_MNT $datalen

That seems unnecessary for such a small value. BTW, any reason this
needs to write more than a page?

> +
> +# use fd 5 to hold file open
> +testfile=$SCRATCH_MNT/syncfs-reports-errors
> +exec 5>$testfile
> +

Also what's the reason for holding an fd on the test file like this?
Does this affect error reporting behavior in some way? Otherwise the
rest looks reasonable to me.

Brian

> +# write some data to file and fsync it out
> +$XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
> +
> +# flip device to non-working mode
> +_dmerror_load_error_table
> +
> +# rewrite the data, and do fdatasync
> +$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
> +
> +# heal the device error
> +_dmerror_load_working_table
> +
> +# open again and call syncfs twice
> +echo "One of the following syncfs calls should fail with EIO:"
> +$XFS_IO_PROG -r -c syncfs -c syncfs $testfile
> +echo "done"
> +
> +echo "This syncfs call should succeed:"
> +$XFS_IO_PROG -r -c syncfs $testfile
> +echo "done"
> +
> +# close file
> +exec 5>&-
> +
> +# success, all done
> +_dmerror_cleanup
> +
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 000000000000..950a2ba42503
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,8 @@
> +QA output created by 999
> +Format and mount
> +fdatasync: Input/output error
> +One of the following syncfs calls should fail with EIO:
> +syncfs: Input/output error
> +done
> +This syncfs call should succeed:
> +done
> diff --git a/tests/generic/group b/tests/generic/group
> index 99d06c9ad945..028cdbd0d52b 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -598,3 +598,4 @@
>  594 auto quick quota
>  595 auto quick encrypt
>  596 auto quick
> +999 auto quick
> -- 
> 2.25.2
> 


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

* Re: [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs
  2020-04-17 15:36 ` Brian Foster
@ 2020-04-20 11:33   ` Jeff Layton
  2020-04-20 14:24     ` Brian Foster
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Layton @ 2020-04-20 11:33 UTC (permalink / raw)
  To: Brian Foster; +Cc: guaneryu, fstests, linux-fsdevel

On Fri, 2020-04-17 at 11:36 -0400, Brian Foster wrote:
> On Tue, Apr 14, 2020 at 08:07:40AM -0400, Jeff Layton wrote:
> > From: Jeff Layton <jlayton@redhat.com>
> > 
> > Add a test for new syncfs error reporting behavior. When an inode fails
> > to be written back, ensure that a subsequent call to syncfs() will also
> > report an error.
> > 
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  tests/generic/999     | 98 +++++++++++++++++++++++++++++++++++++++++++
> >  tests/generic/999.out |  8 ++++
> >  tests/generic/group   |  1 +
> >  3 files changed, 107 insertions(+)
> >  create mode 100755 tests/generic/999
> >  create mode 100644 tests/generic/999.out
> > 
> > diff --git a/tests/generic/999 b/tests/generic/999
> > new file mode 100755
> > index 000000000000..7383ce24c8fd
> > --- /dev/null
> > +++ b/tests/generic/999
> > @@ -0,0 +1,98 @@
> > +#! /bin/bash
> > +# FS QA Test No. 999
> > +#
> > +# Open a file and write to it and fsync. Then, flip the data device to throw
> > +# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
> > +# the same file and call syncfs against it and ensure that an error is reported.
> > +# Then call syncfs again and ensure that no error is reported. Finally, repeat
> > +# the open and syncfs and ensure that there is no error reported.
> > +#
> > +#-----------------------------------------------------------------------
> > +# Copyright (c) 2020, Jeff Layton <jlayton@kernel.org>
> > +#
> > +# 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
> > +#-----------------------------------------------------------------------
> 
> I think the big copyright hunk has been replaced with the
> SPDX-License-Identifier thing (see other tests for reference).
> 

Thanks. Will fix.

> > +
> > +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.*
> > +	_dmerror_cleanup
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +. ./common/dmerror
> > +
> > +# real QA test starts here
> > +_supported_os Linux
> > +_require_scratch_nocheck
> > +# This test uses "dm" without taking into account the data could be on
> > +# realtime subvolume, thus the test will fail with rtinherit=1
> > +_require_no_rtinherit
> > +_require_dm_target error
> > +
> > +rm -f $seqres.full
> > +
> > +echo "Format and mount"
> > +_scratch_mkfs > $seqres.full 2>&1
> > +_dmerror_init
> > +_dmerror_mount
> > +
> > +datalen=65536
> > +_require_fs_space $SCRATCH_MNT $datalen
> 
> That seems unnecessary for such a small value. BTW, any reason this
> needs to write more than a page?
> 

No reason for that size. I think I just copied that from generic/487
since I started with that one as a template. I'll cut it down to a page.

Should I not bother calling _require_fs_space here since it's so small?
I wasn't sure how strict that was...

> > +
> > +# use fd 5 to hold file open
> > +testfile=$SCRATCH_MNT/syncfs-reports-errors
> > +exec 5>$testfile
> > +
> 
> Also what's the reason for holding an fd on the test file like this?
> Does this affect error reporting behavior in some way? Otherwise the
> rest looks reasonable to me.
> 

Again, copied from 487. It's not necessary for this test. I'll switch
that to just "touch testfile" at the start and get rid of the follow-on
close.

Thanks for the review!
-- 
Jeff Layton <jlayton@kernel.org>


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

* Re: [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs
  2020-04-20 11:33   ` Jeff Layton
@ 2020-04-20 14:24     ` Brian Foster
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Foster @ 2020-04-20 14:24 UTC (permalink / raw)
  To: Jeff Layton; +Cc: guaneryu, fstests, linux-fsdevel

On Mon, Apr 20, 2020 at 07:33:27AM -0400, Jeff Layton wrote:
> On Fri, 2020-04-17 at 11:36 -0400, Brian Foster wrote:
> > On Tue, Apr 14, 2020 at 08:07:40AM -0400, Jeff Layton wrote:
> > > From: Jeff Layton <jlayton@redhat.com>
> > > 
> > > Add a test for new syncfs error reporting behavior. When an inode fails
> > > to be written back, ensure that a subsequent call to syncfs() will also
> > > report an error.
> > > 
> > > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > > ---
> > >  tests/generic/999     | 98 +++++++++++++++++++++++++++++++++++++++++++
> > >  tests/generic/999.out |  8 ++++
> > >  tests/generic/group   |  1 +
> > >  3 files changed, 107 insertions(+)
> > >  create mode 100755 tests/generic/999
> > >  create mode 100644 tests/generic/999.out
> > > 
> > > diff --git a/tests/generic/999 b/tests/generic/999
> > > new file mode 100755
> > > index 000000000000..7383ce24c8fd
> > > --- /dev/null
> > > +++ b/tests/generic/999
> > > @@ -0,0 +1,98 @@
> > > +#! /bin/bash
> > > +# FS QA Test No. 999
> > > +#
> > > +# Open a file and write to it and fsync. Then, flip the data device to throw
> > > +# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
> > > +# the same file and call syncfs against it and ensure that an error is reported.
> > > +# Then call syncfs again and ensure that no error is reported. Finally, repeat
> > > +# the open and syncfs and ensure that there is no error reported.
> > > +#
> > > +#-----------------------------------------------------------------------
> > > +# Copyright (c) 2020, Jeff Layton <jlayton@kernel.org>
> > > +#
> > > +# 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
> > > +#-----------------------------------------------------------------------
> > 
> > I think the big copyright hunk has been replaced with the
> > SPDX-License-Identifier thing (see other tests for reference).
> > 
> 
> Thanks. Will fix.
> 
> > > +
> > > +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.*
> > > +	_dmerror_cleanup
> > > +}
> > > +
> > > +# get standard environment, filters and checks
> > > +. ./common/rc
> > > +. ./common/filter
> > > +. ./common/dmerror
> > > +
> > > +# real QA test starts here
> > > +_supported_os Linux
> > > +_require_scratch_nocheck
> > > +# This test uses "dm" without taking into account the data could be on
> > > +# realtime subvolume, thus the test will fail with rtinherit=1
> > > +_require_no_rtinherit
> > > +_require_dm_target error
> > > +
> > > +rm -f $seqres.full
> > > +
> > > +echo "Format and mount"
> > > +_scratch_mkfs > $seqres.full 2>&1
> > > +_dmerror_init
> > > +_dmerror_mount
> > > +
> > > +datalen=65536
> > > +_require_fs_space $SCRATCH_MNT $datalen
> > 
> > That seems unnecessary for such a small value. BTW, any reason this
> > needs to write more than a page?
> > 
> 
> No reason for that size. I think I just copied that from generic/487
> since I started with that one as a template. I'll cut it down to a page.
> 
> Should I not bother calling _require_fs_space here since it's so small?
> I wasn't sure how strict that was...
> 

I'm not sure there's a rule for when to use it or not (it's probably
just up to Eryu's preference), but yeah, it's probably overkill for a
test that's only writing a handful of pages.

Brian

> > > +
> > > +# use fd 5 to hold file open
> > > +testfile=$SCRATCH_MNT/syncfs-reports-errors
> > > +exec 5>$testfile
> > > +
> > 
> > Also what's the reason for holding an fd on the test file like this?
> > Does this affect error reporting behavior in some way? Otherwise the
> > rest looks reasonable to me.
> > 
> 
> Again, copied from 487. It's not necessary for this test. I'll switch
> that to just "touch testfile" at the start and get rid of the follow-on
> close.
> 
> Thanks for the review!
> -- 
> Jeff Layton <jlayton@kernel.org>
> 


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

* [RFC PATCH v2] generic: test reporting of wb errors via syncfs
  2020-04-14 12:07 [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs Jeff Layton
  2020-04-14 12:25 ` Jeff Layton
  2020-04-17 15:36 ` Brian Foster
@ 2020-04-20 16:21 ` Jeff Layton
  2020-04-21 14:21   ` Brian Foster
  2 siblings, 1 reply; 7+ messages in thread
From: Jeff Layton @ 2020-04-20 16:21 UTC (permalink / raw)
  To: fstests; +Cc: linux-fsdevel, guaneryu, bfoster, viro

From: Jeff Layton <jlayton@redhat.com>

Add a test for new syncfs error reporting behavior. When an inode fails
to be written back, ensure that a subsequent call to syncfs() will also
report an error.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 tests/generic/999     | 79 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  8 +++++
 tests/generic/group   |  1 +
 3 files changed, 88 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

v2:
- update license comment
- only write a page of data
- don't bother testing for enough scratch space
- don't hold file open over test

Thanks to Brian Foster for the review! This is testing a proposed
behavior change and is dependent on this patchset being merged:

    vfs: have syncfs() return error when there are writeback errors

We'll probably want to wait until its fate is clear before merging this.

diff --git a/tests/generic/999 b/tests/generic/999
new file mode 100755
index 000000000000..cdc0772d0774
--- /dev/null
+++ b/tests/generic/999
@@ -0,0 +1,79 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2020, Jeff Layton. All rights reserved.
+# FS QA Test No. 999
+#
+# Open a file and write to it and fsync. Then, flip the data device to throw
+# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
+# the same file and call syncfs against it and ensure that an error is reported.
+# Then call syncfs again and ensure that no error is reported. Finally, repeat
+# the open and syncfs and ensure that there is no error reported.
+
+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.*
+	_dmerror_cleanup
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/dmerror
+
+# real QA test starts here
+_supported_os Linux
+_require_scratch_nocheck
+# This test uses "dm" without taking into account the data could be on
+# realtime subvolume, thus the test will fail with rtinherit=1
+_require_no_rtinherit
+_require_dm_target error
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_dmerror_init
+_dmerror_mount
+
+
+# create file
+testfile=$SCRATCH_MNT/syncfs-reports-errors
+touch $testfile
+
+# write a page of data to file, and call fsync
+datalen=$(getconf PAGE_SIZE)
+$XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
+
+# flip device to non-working mode
+_dmerror_load_error_table
+
+# rewrite the data and call fdatasync
+$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
+
+# heal the device error
+_dmerror_load_working_table
+
+# open again and call syncfs twice
+echo "One of the following syncfs calls should fail with EIO:"
+$XFS_IO_PROG -r -c syncfs -c syncfs $testfile
+echo "done"
+
+echo "This syncfs call should succeed:"
+$XFS_IO_PROG -r -c syncfs $testfile
+echo "done"
+
+# success, all done
+_dmerror_cleanup
+
+status=0
+exit
diff --git a/tests/generic/999.out b/tests/generic/999.out
new file mode 100644
index 000000000000..950a2ba42503
--- /dev/null
+++ b/tests/generic/999.out
@@ -0,0 +1,8 @@
+QA output created by 999
+Format and mount
+fdatasync: Input/output error
+One of the following syncfs calls should fail with EIO:
+syncfs: Input/output error
+done
+This syncfs call should succeed:
+done
diff --git a/tests/generic/group b/tests/generic/group
index 718575baeef9..9bcf296fc3dd 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -598,3 +598,4 @@
 594 auto quick quota
 595 auto quick encrypt
 596 auto quick
+999 auto quick
-- 
2.25.3


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

* Re: [RFC PATCH v2] generic: test reporting of wb errors via syncfs
  2020-04-20 16:21 ` [RFC PATCH v2] " Jeff Layton
@ 2020-04-21 14:21   ` Brian Foster
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Foster @ 2020-04-21 14:21 UTC (permalink / raw)
  To: Jeff Layton; +Cc: fstests, linux-fsdevel, guaneryu, viro

On Mon, Apr 20, 2020 at 12:21:43PM -0400, Jeff Layton wrote:
> From: Jeff Layton <jlayton@redhat.com>
> 
> Add a test for new syncfs error reporting behavior. When an inode fails
> to be written back, ensure that a subsequent call to syncfs() will also
> report an error.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  tests/generic/999     | 79 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  8 +++++
>  tests/generic/group   |  1 +
>  3 files changed, 88 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
> 
> v2:
> - update license comment
> - only write a page of data
> - don't bother testing for enough scratch space
> - don't hold file open over test
> 
> Thanks to Brian Foster for the review! This is testing a proposed
> behavior change and is dependent on this patchset being merged:
> 
>     vfs: have syncfs() return error when there are writeback errors
> 
> We'll probably want to wait until its fate is clear before merging this.
> 
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 000000000000..cdc0772d0774
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,79 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0+
> +# Copyright (c) 2020, Jeff Layton. All rights reserved.
> +# FS QA Test No. 999
> +#
> +# Open a file and write to it and fsync. Then, flip the data device to throw
> +# errors, write to it again and do an fdatasync. Then open an O_RDONLY fd on
> +# the same file and call syncfs against it and ensure that an error is reported.
> +# Then call syncfs again and ensure that no error is reported. Finally, repeat
> +# the open and syncfs and ensure that there is no error reported.
> +
> +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.*
> +	_dmerror_cleanup
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +. ./common/dmerror
> +
> +# real QA test starts here
> +_supported_os Linux
> +_require_scratch_nocheck
> +# This test uses "dm" without taking into account the data could be on
> +# realtime subvolume, thus the test will fail with rtinherit=1
> +_require_no_rtinherit
> +_require_dm_target error
> +
> +rm -f $seqres.full
> +
> +echo "Format and mount"
> +_scratch_mkfs > $seqres.full 2>&1
> +_dmerror_init
> +_dmerror_mount
> +
> +
> +# create file
> +testfile=$SCRATCH_MNT/syncfs-reports-errors
> +touch $testfile
> +
> +# write a page of data to file, and call fsync
> +datalen=$(getconf PAGE_SIZE)
> +$XFS_IO_PROG -c "pwrite -W -q 0 $datalen" $testfile
> +
> +# flip device to non-working mode
> +_dmerror_load_error_table
> +
> +# rewrite the data and call fdatasync
> +$XFS_IO_PROG -c "pwrite -w -q 0 $datalen" $testfile
> +
> +# heal the device error
> +_dmerror_load_working_table
> +
> +# open again and call syncfs twice
> +echo "One of the following syncfs calls should fail with EIO:"
> +$XFS_IO_PROG -r -c syncfs -c syncfs $testfile
> +echo "done"
> +
> +echo "This syncfs call should succeed:"
> +$XFS_IO_PROG -r -c syncfs $testfile
> +echo "done"
> +
> +# success, all done
> +_dmerror_cleanup
> +
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 000000000000..950a2ba42503
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,8 @@
> +QA output created by 999
> +Format and mount
> +fdatasync: Input/output error
> +One of the following syncfs calls should fail with EIO:
> +syncfs: Input/output error
> +done
> +This syncfs call should succeed:
> +done
> diff --git a/tests/generic/group b/tests/generic/group
> index 718575baeef9..9bcf296fc3dd 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -598,3 +598,4 @@
>  594 auto quick quota
>  595 auto quick encrypt
>  596 auto quick
> +999 auto quick
> -- 
> 2.25.3
> 


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

end of thread, other threads:[~2020-04-21 14:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 12:07 [RFC PATCH xfstests] generic: test reporting of wb errors via syncfs Jeff Layton
2020-04-14 12:25 ` Jeff Layton
2020-04-17 15:36 ` Brian Foster
2020-04-20 11:33   ` Jeff Layton
2020-04-20 14:24     ` Brian Foster
2020-04-20 16:21 ` [RFC PATCH v2] " Jeff Layton
2020-04-21 14:21   ` Brian Foster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).