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
This commit is contained in:
Mark Johnston
2026-01-25 15:12:19 +00:00
parent 58580dc0c6
commit d6bc31f929
+2 -2
View File
@@ -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
}