linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* add device removal test
@ 2023-06-01  9:42 Christoph Hellwig
  2023-06-01  9:42 ` [PATCH 1/2] generic: add a test for device removal with dirty data Christoph Hellwig
  2023-06-01  9:42 ` [PATCH 2/2] generic: add a test for device removal without " Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2023-06-01  9:42 UTC (permalink / raw)
  To: fstests; +Cc: linux-fsdevel

Hi all,

this series adds two tests for removing a device underneath the
file system.  This covers the new shutdown handling series I'm
posting.

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

* [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-01  9:42 add device removal test Christoph Hellwig
@ 2023-06-01  9:42 ` Christoph Hellwig
  2023-06-01 15:25   ` Darrick J. Wong
  2023-06-01  9:42 ` [PATCH 2/2] generic: add a test for device removal without " Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2023-06-01  9:42 UTC (permalink / raw)
  To: fstests; +Cc: linux-fsdevel

Test the removal of the underlying device when the file system still
has dirty data.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/729     | 53 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/729.out |  2 ++
 2 files changed, 55 insertions(+)
 create mode 100755 tests/generic/729
 create mode 100644 tests/generic/729.out

diff --git a/tests/generic/729 b/tests/generic/729
new file mode 100755
index 00000000..e3b52a51
--- /dev/null
+++ b/tests/generic/729
@@ -0,0 +1,53 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
+# Copyright (c) 2023 Christoph Hellwig
+#
+# Test proper file system shut down when the block device is removed underneath
+# and there is dirty data.
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_cleanup()
+{
+	cd /
+	$UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
+	_put_scsi_debug_dev
+	rm -f $tmp.*
+}
+
+. ./common/filter
+. ./common/scsi_debug
+
+_supported_fs generic
+_require_scsi_debug
+
+physical=`blockdev --getpbsz $SCRATCH_DEV`
+logical=`blockdev --getss $SCRATCH_DEV`
+
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300`
+test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
+echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
+
+_mkfs_dev $SCSI_DEBUG_DEV
+
+_mount $SCSI_DEBUG_DEV $SCRATCH_MNT
+
+# create a test file
+$XFS_IO_PROG -f -c "pwrite 0 1M" $SCRATCH_MNT/testfile >>$seqres.full
+
+# open a file descriptor for reading the file
+exec 3< $SCRATCH_MNT/testfile
+
+# delete the scsi debug device while it still has dirty data
+echo 1 > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/delete
+
+# try to read from the file, which should give us -EIO
+cat <&3 > /dev/null
+
+# close the file descriptor to not block unmount
+exec 3<&-
+
+status=0
+exit
diff --git a/tests/generic/729.out b/tests/generic/729.out
new file mode 100644
index 00000000..8abf2b3c
--- /dev/null
+++ b/tests/generic/729.out
@@ -0,0 +1,2 @@
+QA output created by 729
+cat: -: Input/output error
-- 
2.39.2


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

* [PATCH 2/2] generic: add a test for device removal without dirty data
  2023-06-01  9:42 add device removal test Christoph Hellwig
  2023-06-01  9:42 ` [PATCH 1/2] generic: add a test for device removal with dirty data Christoph Hellwig
@ 2023-06-01  9:42 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2023-06-01  9:42 UTC (permalink / raw)
  To: fstests; +Cc: linux-fsdevel

Test the removal of the underlying device when the file system still
does not have dirty data.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/generic/730     | 55 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/730.out |  2 ++
 2 files changed, 57 insertions(+)
 create mode 100755 tests/generic/730
 create mode 100644 tests/generic/730.out

diff --git a/tests/generic/730 b/tests/generic/730
new file mode 100755
index 00000000..7f795da3
--- /dev/null
+++ b/tests/generic/730
@@ -0,0 +1,55 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
+# Copyright (c) 2023 Christoph Hellwig
+#
+# Test proper file system shut down when the block device is removed underneath
+# and it has no dirty data.
+#
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+_cleanup()
+{
+	cd /
+	$UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
+	_put_scsi_debug_dev
+	rm -f $tmp.*
+}
+
+. ./common/filter
+. ./common/scsi_debug
+
+_supported_fs generic
+_require_scsi_debug
+
+physical=`blockdev --getpbsz $SCRATCH_DEV`
+logical=`blockdev --getss $SCRATCH_DEV`
+
+SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300`
+test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
+echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
+
+_mkfs_dev $SCSI_DEBUG_DEV
+
+_mount $SCSI_DEBUG_DEV $SCRATCH_MNT
+
+# create a test file
+$XFS_IO_PROG -f -c "pwrite 0 1M" -c "fsync" $SCRATCH_MNT/testfile >>$seqres.full
+
+# open a file descriptor for reading the file
+exec 3< $SCRATCH_MNT/testfile
+
+# drop all caches and delete the scsi debug device
+echo 3 > /proc/sys/vm/drop_caches
+echo 1 > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/delete
+
+# try to read from the file, which should give us -EIO
+cat <&3 > /dev/null
+
+# close the file descriptor to not block unmount
+exec 3<&-
+
+status=0
+exit
diff --git a/tests/generic/730.out b/tests/generic/730.out
new file mode 100644
index 00000000..79e96db8
--- /dev/null
+++ b/tests/generic/730.out
@@ -0,0 +1,2 @@
+QA output created by 730
+cat: -: Input/output error
-- 
2.39.2


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

* Re: [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-01  9:42 ` [PATCH 1/2] generic: add a test for device removal with dirty data Christoph Hellwig
@ 2023-06-01 15:25   ` Darrick J. Wong
  2023-06-01 15:27     ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2023-06-01 15:25 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: fstests, linux-fsdevel

On Thu, Jun 01, 2023 at 11:42:23AM +0200, Christoph Hellwig wrote:
> Test the removal of the underlying device when the file system still
> has dirty data.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  tests/generic/729     | 53 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/729.out |  2 ++
>  2 files changed, 55 insertions(+)
>  create mode 100755 tests/generic/729
>  create mode 100644 tests/generic/729.out
> 
> diff --git a/tests/generic/729 b/tests/generic/729
> new file mode 100755
> index 00000000..e3b52a51
> --- /dev/null
> +++ b/tests/generic/729
> @@ -0,0 +1,53 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2015 Red Hat Inc. All Rights Reserved.
> +# Copyright (c) 2023 Christoph Hellwig
> +#
> +# Test proper file system shut down when the block device is removed underneath
> +# and there is dirty data.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +_cleanup()
> +{
> +	cd /
> +	$UMOUNT_PROG $SCRATCH_MNT >>$seqres.full 2>&1
> +	_put_scsi_debug_dev
> +	rm -f $tmp.*
> +}
> +
> +. ./common/filter
> +. ./common/scsi_debug
> +
> +_supported_fs generic
> +_require_scsi_debug
> +
> +physical=`blockdev --getpbsz $SCRATCH_DEV`
> +logical=`blockdev --getss $SCRATCH_DEV`

These two tests need to _notrun if SCRATCH_DEV is not a blockdev or if
SCRATCH_MNT is not a directory.  Normally _require_scratch_nocheck takes
care of that.

Other than that they look ok.

--D

> +
> +SCSI_DEBUG_DEV=`_get_scsi_debug_dev ${physical:-512} ${logical:-512} 0 300`
> +test -b "$SCSI_DEBUG_DEV" || _notrun "Failed to initialize scsi debug device"
> +echo "SCSI debug device $SCSI_DEBUG_DEV" >>$seqres.full
> +
> +_mkfs_dev $SCSI_DEBUG_DEV
> +
> +_mount $SCSI_DEBUG_DEV $SCRATCH_MNT
> +
> +# create a test file
> +$XFS_IO_PROG -f -c "pwrite 0 1M" $SCRATCH_MNT/testfile >>$seqres.full
> +
> +# open a file descriptor for reading the file
> +exec 3< $SCRATCH_MNT/testfile
> +
> +# delete the scsi debug device while it still has dirty data
> +echo 1 > /sys/block/`_short_dev $SCSI_DEBUG_DEV`/device/delete
> +
> +# try to read from the file, which should give us -EIO
> +cat <&3 > /dev/null
> +
> +# close the file descriptor to not block unmount
> +exec 3<&-
> +
> +status=0
> +exit
> diff --git a/tests/generic/729.out b/tests/generic/729.out
> new file mode 100644
> index 00000000..8abf2b3c
> --- /dev/null
> +++ b/tests/generic/729.out
> @@ -0,0 +1,2 @@
> +QA output created by 729
> +cat: -: Input/output error
> -- 
> 2.39.2
> 

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

* Re: [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-01 15:25   ` Darrick J. Wong
@ 2023-06-01 15:27     ` Christoph Hellwig
  2023-06-01 16:04       ` Darrick J. Wong
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2023-06-01 15:27 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, fstests, linux-fsdevel

On Thu, Jun 01, 2023 at 08:25:36AM -0700, Darrick J. Wong wrote:
> > +_require_scsi_debug
> > +
> > +physical=`blockdev --getpbsz $SCRATCH_DEV`
> > +logical=`blockdev --getss $SCRATCH_DEV`
> 
> These two tests need to _notrun if SCRATCH_DEV is not a blockdev or if
> SCRATCH_MNT is not a directory.  Normally _require_scratch_nocheck takes
> care of that.
> 
> Other than that they look ok.

Can SCRATCH_MNT be not a directory?

But yeah, these tests should simply grow a

_require_block_device $SCRATCH_DEV


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

* Re: [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-01 15:27     ` Christoph Hellwig
@ 2023-06-01 16:04       ` Darrick J. Wong
  2023-06-02  4:13         ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2023-06-01 16:04 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: fstests, linux-fsdevel

On Thu, Jun 01, 2023 at 05:27:40PM +0200, Christoph Hellwig wrote:
> On Thu, Jun 01, 2023 at 08:25:36AM -0700, Darrick J. Wong wrote:
> > > +_require_scsi_debug
> > > +
> > > +physical=`blockdev --getpbsz $SCRATCH_DEV`
> > > +logical=`blockdev --getss $SCRATCH_DEV`
> > 
> > These two tests need to _notrun if SCRATCH_DEV is not a blockdev or if
> > SCRATCH_MNT is not a directory.  Normally _require_scratch_nocheck takes
> > care of that.
> > 
> > Other than that they look ok.
> 
> Can SCRATCH_MNT be not a directory?

Good question.  AFAICT the only checks on it are in
_require_scratch_nocheck itself...

> But yeah, these tests should simply grow a
> 
> _require_block_device $SCRATCH_DEV

...but you could set up the scsi_debug device and mount it on
$TEST_DIR/foo which would avoid the issue of checking SCRATCH_*
entirely.

(Please remember to _require_test if you do though.)

--D

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

* Re: [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-01 16:04       ` Darrick J. Wong
@ 2023-06-02  4:13         ` Christoph Hellwig
  2023-06-02 10:58           ` Zorro Lang
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2023-06-02  4:13 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Christoph Hellwig, fstests, linux-fsdevel

On Thu, Jun 01, 2023 at 09:04:50AM -0700, Darrick J. Wong wrote:
> Good question.  AFAICT the only checks on it are in
> _require_scratch_nocheck itself...
> 
> > But yeah, these tests should simply grow a
> > 
> > _require_block_device $SCRATCH_DEV
> 
> ...but you could set up the scsi_debug device and mount it on
> $TEST_DIR/foo which would avoid the issue of checking SCRATCH_*
> entirely.

I thought about that as we really don't need a SCRATCH_DEV, but
how do we ensure we are testing a block based file system then?

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

* Re: [PATCH 1/2] generic: add a test for device removal with dirty data
  2023-06-02  4:13         ` Christoph Hellwig
@ 2023-06-02 10:58           ` Zorro Lang
  0 siblings, 0 replies; 8+ messages in thread
From: Zorro Lang @ 2023-06-02 10:58 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Darrick J. Wong, fstests, linux-fsdevel

On Fri, Jun 02, 2023 at 06:13:41AM +0200, Christoph Hellwig wrote:
> On Thu, Jun 01, 2023 at 09:04:50AM -0700, Darrick J. Wong wrote:
> > Good question.  AFAICT the only checks on it are in
> > _require_scratch_nocheck itself...
> > 
> > > But yeah, these tests should simply grow a
> > > 
> > > _require_block_device $SCRATCH_DEV
> > 
> > ...but you could set up the scsi_debug device and mount it on
> > $TEST_DIR/foo which would avoid the issue of checking SCRATCH_*
> > entirely.
> 
> I thought about that as we really don't need a SCRATCH_DEV, but
> how do we ensure we are testing a block based file system then?

Maybe

  _require_test
  _require_block_device $TEST_DEV

can help to make sure the FSTYP is a localfs?

Thanks,
Zorro

> 


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

end of thread, other threads:[~2023-06-02 10:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01  9:42 add device removal test Christoph Hellwig
2023-06-01  9:42 ` [PATCH 1/2] generic: add a test for device removal with dirty data Christoph Hellwig
2023-06-01 15:25   ` Darrick J. Wong
2023-06-01 15:27     ` Christoph Hellwig
2023-06-01 16:04       ` Darrick J. Wong
2023-06-02  4:13         ` Christoph Hellwig
2023-06-02 10:58           ` Zorro Lang
2023-06-01  9:42 ` [PATCH 2/2] generic: add a test for device removal without " Christoph Hellwig

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).