Download raw body.
need help with test: sys/vfs: stop checkalias replacing vnodes
need help with test: sys/vfs: stop checkalias replacing vnodes
need help with test: sys/vfs: stop checkalias replacing vnodes
On Wed, 11 Nov 2026 03:46:40 +0100,
Yamasaki Yuu <miagetegorann@gmail.com> wrote:
>
> Since "sys/vfs: stop checkalias replacing vnodes" (9274ed7885f in the
> git mirror, 2026-11-08), the root swap partition is configured twice
> at boot. swapctl -A in rc now adds it a second time:
>
> swapctl: adding 0b85468de71a22af.b as swap device at priority 0
>
> $ pstat -s
> Device 512-blocks Used Avail Capacity Priority
> /dev/sd0b 524256 0 524256 0% 0
> /dev/sd0b 524256 0 524256 0% 0
> Total 1048512 0 1048512 0%
>
> GENERIC.MP built from the parent commit lists sd0b once, and
> swapctl -A gets EBUSY there as before. The duplicate is still there
> at 6afb24b0786. Seen on amd64 under QEMU with an AHCI disk.
>
> swapmount() gets its vnode from bdevvp(), swapctl -A gets one through
> namei(), and swaplist_find() compares vnode pointers. ffs_vinit()
> used to replace its vnode with the VT_NON alias returned by
> checkalias(), so both were the same vnode and SWAP_ON failed with
> EBUSY. Now they are two vnodes for the same dev_t.
>
> The same lookup is used by SWAP_OFF and SWAP_CTL, so the partition the
> kernel configured can't be removed by path any more. Of two SWAP_OFF
> calls on /dev/sd0b, the first removes the entry rc added and the
> second fails with ENXIO; sd0b stays in the list. swapctl -d makes
> the same call.
>
> Both entries cover the same blocks, so paging corrupts memory. Under
> QEMU with 512 MB of RAM, a pattern test that fills and checks 560 MB
> finished with no bad words on the parent commit. On 9274ed7885f the
> test program and sshd crashed during the same test.
>
> The diff below makes swaplist_find() match block devices on swd_dev as
> well. With it on top of 6afb24b0786 (amd64 GENERIC.MP, QEMU, 512 MB of
> RAM): rc no longer adds sd0b and pstat -s lists it once; a second
> SWAP_ON fails with EBUSY; the pattern test finishes with no bad words;
> SWAP_OFF of /dev/sd0b, SWAP_ON and SWAP_ON again (EBUSY) work.
>
Thansk for the report.
Yesterday I had send to miod@ this diff which addressed the problem.
Anyway, I had reverted my checkaliases diff which uncovered the issue.
The diff:
Index: sys/uvm/uvm_swap.c
===================================================================
RCS file: /home/cvs/src/sys/uvm/uvm_swap.c,v
diff -u -p -r1.185 uvm_swap.c
--- sys/uvm/uvm_swap.c 8 Nov 2026 08:42:55 -0000 1.185
+++ sys/uvm/uvm_swap.c 10 Nov 2026 22:19:13 -0000
@@ -58,6 +58,7 @@
#include <nfs/nfsproto.h>
#include <nfs/nfsdiskless.h>
#endif
+#include <sys/lock.h>
#include <uvm/uvm.h>
#ifdef UVM_SWAP_ENCRYPT
@@ -471,7 +472,8 @@ swaplist_find(struct vnode *vp, boolean_
*/
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
TAILQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) {
- if (sdp->swd_vp != vp)
+ if (sdp->swd_vp != vp &&
+ (vp->v_type != VBLK || sdp->swd_dev != vp->v_rdev))
continue;
if (remove) {
TAILQ_REMOVE(&spp->spi_swapdev, sdp, swd_next);
@@ -773,8 +775,17 @@ sys_swapctl(struct proc *p, void *v, reg
}
/*
- * do the real work.
+ * swap_off() drops the swap reference before closing the vnode.
+ * Hold a reference to that vnode even when named by an alias.
*/
+ if (vp != sdp->swd_vp) {
+ mtx_leave(&uvm_swap_data_lock);
+ vput(vp);
+ vp = sdp->swd_vp;
+ if ((error = vget(vp, LK_EXCLUSIVE | LK_RETRY)) != 0)
+ goto out;
+ mtx_enter(&uvm_swap_data_lock);
+ }
error = swap_off(p, sdp);
break;
default:
--
wbr, Kirill
need help with test: sys/vfs: stop checkalias replacing vnodes
need help with test: sys/vfs: stop checkalias replacing vnodes
need help with test: sys/vfs: stop checkalias replacing vnodes