diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2021-11-28 01:52:46 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2021-11-29 16:38:02 +0000 |
commit | 08bb51f8d60c552d1f7c202cc2eb267ed480e541 (patch) | |
tree | e939f2136caf28d1c1c964ca06d6b4748e6d23b6 | |
parent | 0190c38b9dfaa16de1bc61e829b9a1221fed7896 (diff) | |
download | src-08bb51f8d60c552d1f7c202cc2eb267ed480e541.tar.gz src-08bb51f8d60c552d1f7c202cc2eb267ed480e541.zip |
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
-rw-r--r-- | sys/kern/vfs_bio.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 4b746a269171..8d6eac800caf 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -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 */ } |