Subject: kern/833: Mini-root support does not work
To: None <gnats-admin@NetBSD.ORG>
From: None <osymh@lightning.oscs.montana.edu>
List: netbsd-bugs
Date: 03/01/1995 21:20:04
>Number:         833
>Category:       kern
>Synopsis:       Mini-root support (GENERIC option) will panic
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar  1 21:20:02 1995
>Originator:     Michael L. Hitch
>Organization:
"	Montana State University"
>Release:        NetBSD-current 02/26/95<NetBSD-current source date>
>Environment:
System: NetBSD amiga2.oscs.montana.edu 1.0A NetBSD 1.0A (ZEUS) #950213-0: Tue Feb 14 00:23:01 MST 1995 root@amiga2.oscs.montana.edu:/altroot/tmp/src/sys/arch/amiga/compile/ZEUS amiga


>Description:
	When using the mini-root support (booting with a mini-root file
	system on the swap partition), swapinit will panic with swfree 0.
	This is because swfree() attempts to open the swap device, but
	gets EBUSY because the swap device is already open due to the
	root filesystem at the beginning of the swap partition is
	mounted.
>How-To-Repeat:
	Compile a kernel with the GENERIC option.  Copy a small root file
	system to the beginning of the swap partition (I used the Amiga
	floppy installation file system).  Boot using the mini-root
	filesystem (on the Amiga, use "loadbsd -b ..." and enter sd0*
	at the root device prompt).
>Fix:
	A possible fix is to ignore the EBUSY error return in swfree if
	the mini-root is being used:
diff -cr /usr/src/sys/vm/vm_swap.c sys/vm/vm_swap.c
*** /usr/src/sys/vm/vm_swap.c	Mon Jan  9 04:19:25 1995
--- sys/vm/vm_swap.c	Wed Mar  1 21:02:48 1995
***************
*** 349,356 ****
  
  	sp = &swdevt[index];
  	vp = sp->sw_vp;
! 	if (error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p))
! 		return (error);
  	sp->sw_flags |= SW_FREED;
  	nblks = sp->sw_nblks;
  	/*
--- 349,365 ----
  
  	sp = &swdevt[index];
  	vp = sp->sw_vp;
! 	if (error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p)) {
! #ifdef GENERIC
! 		/*
! 		 * If using mini-root, the swap device is already
! 		 * opened from the root mount.  If device is busy,
! 		 * ignore the error.
! 		 */
! 		if (error != EBUSY || rootdev != dumpdev)
! #endif
! 			return (error);
! 	}
  	sp->sw_flags |= SW_FREED;
  	nblks = sp->sw_nblks;
  	/*
>Audit-Trail:
>Unformatted: