git: 0484b6a01a0e - stable/15 - autofs: try to avoid waiting for timeouts of in-flight requests for forced unmounts

Konstantin Belousov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a7b0216.3fcab.836379__40958.9644333877$1786446404$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by kib:

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

commit 0484b6a01a0e4eab1c77f7fb7c65eb64ad5dd408
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2026-08-04 06:26:56 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2026-08-11 11:00:02 +0000

    autofs: try to avoid waiting for timeouts of in-flight requests for forced unmounts
    
    (cherry picked from commit d3c3a705b5e6689798057b764713bfc0e3b69f6a)
---
 sys/fs/autofs/autofs_vfsops.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/sys/fs/autofs/autofs_vfsops.c b/sys/fs/autofs/autofs_vfsops.c
index 473a0b2280ac..3da9909b6c3e 100644
--- a/sys/fs/autofs/autofs_vfsops.c
+++ b/sys/fs/autofs/autofs_vfsops.c
@@ -109,6 +109,33 @@ autofs_mount(struct mount *mp)
 	return (0);
 }
 
+/*
+ * Try to abort any requests currently in flight.  This is not
+ * strictly necessary, the strong pass is done after all vnodes are
+ * reclaimed, and does not prevent new requests from queueing.  But
+ * doing it now should practically avoid waiting for timeouts because
+ * each in-flight requests busies the mount point, which makes
+ * unmount() to wait for it to drain.
+ */
+static void
+autofs_purge(struct mount *mp)
+{
+	struct autofs_mount *amp;
+	struct autofs_request *ar;
+
+	amp = VFSTOAUTOFS(mp);
+	sx_xlock(&autofs_softc->sc_lock);
+	TAILQ_FOREACH(ar, &autofs_softc->sc_requests, ar_next) {
+		if (ar->ar_mount != amp)
+			continue;
+		ar->ar_error = ENXIO;
+		ar->ar_done = true;
+		ar->ar_in_progress = false;
+	}
+	sx_xunlock(&autofs_softc->sc_lock);
+	cv_broadcast(&autofs_softc->sc_cv);
+}
+
 static int
 autofs_unmount(struct mount *mp, int mntflags)
 {
@@ -208,6 +235,7 @@ static struct vfsops autofs_vfsops = {
 	.vfs_fhtovp =		NULL, /* XXX */
 	.vfs_mount =		autofs_mount,
 	.vfs_unmount =		autofs_unmount,
+	.vfs_purge =		autofs_purge,
 	.vfs_root =		autofs_root,
 	.vfs_statfs =		autofs_statfs,
 	.vfs_init =		autofs_init,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.