Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!elroy!cit-vax!mangler
From: mangler@cit-vax.Caltech.Edu (Don Speck)
Newsgroups: comp.unix.wizards
Subject: Re: Disk striping? (4.3 BSD)
Summary: interacts badly with buffer cache
Message-ID: <4834@cit-vax.Caltech.Edu>
Date: 10 Dec 87 08:25:59 GMT
References: <2369@emory.uucp>
Organization: California Institute of Technology
Lines: 36

In article <2369@emory.uucp>, arnold@emory.uucp (Arnold D. Robbins {EUCC}) writes:
> However, there is a limited form of disk striping already in the BSD
> kernel: /dev/swap! One can swap on more than one physical disk at a time.
>
> My question is, how general or non-general are the mechanisms used in
> putting together the swap device?

During a time when it looked like my boss would only buy small disks
(Eagles), I started writing a pseudo-device to stripe several partitions
together.

Chris Torek pointed out that it's easy to do for the raw device:
supply physio() with an appropriate (*minphys)() routine that will
chop up the I/O and bump the blkno and buffer address.

But for the block device it's messy.  You can't just fudge the blkno
and buffer address, because those are the property of the buffer cache,
and may be inspected by getblk() at ANY TIME.  So you have to construct
one or more new buf structures, and use B_CALL to merge the relevant info
back to the original buf.  (Which means you can't use the stripe driver
for a swap device.  What's that you say?  Oh, the real swap device gets
around this by only providing a character device).

The really ugly part is allocating those new buf structures.  You can
rip them off from either the buffer cache or the swap headers, but
either way, there may not be any available when you ask, so you might
have to sleep().  The problem is that strategy routines aren't supposed
to sleep(), because they might be called at interrupt time.  I think ND
may be the only thing that does this, but I'm not sure.

I never got around to testing the code, partly due to lack of empty
partitions.

So no, the mechanism used in the swap device is not very general.

Don Speck   speck@vlsi.caltech.edu  {amdahl,scgvaxd}!cit-vax!speck