From: ASOU Masato Subject: Close the existing keydisk.img. To: tech@openbsd.org Cc: YASUOKA Masahiko , Masato ASOU Date: Mon, 9 Feb 2026 16:07:29 +0900 Hi, When I run the make command in regress/usr.sbin/install for the second time, vnd2 fails to be unconfigured. The problem does not occur if the make clean command is run (to delete keydisk.img) before the second time. If keydisk.img was generatad with the dd command during the first run, softraid_crypto.c: sr_crypto_create_key_disk() execute VOP_CLOSE("vnd2"). However, if keydisk.img from the previous run still exists, softraid_crypto.c: sr_crypto_read_key_disk() does not execute VOP_CLOSE("vnd2"). The patch is included at the end of this email. The below is first time and vnd2 success to be unconfigured. $ cd /usr/src/regress/usr.sbin/installboot $ doas make doas (asou@obsd78-vnconfig.example.co.jp) password: ==== create-root ==== dd if=/dev/zero of=disk1.img bs=1m count=0 seek=768 status=none vnconfig -- disk1.img 1>diskdev1.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null dd if=/dev/zero of=disk2.img bs=1m count=0 seek=768 status=none vnconfig -- disk2.img 1>diskdev2.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null dd if=/dev/zero of=keydisk.img bs=1m count=0 seek=768 status=none vnconfig -- keydisk.img 1>keydev.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null bioctl -l"$(sed -- s/$/a/ diskdev1.txt diskdev2.txt | paste -sd, -- -)" -c1C -k"$(rootdev.txt fdisk -gy -b 532480 -- "$(/dev/null disklabel -Aw -- "$(/dev/null newfs: reduced number of fragments per cylinder group from 31696 to 31432 to enlarge last cylinder group mkdir -p -- mnt mount -- /dev/"$(/dev/null *** Error 1 in . (Makefile:142 'dry-prepare-root') EXPECTED_FAIL ==== dry-prepare-stages ==== /usr/sbin/installboot -n -p -- "$(/dev/null *** Error 1 in . (Makefile:144 'dry-prepare-stages') EXPECTED_FAIL ==== dry-nodisk-stages ==== /usr/sbin/installboot -n -- /usr/mdec/biosboot /usr/mdec/boot 2>/dev/null *** Error 1 in . (Makefile:147 'dry-nodisk-stages') EXPECTED_FAIL ==== dry-toofew ==== /usr/sbin/installboot -n -- 2>/dev/null *** Error 1 in . (Makefile:150 'dry-toofew') EXPECTED_FAIL ==== dry-toomany ==== /usr/sbin/installboot -n -- disk stage1 stage2 too many 2>/dev/null *** Error 1 in . (Makefile:152 'dry-toomany') EXPECTED_FAIL ==== cleanup ==== umount -- mnt 2>/dev/null rmdir -- mnt 2>/dev/null bioctl -d -- "$(/dev/null vnconfig -u -- "$(/dev/null vnconfig -u -- "$(/dev/null vnconfig -u -- "$(/dev/null $ doas vnconfig -l vnd0: not in use vnd1: not in use vnd2: not in use vnd3: not in use $ The above seems fine. However, when I run the make command again, vnd2 fails to be unconfigured. $ doas make ==== create-root ==== dd if=/dev/zero of=disk1.img bs=1m count=0 seek=768 status=none vnconfig -- disk1.img 1>diskdev1.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null dd if=/dev/zero of=disk2.img bs=1m count=0 seek=768 status=none vnconfig -- disk2.img 1>diskdev2.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null dd if=/dev/zero of=keydisk.img bs=1m count=0 seek=768 status=none vnconfig -- keydisk.img 1>keydev.txt fdisk -gy -b 532480 -- "$(/dev/null echo 'RAID *' | disklabel -wAT- -- "$(/dev/null bioctl -l"$(sed -- s/$/a/ diskdev1.txt diskdev2.txt | paste -sd, -- -)" -c1C -k"$(rootdev.txt fdisk -gy -b 532480 -- "$(/dev/null disklabel -Aw -- "$(/dev/null newfs: reduced number of fragments per cylinder group from 31696 to 31432 to enlarge last cylinder group mkdir -p -- mnt mount -- /dev/"$(/dev/null *** Error 1 in . (Makefile:142 'dry-prepare-root') EXPECTED_FAIL ==== dry-prepare-stages ==== /usr/sbin/installboot -n -p -- "$(/dev/null *** Error 1 in . (Makefile:144 'dry-prepare-stages') EXPECTED_FAIL ==== dry-nodisk-stages ==== /usr/sbin/installboot -n -- /usr/mdec/biosboot /usr/mdec/boot 2>/dev/null *** Error 1 in . (Makefile:147 'dry-nodisk-stages') EXPECTED_FAIL ==== dry-toofew ==== /usr/sbin/installboot -n -- 2>/dev/null *** Error 1 in . (Makefile:150 'dry-toofew') EXPECTED_FAIL ==== dry-toomany ==== /usr/sbin/installboot -n -- disk stage1 stage2 too many 2>/dev/null *** Error 1 in . (Makefile:152 'dry-toomany') EXPECTED_FAIL ==== cleanup ==== umount -- mnt 2>/dev/null rmdir -- mnt 2>/dev/null bioctl -d -- "$(/dev/null vnconfig -u -- "$(/dev/null vnconfig -u -- "$(/dev/null vnconfig -u -- "$(/dev/null *** Error 1 in target 'cleanup' (ignored) $ doas vnconfig -l vnd0: not in use vnd1: not in use vnd2: covering keydisk.img on sd0f, inode 77924 vnd3: not in use $ comment? ok? -- ASOU Masato diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index 6e24f2ff4f5..8e52701e5f9 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -837,7 +837,7 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, struct sr_crypto *mdd_crypto, vput(vn); goto done; } - open = 1; /* close dev on error */ + open = 1; /* Get partition details. */ label = malloc(sizeof(*label), M_DEVBUF, M_WAITOK); @@ -900,8 +900,6 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, struct sr_crypto *mdd_crypto, } } - open = 0; - done: for (omi = SLIST_FIRST(&som); omi != NULL; omi = omi_next) { omi_next = SLIST_NEXT(omi, omi_link);