From: Christoph Hellwig <hch@lst.de>
To: fstests@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/2] generic: add a test for device removal with dirty data
Date: Thu, 1 Jun 2023 11:42:23 +0200 [thread overview]
Message-ID: <20230601094224.1350253-2-hch@lst.de> (raw)
In-Reply-To: <20230601094224.1350253-1-hch@lst.de>
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
next prev parent reply other threads:[~2023-06-01 9:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 9:42 add device removal test Christoph Hellwig
2023-06-01 9:42 ` Christoph Hellwig [this message]
2023-06-01 15:25 ` [PATCH 1/2] generic: add a test for device removal with dirty data 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230601094224.1350253-2-hch@lst.de \
--to=hch@lst.de \
--cc=fstests@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).