From peter@vk2pj.alcatel.com.au  Tue Jan  7 02:11:56 1997
Received: from gatekeeper.alcatel.com.au (gatekeeper.alcatel.com.au [203.17.66.1])
          by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id CAA11947
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 7 Jan 1997 02:11:51 -0800 (PST)
Received: from 139.188.22.50 (139.188.22.50) by gatekeeper.alcatel.com.au
 (PMDF V5.0-5 #11861) id <01IDY1W33E4G0008D7@gatekeeper.alcatel.com.au> for
 FreeBSD-gnats-submit@freebsd.org; Tue, 07 Jan 1997 21:10:27 +1000
Received: from vk2pj.alcatel.com.au (vk2pj.alcatel.com.au)
 by cbd.alcatel.com.au (PMDF V5.0-5 #9241)
 id <01IDY1UTYQGW9QVJ65@cbd.alcatel.com.au> for
 FreeBSD-gnats-submit@freebsd.org; Tue, 07 Jan 1997 21:09:31 +1100
Received: (from peter@localhost) by vk2pj.alcatel.com.au (8.7.5/8.7.3)
 id VAA03372; Tue, 07 Jan 1997 21:10:51 +1100 (EST)
Message-Id: <199701071010.VAA03372@vk2pj.alcatel.com.au>
Date: Tue, 07 Jan 1997 21:10:51 +1100 (EST)
From: peter.jeremy@alcatel.com.au
Reply-To: peter.jeremy@alcatel.com.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: filesystems not unmounted following shutdown -h
X-Send-Pr-Version: 3.2

>Number:         2393
>Category:       kern
>Synopsis:       filesystems not unmounted following shutdown -h
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    grog
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan  7 02:20:02 PST 1997
>Closed-Date:    Fri Jul 9 18:07:05 PDT 1999
>Last-Modified:  Fri Jul  9 18:07:59 PDT 1999
>Originator:     Peter Jeremy
>Release:        FreeBSD 2.1-STABLE i386
>Organization:
Peter Jeremy (VK2PJ)			peter.jeremy@alcatel.com.au
Alcatel Australia Limited
41 Mandible St				Phone: +61 2 9690 5019
ALEXANDRIA  NSW  2015			Fax:   +61 2 9690 5247
>Environment:

Clone VLB i486DX2-50 with no-name VLB IDE controller.
FreeBSD 2.1.5-RELEASE #0: Tue Dec 31 06:45:18 EST 1996
    root@vk2pj.alcatel.com.au:/home/src/FreeBSD/sys/compile/vk2pj
CPU: i486DX (486-class CPU)
real memory  = 20971520 (20480K bytes)
avail memory = 18784256 (18344K bytes)
Probing for devices on the ISA bus:
sc0 at 0x60-0x6f irq 1 on motherboard
sc0: VGA color {16 virtual consoles, flags=0x0}
sio0 at 0x3f8-0x3ff irq 4 on isa
sio0: type 16450
sio1 at 0x2f8-0x2ff irq 9 on isa
sio1: type 16550A
sio2 at 0x3e8-0x3ef irq 3 on isa
sio2: type 16450
lpt0 at 0x378-0x37f irq 7 on isa
lpt0: Interrupt-driven port
lp0: TCP/IP capable interface
lpt1 at 0x278-0x27f irq 5 on isa
lpt1: Interrupt-driven port
lp1: TCP/IP capable interface
pca0 on motherboard
pca0: PC speaker audio driver
fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa
fdc0: NEC 765
fd0: 1.44MB 3.5in
wdc0 at 0x1f0-0x1f7 irq 14 on isa
wdc0: unit 0 (wd0): {Conner Peripherals 420MB - CFS420A}, 32-bit, multi-block-64
wd0: 406MB (832608 sectors), 826 cyls, 16 heads, 63 S/T, 512 B/S
aha0 at 0x334-0x337 irq 11 drq 6 on isa
(aha0:6:0): "ARCHIVE VIPER 150  21247 -005" type 1 removable SCSI 1
st0(aha0:6:0): Sequential-Access st0: Archive  Viper 150 is a known rogue
density code 0x0,  drive empty
matcd - Matsushita (Panasonic) CD-ROM Driver by FDIV, Version  1(26) 18-Oct-95
matcdc0 at 0x230-0x233 on isa
matcdc0 Host interface type 0
matcd0: [CR-5630.75]  
npx0 on motherboard
npx0: INT 16 interface
sb0 at 0x220 irq 10 drq 1 on isa
sb0: {SoundBlaster 16 4.11}
sbxvi0 at 0x0 drq 5 on isa
sbxvo0: {SoundBlaster 16 4.11}
sbmidi0 at 0x330 on isa
 {SoundBlaster MPU-401}
opl0 at 0x388 on isa
opl0: {Yamaha OPL-3 FM}
joy0 at 0x201 on isa
joy0: joystick

>Description:

When the system is shut down and halted from multi-user mode, the mounted
filesystems are not unmounted cleanly.  This causes an fsck on the next
reboot.  When the system is brought down to single-user, the filesystems
manually unmounted and then the system is halted, there is no problem
(/ unmounts cleanly).

I added some code to /sys/i386/i386/machdep.c:boot() to display dirty
buffers (see below) after the `giving up' message.  This showed the
following quite consistently (there were almost always 4 busy buf's):

b_flags == B_ASYNC | B_BUSY | B_CACHE (mostly) | B_WRITEINPROG
b_resid == 0
b_bcount == 0x400, 0x800, 0x1800, 0x2000
b_lblkno == b_blkno = 1984, 16, 48, 64 (respectively)
b_pblkno varies widely.  I haven't seen any pattern
b_dev = 0xff00

>How-To-Repeat:

[from multi-user mode]
# shutdown -h now
...
syncing disks ... 4 4 4 4 ... giving up

>Fix:
	
[from multi-user mode]
# shutdown now
[select shell]: sh
# umount -av
# halt
...
syncing disks ... done

The added code in machdep.c is:
*** /cdrom/usr/src/sys/i386/i386/machdep.c	Tue Jun 25 16:19:29 1996
--- /usr/src/sys/i386/i386/machdep.c	Sat Nov 30 19:09:47 1996
***************
*** 888,893 ****
--- 888,930 ----
  			 * unmount filesystems (thus forcing an fsck on reboot).
  			 */
  			printf("giving up\n");
+ 			for (bp = buf, iter = 0; iter < nbuf; iter++, bp++) {
+ 			  long	flags = bp->b_flags;
+ 			  if ((flags & (B_BUSY | B_INVAL)) == B_BUSY) {
+ 			    printf("%4d 0x%08lx", iter, flags);
+ 			    if (flags & B_AGE)		printf(" age");
+ 			    if (flags & B_APPENDWRITE)	printf(" appendwrite");
+ 			    if (flags & B_ASYNC)	printf(" async");
+ 			    if (flags & B_BAD)		printf(" bad");
+ 			    if (flags & B_BUSY)		printf(" busy");
+ 			    if (flags & B_CACHE)	printf(" cache");
+ 			    if (flags & B_CALL)		printf(" call");
+ 			    if (flags & B_DELWRI)	printf(" delwri");
+ 			    if (flags & B_DIRTY)	printf(" dirty");
+ 			    if (flags & B_DONE)		printf(" done");
+ 			    if (flags & B_EINTR)	printf(" eintr");
+ 			    if (flags & B_ERROR)	printf(" error");
+ 			    if (flags & B_GATHERED)	printf(" gathered");
+ 			    if (flags & B_INVAL)	printf(" inval");
+ 			    if (flags & B_LOCKED)	printf(" locked");
+ 			    if (flags & B_NOCACHE)	printf(" nocache");
+ 			    if (flags & B_MALLOC)	printf(" malloc");
+ 			    if (flags & B_CLUSTEROK)	printf(" clusterok");
+ 			    if (flags & B_PHYS)		printf(" phys");
+ 			    if (flags & B_RAW)		printf(" raw");
+ 			    if (flags & B_READ)		printf(" read");
+ 			    if (flags & B_TAPE)		printf(" tape");
+ 			    if (flags & B_RELBUF)	printf(" relbuf");
+ 			    if (flags & B_WANTED)	printf(" wanted");
+ 			    if (flags & B_WRITEINPROG)	printf(" writeinprog");
+ 			    if (flags & B_XXX)		printf(" xxx");
+ 			    if (flags & B_PAGING)	printf(" paging");
+ 			    if (flags & B_VMIO)		printf(" vmio");
+ 			    if (flags & B_CLUSTER)	printf(" cluster");
+ 			    if (flags & B_BOUNCE)	printf(" bounce");
+ 			    printf(" resid=%x bcount=%x lblk=%d blk=%d pblk=%d dev=%x\n", bp->b_resid, bp->b_bcount, bp->b_lblkno, bp->b_blkno, bp->b_pblkno, bp->b_dev);
+ 			  }
+ 			}
  		} else {
  			printf("done\n");
  			/*
>Release-Note:
>Audit-Trail:

Greg Lehey, 9 July 1999

	This PR has been n unlooked at and unloved for over two years.
	Is it still relevant?  Do the patches still apply?  Otherwise
	I'd suggest we close it.

State-Changed-From-To: open->feedback 
State-Changed-By: grog 
State-Changed-When: Fri Jul 9 02:14:25 PDT 1999 
State-Changed-Why:  
ySoliciting feedback from submitter 


Responsible-Changed-From-To: freebsd-bugs->grog 
Responsible-Changed-By: grog 
Responsible-Changed-When: Fri Jul 9 02:14:25 PDT 1999 
Responsible-Changed-Why:  
grog is handling this PR 

From: Peter Jeremy <jeremyp@gsmx07.alcatel.com.au>
To: grog@FreeBSD.ORG
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/2393: filesystems not unmounted following shutdown -h
Date: Sat, 10 Jul 1999 07:40:50 +1000

 Hi Greg,
 
 > Soliciting feedback from submitter
 
 I'd forgotten all about that PR.  It _has_ been quite a while.
 
 I don't recall seeing the problem for quite some time now.  I
 definitely never saw it in 2.2.5 (which I'm still running at home).
 The patches I submitted were neither a fix nor a work-around.
 All they did was dump relevant pieces from the dirty buffers to
 see if I (or someone else) could work out what was going wrong.
 
 There's similar code in an "#ifdef SHOW_BUSYBUFS" in
 kern/kern_shutdown.c:boot() which has been there since before 2.2.5.
 When I first saw the code, I assumed it was related to my PR - it
 was obviously done independently when someone else has a similar
 problem (I'm not expert enough at reading the CVS archives to
 work out exactly who or when).
 
 All in all, I'd just close the PR as `no longer relevant'.
 
 Peter
 --
 Peter Jeremy (VK2PJ)                    peter.jeremy@alcatel.com.au
 Alcatel Australia Limited
 41 Mandible St                          Phone: +61 2 9690 5019
 ALEXANDRIA  NSW  2015                   Fax:   +61 2 9690 5982
 
State-Changed-From-To: feedback->closed 
State-Changed-By: grog 
State-Changed-When: Fri Jul 9 18:07:05 PDT 1999 
State-Changed-Why:  
Submitter agreed to close PR 
>Unformatted:
