From d6bc31f92991b6d67da54868f3563278015389ca Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Sun, 25 Jan 2026 15:12:19 +0000 Subject: [PATCH] makefs/zfs/tests: Force-destroy md devices Most of these tests create a md(4) device backed by a makefs-generated image, then import the pool, using the md device as a pool vdev. When a test finishes, it destroys the pool, then destroys the md device. Once in a while md device destruction fails with EBUSY. This happens when a GEOM consumer is holding the device open; kern_mddetach_locked() simply fails if any consumers are present. zpool destruction is synchronous so ZFS is innocent, rather, the problem seems to be that GEOM re-tastes the device after the zpool reference goes away. This operation creates a transient reference that causes the spurious failure. Use "mdconfig -o force" to work around this. MFC after: 2 weeks --- usr.sbin/makefs/tests/makefs_zfs_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/makefs/tests/makefs_zfs_tests.sh b/usr.sbin/makefs/tests/makefs_zfs_tests.sh index 9d5ce300843..7f0187be054 100644 --- a/usr.sbin/makefs/tests/makefs_zfs_tests.sh +++ b/usr.sbin/makefs/tests/makefs_zfs_tests.sh @@ -51,7 +51,7 @@ common_cleanup() if [ -f "$TEST_MD_DEVICE_FILE" ]; then md=$(cat $TEST_MD_DEVICE_FILE) if [ -c /dev/"$md" ]; then - mdconfig -d -u "$md" + mdconfig -o force -d -u "$md" fi fi } @@ -210,7 +210,7 @@ compression_body() atf_check zpool destroy ${ZFS_POOL_NAME} atf_check rm -f ${TEST_ZFS_POOL_NAME} - atf_check mdconfig -d -u $(cat ${TEST_MD_DEVICE_FILE}) + atf_check mdconfig -o force -d -u $(cat ${TEST_MD_DEVICE_FILE}) atf_check rm -f ${TEST_MD_DEVICE_FILE} done }