Subject: Pseudo-disk, take three
To: None <tech-kern@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 11/01/2001 22:30:40
On the "first make it work, then make it better" principle, I bashed on
my pseudo-disk driver so that delayed writes are completed immediately,
buffered by the driver, and the buffers flushed by a kernel thread.
The buffer space is allocated with malloc(,M_DEVBUF,) as necessary.
Rather than the kludge of scanning the open file table for every
process that tries to do I/O, I buffer every I/O that's B_ASYNC but not
B_READ.  I did a little test pounding with verbosity turned on and saw
the count of buffers waiting to be flushed go as high as about 35
(presumably 8K) buffers; I'd assume it can get higher...but there's not
much to be done about it; if the driving process is blocked waiting for
a buffer, we _have_ to complete the I/O so it cna get it, or we'll
deadlock, and I see no easy way to tell whether a given process is
critical to the pseudo-disk's operation.  (The control process may
block waiting for other processes; and it's possible for it to fork and
thus have processes with descriptors on the master device that aren't
critical to operation.  The open-file scanning technique worked for my
tests because my driving process setup was simple, but it's not a real
deadlock avoidance mechanism.)

I'm now using it with two simple userland programs to allow my Alpha to
work with a disk that's actually connected to a SPARC.  I'm unpacking a
source tree into the remote disk and will have the alpha do a make
build of that source tree; if that completes without exhibiting further
trouble I'll consider it ready for the interested among you to pound on
and improve.  I don't expect problems, but that was true before I found
the previous problems, too.

In case any of you want to start playing with it now, I've updated the
ftp.netbsd.org copy of my patch tree that I mentioned a day or two ago
(ftp.netbsd.org:/pub/NetBSD/misc/mouse/patch-tree/, with the
pseudo-disk driver code in src/sys/dev/pseudo/pdisk*).  The three
userland programs I've been using (which, again, are undocumented as
yet - but are very simple) I've put in .../misc/mouse/hacks/.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B