[net.bugs.usg] Sys V r2 version 2 swap bug

phil@qfdts.oz (Phil Chadwick) (07/05/85)

System V release 2 version 2 has a new command called swap
to configure extra swap areas into the system on the fly.
I just tried it.  Guess what happened?  "panic: IO err in swap".
Double checked everything and tried again.  Same result.

Then I found something very strange in the swap code in
the file physio.c!  The swap i/o is being done with a

	(*bdevsw[bmajor(swapdev)].d_strategy)(bp)

swapdev is an extern and reflects the device codes for the
*initially* configured swap device.  Now why are they using
the driver for the initially configured swap device to do the
i/o when the swap device may be anything configured into the
system with the swap command?

Has anyone got Sys V r2 v2 to swap on anything but the initially
configured swap device?  Will changing "swapdev" to "dev" fix
the problem?

----
Phil Chadwick		  Australia: (07) 2296500
Department of Forestry	  International: +61 7 2296500
PO Box 5		  ACSnet: phil@qfdts.oz
Brisbane, Roma Street	  ARPA: decvax!mulga!qfdts.oz!phil@UCB-VAX.ARPA
AUSTRALIA	4001	  UUCP: {decvax,vax135,eagle,pesnta}!mulga!qfdts.oz!phil

stewart@houxf.UUCP (Bill Stewart HO 4K-435 x0705) (07/13/85)

[... Has anyone been able to change swap areas?...]
Yes, I do it all the time.  My system boots up with swap on the
root drive, which is boring; in the /etc/rc I do the following:

	swap -a /dev/dsk/1s1 0 70000	# Add 70Kblocks swap on 1s1
	swap -d /dev/dsk/0s0 14320	# Remove 0s0 swap.
	swap -l				# List what's left

You have to be careful of two things - 
	1) always allocate new swap space before you zap the
		old swap space, so you have SOME swap space.
	
	2) be careful if you delete a swap area when something's
		using it.  I haven't dug around enough to really
		understand what happens, but I normally remove swap
		areas only when there's not enough running to swap
		anyway.
-- 
Bill Stewart	ho95c!wcs AT&T Bell Labs, Holmdel NJ
HO 4K-435 x0705   (201-949-0705)
{allegra, ucbvax!ihnp4, decvax!harpo}!houxf!stewart

phil@qfdts.oz (Phil Chadwick) (07/16/85)

Bill Stewart (ho95c!wcs AT&T Bell Labs, Holmdel NJ) writes that
in System V r2.0 version 2:

    >[... Has anyone been able to change swap areas?...]
    >Yes, I do it all the time.  My system boots up with swap on the
    >root drive, which is boring; in the /etc/rc I do the following:
    >
    >	swap -a /dev/dsk/1s1 0 70000	# Add 70Kblocks swap on 1s1
    >	swap -d /dev/dsk/0s0 14320	# Remove 0s0 swap.
    >	swap -l				# List what's left

I appreciate the advice since it made me think the problem
through a little further.

I should have said that the problem was on a VAX, although I
don't know if it is specific to the VAX.  To recap, our VAX
panics (as soon as it has to swap) after extra swap space
(on a drive type which differs from the initially configured
swap device) is added to the system with a swap(1m) command.

It does not surprise me that the above swap commands worked
because on a VAX at least, /dev/dsk/1s1 and /dev/dsk/0s0 are
massbus disks and will both have the same major device code
(reflecting either the rm05 or gd driver).  Hence using
"bmajor(swapdev)" will select the correct driver for both
swap areas.

I still think that the "swapdev" in line 72 of physio.c is wrong
(because it reflects the initially configured swap device, not
necessarily the one that should be used):

	(*bdevsw[bmajor(swapdev)].d_strategy)(bp)

I think that "swapdev" should be changed to "dev".  But is this
all that is required?

----
Phil Chadwick		  Australia: (07) 2296500
Department of Forestry	  International: +61 7 2296500
PO Box 5		  ACSnet: phil@qfdts.oz
Brisbane, Roma Street	  ARPA: decvax!mulga!qfdts.oz!phil@UCB-VAX.ARPA
AUSTRALIA	4001	  UUCP: {decvax,vax135,eagle,pesnta}!mulga!qfdts.oz!phil