From: Anand Jain <anajain.sg@gmail.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] generic: test case for reappearing device
Date: Thu, 18 Sep 2025 08:32:47 +0800 [thread overview]
Message-ID: <4cc549240200e8ac3b4646c99fef5fcf30ef6f2d.1758148804.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1758148804.git.anand.jain@oracle.com>
From: Anand Jain <anand.jain@oracle.com>
Tests how the filesystem handles a device that reappears with a different
MAJ:MIN due to a block layer transport failure.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
tests/generic/809 | 72 +++++++++++++++++++++++++++++++++++++++++++
tests/generic/809.out | 2 ++
2 files changed, 74 insertions(+)
create mode 100755 tests/generic/809
create mode 100644 tests/generic/809.out
diff --git a/tests/generic/809 b/tests/generic/809
new file mode 100755
index 000000000000..3e9943f9ac85
--- /dev/null
+++ b/tests/generic/809
@@ -0,0 +1,72 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle. All Rights Reserved.
+#
+# FS QA Test 809
+#
+# Tests how the filesystem handles a device that reappears with a different
+# MAJ:MIN while the old MAJ:MIN is still mounted and in use, due to a block
+# layer transport failure.
+
+. ./common/preamble
+
+_begin_fstest auto quick tempfsid shutdown
+
+_cleanup()
+{
+ local new_blk_handle
+
+ cd /
+ rm -r -f $tmp.*
+ $UMOUNT_PROG $mnt1 &> /dev/null
+ $UMOUNT_PROG $SCRATCH_MNT &> /dev/null
+
+ if [[ ! -b $new_scratch_dev ]]; then
+ echo "_cleanup: failed to restore the scratch device."
+ return
+ fi
+ new_blk_handle=$(_bdev_handle $new_scratch_dev)
+ _devmgt_remove $new_blk_handle $new_scratch_dev
+ _devmgt_add $new_blk_handle
+
+ [[ -b $SCRATCH_DEV ]] || \
+ echo "_cleanup: failed to restore scratch device."
+}
+
+_require_test
+_require_scratch
+_require_scratch_bdev_delete
+
+mnt1=$TEST_DIR/$seq/mnt1
+rm -r -f $mnt1
+mkdir -p $mnt1
+
+_scratch_mkfs >> /dev/null
+_scratch_mount
+
+$XFS_IO_PROG -fc 'pwrite -S 0x61 0 9000' $SCRATCH_MNT/foo >> $seqres.full
+_mount $SCRATCH_DEV $mnt1
+$UMOUNT_PROG $mnt1
+
+# Ensure data is flushed to disk before the device disappears
+sync
+
+id1=$(lsblk -ndo MAJ:MIN $SCRATCH_DEV)
+scratch_fsid=$(blkid --probe --match-tag UUID $SCRATCH_DEV | \
+ $AWK_PROG '{print $2}' | sed -e 's/UUID=//g' | sed -e 's/\"//g')
+blk_handle=$(_bdev_handle $SCRATCH_DEV)
+_devmgt_remove $blk_handle $SCRATCH_DEV
+_devmgt_add $blk_handle
+new_scratch_dev=$(blkid -l -o device -t UUID=$scratch_fsid)
+id2=$(lsblk -ndo MAJ:MIN $new_scratch_dev)
+[[ -b $new_scratch_dev ]] || _fail "Device failed to reappear"
+[[ "$id1" != "$id2" ]] || \
+ _not_run "Device cannot reappear with a different major:minor"
+
+# Mount the reappeared device while the old node is still mounted
+# (not supported on XFS).
+[[ $FSTYP == "xfs" ]] && $UMOUNT_PROG $SCRATCH_MNT
+_mount $new_scratch_dev $mnt1
+echo Silence is golden
+status=0
+exit
diff --git a/tests/generic/809.out b/tests/generic/809.out
new file mode 100644
index 000000000000..e90865ca8f8c
--- /dev/null
+++ b/tests/generic/809.out
@@ -0,0 +1,2 @@
+QA output created by 809
+Silence is golden
--
2.51.0
next prev parent reply other threads:[~2025-09-18 0:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 0:32 [PATCH 0/2] fstests: test device reappearance with new maj:min Anand Jain
2025-09-18 0:32 ` [PATCH 1/2] common/rc: helper functions to handle block devices via sysfs Anand Jain
2025-09-26 15:57 ` Zorro Lang
2025-09-30 3:47 ` Anand Jain
2025-09-18 0:32 ` Anand Jain [this message]
2025-09-18 17:15 ` [PATCH 0/2] fstests: test device reappearance with new maj:min Neal Gompa
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=4cc549240200e8ac3b4646c99fef5fcf30ef6f2d.1758148804.git.anand.jain@oracle.com \
--to=anajain.sg@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@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).