Subject: kern/827: diskless booting can't swap locally
To: None <lukem@dodo.melb.cpr.itg.telecom.com.au>
From: Gordon W. Ross <gwr@mc.com>
List: netbsd-bugs
Date: 02/27/1995 10:47:57
> Date: Sun, 26 Feb 1995 15:05:05 -0800
> From: Luke Mewburn <lukem@dodo.melb.cpr.itg.telecom.com.au>
> 
> >Number:         827
> >Category:       kern
> >Synopsis:       diskless boot kernel ignores 'swap on sd0' entry

> 
> >Description:
> 	A config line of the form:
> 		'config netbsd root on nfs swap on sd0'
> 	doesn't swap on sd0b, it swaps on nfs.
...
> 	From looking at /sys/sys/nfs_boot.c, it assumes that if you
> 	have root on nfs, that's where you want swap. It should listen
> 	to what you config the kernel for.
> 	(Technically, it should also support "root on sd0 swap on nfs")

I don't think the problem is in nfs_mountroot.

Note that in nfs_vfsops.c:nfs_mountroot() we have:

	/*
	 * "Mount" the swap device.
	 *
	 * On a "dataless" configuration (swap on disk) we will have:
	 *	(swdevt[0].sw_dev != NODEV) identifying the swap device.
	 */
	if (bdevvp(swapdev, &swapdev_vp))
		panic("nfs_mountroot: can't setup swap vp");
	if (swdevt[0].sw_dev != NODEV)
		return (0);

I have verified that this works on the Sun3, using "boot -a ..."
Note that the nfs_boot.c code prints some confusing messages:
	root on saturn2:/home/venus/root
	swap on saturn2:/home/venus/swap
Both server responses are printed, even if you only use root.

Those printf calls should probably move to nfs_mountroot to
avoid this confusion.

Attached is a log of my experiment: (in case you're curious)

Note that there is only one call to nfs_mount_diskless()
and the value of swdevt[0].sw_dev ends up being 0701 (sd0b).

>b sd()netbsd -das
Boot: sd(0,0,0)netbsd -das
root filesystem type ( 4.2 nfs  ): 4.2
root device ( xy%d[a-h] sd%d[a-h] xd%d[a-h] ): sd0a
root on sd0a fstype 4.2
Boot: netbsd -das
Size: 522880+112168+63376 bytes
console on zs0 (ttya)
DDB: found symbols [41160 + 43967 bytes]
Stopped at      _Debugger+0x6:  unlk    a6
db> br nfs_boot_init
db> c
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.

NetBSD 1.0A (GENERIC) #161: Thu Feb 23 18:40:56 EST 1995
    gwr@saturn2:/home/gwr/netbsd/src/sys/arch/sun3/compile/GENERIC
Model: Sun 3/260
real mem  = 16760832
avail mem = 14950400
using 102 buffers containing 835584 bytes of memory
mainbus0 (root)
obctl0 at mainbus0
idprom0 at obctl0 hostid 0x13005136
obmem0 at mainbus0
obio0 at mainbus0
zs0 at obio0 addr 0x20000 level 6 softpri 2
zs1 at obio0 addr 0x0 level 6 softpri 2
eeprom0 at obio0 addr 0x40000
clock0 at obio0 addr 0x60000 level 5
ie0 at obio0 addr 0xc0000 level 3 hwaddr 08:00:20:06:b3:e3
vmes0 at mainbus0
si0 at vmes0 addr 0xff200000 level 2 vector 0x40
scsibus0 at si0
si0 targ 0 lun 0: <EMULEX, MD21/S2     ESDI, A00> SCSI0 0/direct fixed
sd0 at scsibus0: 312MB, 1224 cyl, 15 head, 34 sec, 512 bytes/sec
si0 targ 4 lun 0: <, , > SCSI1 1/sequential removable
st0 at scsibus0: rogue, drive empty
vmel0 at mainbus0
root device? [sd0a] ie0
swap device? [ie0] sd0b
dump device? [sd0b] 
Breakpoint at   _nfs_boot_init: linkw   a6,#-0x3c
db> tr
_nfs_boot_init(ffe3e58,e0a07a8) + 0
_nfs_mountroot(8,4000,1c0000,fef0098,dfffffc) + 36
_main(ffe3fac) + 2ee
start() + 9c
db> x/i _nfs_mountroot+0x36
_nfs_mountroot+0x36:    bsrl    _nfs_boot_init  [addr:0xe038be6 ]
db> 
_nfs_mountroot+0x3c:    addqw   #0x8,sp
db> 
_nfs_mountroot+0x3e:    pea     a6@(-0x178)
db> br _nfs_mountroot+0x3e
db> c
nfs_boot: using network interface 'ie0'
ie0: TDR detected a short 0 clocks away
nfs_boot: client_addr=0xc0e91177
ie0: TDR detected a short 0 clocks away
nfs_boot: server_addr=0xc0e91120
nfs_boot: hostname=venus
root on saturn2:/home/venus/root
swap on saturn2:/home/venus/swap
Breakpoint at   _nfs_mountroot+0x3e:    pea     a6@(-0x178)
db> x/x swdevt
_swdevt:                 701
db> 
_swdevt+0x4:               0
db> br nfs_mount_diskless
db> c
Breakpoint at   _nfs_mount_diskless:    linkw   a6,#-0x3c
db> tr
_nfs_mount_diskless(8,4000,1c0000,fef0098,dfffffc) + 0
_main(ffe3fac) + 2ee
start() + 9c
db> x/s 0xe049806
_nfs_statfs+0x2a8:      /
db> c
WARNING: clock gained 12 days -- CHECK AND RESET THE DATE!
db> c
ie0: TDR detected a short 0 clocks away
ie0: TDR detected a short 0 clocks away
Fast boot ... skipping disk checks
# 
telnet> send brk
Stopped at      _Debugger+0x6:  unlk    a6
db> x/x swdevt
_swdevt:                 701
db> c
#