From owner-freebsd-bugs Mon Apr 19 11:22:31 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id C263A15160 for ; Mon, 19 Apr 1999 11:22:26 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id LAA03775; Mon, 19 Apr 1999 11:20:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from zephyr.isi.edu (zephyr.isi.edu [128.9.160.160]) by hub.freebsd.org (Postfix) with ESMTP id 6EE091563A for ; Mon, 19 Apr 1999 11:18:30 -0700 (PDT) (envelope-from faber@ISI.EDU) Received: from vermouth.isi.edu (vermouth.isi.edu [128.9.160.247]) by zephyr.isi.edu (8.8.7/8.8.6) with ESMTP id LAA10698 for ; Mon, 19 Apr 1999 11:16:01 -0700 (PDT) Received: (from faber@localhost) by vermouth.isi.edu (8.9.2/8.8.5) id LAA02511; Mon, 19 Apr 1999 11:16:04 -0700 (PDT) Message-Id: <199904191816.LAA02511@vermouth.isi.edu> Date: Mon, 19 Apr 1999 11:16:04 -0700 (PDT) From: Ted Faber Reply-To: faber@ISI.EDU To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/11222: MFS does not sync from reboot syscall Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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