shutdown: unmount filesystems after swapoff

Swap on file requires operational underlying mount, otherwise
swapoff_all() is guaranteed to panic due to the default strategy VOP for
reclaimed vnodes.

Reported and tested by:	peterj
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33147
This commit is contained in:
Konstantin Belousov 2021-11-28 03:52:46 +02:00
parent 0190c38b9d
commit 08bb51f8d6

View File

@ -1452,16 +1452,21 @@ bufshutdown(int show_busybufs)
*/
printf("Giving up on %d buffers\n", nbusy);
DELAY(5000000); /* 5 seconds */
swapoff_all();
} else {
if (!first_buf_printf)
printf("Final sync complete\n");
/*
* Unmount filesystems
* Unmount filesystems. Swapoff before unmount,
* because file-backed swap is non-operational after unmount
* of the underlying filesystem.
*/
if (!KERNEL_PANICKED())
if (!KERNEL_PANICKED()) {
swapoff_all();
vfs_unmountall();
}
}
swapoff_all();
DELAY(100000); /* wait for console output to finish */
}