Date: Mon, 19 Apr 1999 11:16:04 -0700 (PDT) From: Ted Faber <faber@ISI.EDU> To: FreeBSD-gnats-submit@freebsd.org Subject: kern/11222: MFS does not sync from reboot syscall Message-ID: <199904191816.LAA02511@vermouth.isi.edu>
next in thread | raw e-mail | index | archive | help
>Number: 11222 >Category: kern >Synopsis: MFS does not sync from reboot syscall >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 19 11:20:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Ted Faber >Release: FreeBSD 3.1-RELEASE i386 >Organization: USC/ISI >Environment: FreeBSD 3.1-RELEASE running XFree86-3.3.3.1 >Description: If there are dirty buffers from an MFS file system when the reboot syscall is made, those buffers are never cleaned. Therefore all filesystems (including real disk-based ones) are not unmounted cleanly, requiring a full fsck on reboot. Internally the problem is that the MFS strategy routine, which is called by the sync calls in reboot (syscall), queues buffers for the MFS process itself to write, and wakes that process up. The reboot syscall never releases the processor, so those buffers remain dirty. The enclosed patch adds code to the reboot syscall to detect such MFS mounted buffers and if they are present, release the processor to allow the MFS to clean up after itself. The patch also raises the MFS process's sleep priority to make sure that it runs when reboot releases the processor. The patch is relative to /sys on a 3.1-RELEASE system. It modifies /sys/kern/kern_shutdown.c and /sys/ufs/mfs/nfs_vfsops.c >How-To-Repeat: I was able to consistently reproduce the problem by rebooting from a complex X session that uses /tmp (an MFS) extensively. The default root X session does not tickle the bug. Although I didn't try it, I would bet that rebooting while one or more processes was rewriting a file to an MFS file system would also work. >Fix: The enclosed patch allows the buffers to be cleaned. Without the patch, users can reboot their system by using shutdown and manually umounting /tmp (the MFS) before rebooting. The patch is relative to /sys on a 3.1-RELEASE system. It modifies /sys/kern/kern_shutdown.c and /sys/ufs/mfs/nfs_vfsops.c *** kern/kern_shutdown.c.orig Mon Dec 28 15:03:00 1998 --- kern/kern_shutdown.c Sun Apr 18 14:35:02 1999 *************** *** 196,201 **** --- 196,202 ---- if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) { register struct buf *bp; int iter, nbusy; + int mfs = 0; /* Number of buffers on MFS filesystems */ waittime = 0; printf("\nsyncing disks... "); *************** *** 218,228 **** --- 219,241 ---- /* bawrite(bp);*/ nbusy++; } + if ( major(bp->b_dev) == 0xff && + bp->b_dev != NODEV) + mfs++; } if (nbusy == 0) break; printf("%d ", nbusy); sync(&proc0, NULL); + if ( mfs ) { + /* + * there are MFS bufferes to sync. Give + * up the processor so the MFS code can + * clean the buffers + */ + mfs = 0; + tsleep(&proc0, PWAIT, "rmfswait",1); + } DELAY(50000 * iter); } /* *** ufs/mfs/mfs_vfsops.c.orig Thu Dec 31 20:14:11 1998 --- ufs/mfs/mfs_vfsops.c Sun Apr 18 14:29:24 1999 *************** *** 367,373 **** } ! static int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */ /* * Used to grab the process and keep it in the kernel to service --- 367,373 ---- } ! static int mfs_pri = PRIBIO | PCATCH; /* XXX prob. temp */ /* * Used to grab the process and keep it in the kernel to service >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904191816.LAA02511>