Subject: MACH vm code problems (vm_fault doesn't consult underlying VFS)
To: None <port-sparc@sun-lamp.cs.berkeley.edu, bsdi-users@bsdi.com>
From: Ronald G Minnich <rminnich@descartes.super.org>
List: port-sparc
Date: 06/03/1994 06:48:53
I'm trying to get a modified version of NFS, called MNFS, working under 
bsdi/netbsd, and have run into a problem with the mach vm model. I'm 
pondering options, and wanted to ping this knowledgeable community for 
ideas. 

MNFS is a stateful-server version of NFS. Page ownership is tracked, only 
one writeable copy of a page is allowed to exist, and pages are recalled 
as needed to satisfy these constraints (for more info contact our home 
page: ftp::/super.org/pub/www/src.home.page). An implication of these 
constraints, among other things, is that when a write fault occurs on a 
previously read-faulted page, MNFS client-side code needs to be notified, 
in case the writeable copy needs to be fetched. 

Here is where I run into the mach vm model. In the mach vm model, the 
vm_pager acts as a page cache, and once it gets a page, it is willing to 
satisfy read/write faults on that page *without consulting the underlying 
vfs*. So, unlike (e.g.) AIX, sunos and solaris, it's not possible in the 
current implementation to have the vm_pager come back to the VFS and say "I 
asked for this readonly before; can I have it writeable now?". 

In addition, for reasons I don't understand, the vm_pager doesn't pass any
fault info to the underlying dev, vnode, or other pager code. We've found
it handy for writing drivers for hardware we've built as well as for mnfs
to have the faulting virtual address and the protections available to the
vfs/driver code that actually handles the fault (which happens in sunos
and solaris). 

So, I'm trying to work up changes that make the fault code more useful 
for us. First desired change is:
struct faultinfo
  {
    caddr_t faulting_vaddr;
    vm_prot_t  faulting_protections; /* shorten these to taste :-) */
  };

faultinfo gets handed to the getpage function(s), i.e. it's an added 
fourth parameter to the three that are there now. 

Second change: in the initial step in vm_fault where it's looking up the
page, have it consult the underlying pager (i.e. vfs/driver/etc.) to see
if the pager thinks it has the page. This will give the VFS a chance to do
what's needed. 

These are preliminary thoughts on how to get mnfs to work on xxxbsd. I've
got it working now on four different OS'es on three different vendor
boxes. I can't ship any of that code, so I'd like to get it working on
bsd. On one vendor's box I had to hack the page fault code specifically
for mnfs, but I couldn't look in the mirror next morning (but those
changes are probably there to stay). So I'd like to work out a way to do
this that's acceptable to this community. Any thoughts would be welcome. 

thanks
ron




------------------------------------------------------------------------------