summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_shutdown.c
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>2005-09-08 06:30:05 +0000
committertruckman <truckman@FreeBSD.org>2005-09-08 06:30:05 +0000
commitd2af5326c994aa94a5ea74bb305f2ef113aa3f37 (patch)
treea7c1284d2223edd7814ccb561907d21453d07e6b /sys/kern/kern_shutdown.c
parent23fa8aa7880a44dca26cb97693a3ce5615169037 (diff)
downloadFreeBSD-src-d2af5326c994aa94a5ea74bb305f2ef113aa3f37.zip
FreeBSD-src-d2af5326c994aa94a5ea74bb305f2ef113aa3f37.tar.gz
Add a new struct buf flag bit, B_PERSISTENT, and use it to tag
struct bufs that are persistently held by ext2fs. Ignore any buffers with this flag in the code in boot() that counts "busy" and dirty buffers and attempts to sync the dirty buffers, which is done before attempting to unmount all the file systems during shutdown. This fixes the problem caused by any ext2fs file systems that are mounted at system shutdown time, which caused boot() to give up on a non-zero number of buffers and skip the call to vfs_unmountall(). This left all the mounted file systems in a dirty state and caused them to all require cleanup by fsck on reboot. Move the two separate copies of the "busy" buffer test in boot() to a separate function. Nuke the useless spl() stuff in the ext2fs ULCK_BUF() macro. Bring the PRINT_BUF_FLAGS definition in sys/buf.h up to date with this and previous flag changes. PR: kern/56675, kern/85163 Tested by: "Matthias Andree" matthias.andree at gmx.de Reviewed by: bde MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_shutdown.c')
-rw-r--r--sys/kern/kern_shutdown.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index a22cea2..9b70f18 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -236,6 +236,16 @@ doadump(void)
dumpsys(&dumper);
}
+static int
+isbufbusy(struct buf *bp)
+{
+ if (((bp->b_flags & (B_INVAL | B_PERSISTENT)) == 0 &&
+ BUF_REFCNT(bp) > 0) ||
+ ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI))
+ return (1);
+ return (0);
+}
+
/*
* Shutdown the system cleanly to prepare for reboot, halt, or power off.
*/
@@ -288,16 +298,9 @@ boot(int howto)
*/
for (iter = pbusy = 0; iter < 20; iter++) {
nbusy = 0;
- for (bp = &buf[nbuf]; --bp >= buf; ) {
- if ((bp->b_flags & B_INVAL) == 0 &&
- BUF_REFCNT(bp) > 0) {
+ for (bp = &buf[nbuf]; --bp >= buf; )
+ if (isbufbusy(bp))
nbusy++;
- } else if ((bp->b_flags & (B_DELWRI | B_INVAL))
- == B_DELWRI) {
- /* bawrite(bp);*/
- nbusy++;
- }
- }
if (nbusy == 0) {
if (first_buf_printf)
printf("All buffers synced.");
@@ -343,8 +346,7 @@ boot(int howto)
*/
nbusy = 0;
for (bp = &buf[nbuf]; --bp >= buf; ) {
- if (((bp->b_flags&B_INVAL) == 0 && BUF_REFCNT(bp)) ||
- ((bp->b_flags & (B_DELWRI|B_INVAL)) == B_DELWRI)) {
+ if (isbufbusy(bp)) {
#if 0
/* XXX: This is bogus. We should probably have a BO_REMOTE flag instead */
if (bp->b_dev == NULL) {
OpenPOWER on IntegriCloud