git: f30c296f200e - stable/15 - swapoff: release vnode held since swapon

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Fri, 20 Nov 2026 09:30:29 UTC
The branch stable/15 has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=f30c296f200e63fd77ce364d30c67950cf07fbee

commit f30c296f200e63fd77ce364d30c67950cf07fbee
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-16 09:57:24 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-19 21:12:45 +0000

    swapoff: release vnode held since swapon
    
    kern_swapon looks up the proposed swap path and aquires a vnode which is
    held (unlocked) throughout the life of the swap device.  In the device
    case (swapgeom) it was never released in the swapoff path.
    
    Remove an incorrect comment about swapgeom_close being called from
    biodone.  It is only called directly via swapoff(2) or at the end of the
    shutdown path.
    
    Reviewed by:    kib, markj
    Reported by:    llm-postcr
    MFC after:      3 days
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D61465
    
    (cherry picked from commit 933f5f616a8a44b7af6cdccecf959ef1e8bab66e)
---
 sys/vm/swap_pager.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 2b5fc64de771..3bbc2b8b123c 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -3269,13 +3269,14 @@ swapgeom_close(struct thread *td, struct swdevt *sw)
 	sw->sw_id = NULL;
 	mtx_unlock(&sw_dev_mtx);
 
-	/*
-	 * swapgeom_close() may be called from the biodone context,
-	 * where we cannot perform topology changes.  Delegate the
-	 * work to the events thread.
-	 */
 	if (cp != NULL)
 		g_waitfor_event(swapgeom_close_ev, cp, M_WAITOK, NULL);
+
+	/*
+	 * Release the reference added by kern_swapon when resolving the
+	 * vnode.
+	 */
+	vrele(sw->sw_vp);
 }
 
 static int