9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Martin C.Atkins <martin_ml@parvat.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Acme mailreader - now: User mode filesystems in linux
Date: Fri, 17 Dec 2004 10:25:26 +0530	[thread overview]
Message-ID: <20041217102526.0b64d965.martin_ml@parvat.com> (raw)
In-Reply-To: <9ccf822edf0a9a77c141ae47312638dd@collyer.net>

Hi all,

On Thu, 16 Dec 2004 15:22:59 -0800 geoff@collyer.net wrote:
>..
> However, Martin Atkins has revealed the mystery kernel agent: coda.
> Apparently it's somewhat specialised but lets user-mode file servers
> catch opens and closes.

I was going to write a longer message today, anyway :-).

Yes, the kernel-mode agent I use is the Coda filesystem driver, which
has been in the stock linux kernel for several years.

For those that don't already know: Coda is a remote filesystem that
copes (more or less well) with disconnection from, and reconnection
to the fileserver. Thus allowing clients to continue work in the
disconnected state. I'm not sure how successful it was at this - I've
never tried it - but it sounds like an interesting goal. This goal is
also shared by Intermezzo, which was (also) started by Peter Braam -
so presumably he felt Coda could be improved upon.

However, judging by the News pages on their web sites, more seems to
be happening with Coda, than with Intermezzo, recently.

Anyway, the interesting thing about both these systems, from the
point of view of this discussion, is that the real work is done in a
user-mode agent, which communicates with a kernel-mode stub driver.
In Coda the user-mode agent is, for some obscure reason, called Venus.

Thus it was only necessary to reverse-engineer the kernel module <->
Venus protocol. This was surprisingly easy: it is documented in some
detail on the Coda website, and Pavel Machek's podfuk had already
worked out some of the more obscure details (but this wasn't a
general-purpose library, didn't do some things I wanted, and was I
thought, messy). The Coda driver is stable enough that I don't
remember any hangs/etc, even while I was going through the
trial-and-error process!

The user-mode agent simply opens /dev/cfsN, for some N, and reads and
writes messages down to the kernel module. My library for this is, as
I said, about 1400 lines of Python. Trivial fileserver applications
can be as small as 10-20 lines, and faulty fileservers (or library)
never crash/hang the kernel (which is how things should be! :-). It
is also possible to kill the fileserver, and restart with minimal
side effects.

It would be easy to make libraries for other languages.

One curiosity, which is both an advantage, and a disadvantage
depending on what you want to do: The user-mode agent is not involved
in - does not even see - reads and writes. When a client opens a
file, the user-mode agent makes a file somewhere containing the
contents of the "virtual" file, opens it, and writes the file
descriptor down into the kernel. The kernel module returns this file
descriptor (more or less) to the client who reads and writes it as a
normal file, with no intervention of Coda. When the client closes the
file, the kernel driver tells the user-mode agent, which deals with
the (possibly new) contents of the file, and might then remove it
from the local filesystem.

The advantage of this is that reads/writes happen at the same speed
as reads and writes to local files. The disadvantages are that the
open has to make a local copy of the entire contents of the file -
even if it is very big - and can't process individual writes as
commands, as in common in Plan 9. The user-mode agent might also
have to read the file to work out what changed.

However, you can rather easily process open+write+close as a command
to the user-mode agent, or have a file whose contents are different
every time it is opened. (So you do open+read+close, to read a status
value, for example)

Ideally, I'd like the processing of open to be able to decide whether
to send a file descriptor down into the kernel, or to receive
read/write messages - this seems to have been in previous versions of
Coda - such is life!

Re: Intermezzo - as Ron pointed out, it's kernel driver could also
possibly be used for this purpose. However, it uses hooks into an
underlying journalled filessystem - a requirement that I couldn't
easily satisfy back when I started this work, and I wasn't sure that
the kernel-user space interface was so easy to apply to my purpose.
However, it might allow one to avoid the disadvantages mentioned in
the last paragraph. 

I've been meaning to opensource the library for a while now - but
I'd like to clean it up in a few places, before a proper release.
This interest might be the spur to make me get around to it...

>...
> 9), and it becomes possible to push lots of code and some hacks out of
> the kernel, while permitting some new and interesting work.

No disagreements there!

Martin
-- 
Martin C. Atkins			martin_ml@parvat.com
Parvat Infotech Private Limited		http://www.parvat.com{/,/martin}


  parent reply	other threads:[~2004-12-17  4:55 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-15 15:34 [9fans] Acme mailreader jim
2004-12-15 15:40 ` gdiaz
2004-12-15 15:47   ` jim
2004-12-15 15:50     ` Joseph Stewart
2004-12-15 15:57       ` jim
2004-12-15 16:10       ` Russ Cox
2004-12-15 15:58     ` Charles Forsyth
2004-12-15 16:04       ` jim
2004-12-15 16:24         ` C H Forsyth
2004-12-15 16:31           ` jim
2004-12-15 17:07             ` Russ Cox
2004-12-15 17:30               ` jim
2004-12-15 18:33                 ` Russ Cox
2004-12-15 18:49                   ` jim
2004-12-15 18:36               ` Axel Belinfante
2004-12-15 18:47                 ` jim
2004-12-15 18:51                 ` rog
2004-12-15 18:48             ` Skip Tavakkolian
2004-12-15 16:05       ` rog
2004-12-15 16:07 ` rog
2004-12-15 16:09   ` jim
2004-12-16  0:24     ` geoff
2004-12-16  4:12       ` Ronald G. Minnich
2004-12-16  4:51         ` geoff
2004-12-16  9:25           ` jim
2004-12-16  5:13         ` Skip Tavakkolian
2004-12-16  5:17           ` geoff
2004-12-16  5:20             ` boyd, rounin
2004-12-16  5:34               ` boyd, rounin
2004-12-16  5:29             ` Skip Tavakkolian
2004-12-16 15:54             ` Ronald G. Minnich
2004-12-16 17:52               ` Skip Tavakkolian
2004-12-16 18:13               ` Dave Eckhardt
2004-12-16  5:23           ` Andy Newman
2004-12-16 15:52           ` Ronald G. Minnich
2004-12-16  8:17       ` Martin C.Atkins
2004-12-16  9:35         ` jim
2004-12-16 15:19         ` rog
2004-12-16 15:26           ` jim
2004-12-16  9:30       ` jim
2004-12-16 15:08       ` David Leimbach
2004-12-16 23:22         ` geoff
2004-12-16 23:25           ` boyd, rounin
2004-12-16 23:38           ` Ronald G. Minnich
2004-12-17  1:31             ` Skip Tavakkolian
2004-12-17 15:50               ` Ronald G. Minnich
2004-12-17  4:55           ` Martin C.Atkins [this message]
2004-12-17  9:54             ` [9fans] Acme mailreader - now: User mode filesystems in linux Martin C.Atkins
2004-12-17 10:22               ` geoff
2004-12-17 10:45                 ` Martin C.Atkins
2004-12-17 11:42                 ` Andy Newman
2004-12-17 15:57                   ` Ronald G. Minnich
2004-12-17 12:30                 ` Latchesar Ionkov
2004-12-17 15:55                 ` Ronald G. Minnich
2004-12-17 13:41               ` Derek Fawcus
2004-12-17 14:42               ` Karl Magdsick
2004-12-17 14:56                 ` Russ Cox
2004-12-18  0:13               ` Tim Newsham
2004-12-18  0:13                 ` boyd, rounin
2004-12-18  3:49                   ` Ronald G. Minnich
2004-12-23 16:04                     ` boyd, rounin
2004-12-17 15:44             ` Ronald G. Minnich
2004-12-18 12:35               ` Martin C.Atkins
2004-12-17 18:52           ` [9fans] Acme mailreader David Leimbach
2004-12-17 23:20             ` Jack Johnson
2004-12-18  1:00               ` David Leimbach
2004-12-15 16:09 ` Russ Cox
2004-12-15 16:16   ` jim
2004-12-15 16:22   ` boyd, rounin
2004-12-17 15:31 [9fans] Acme mailreader - now: User mode filesystems in linux bmaroshe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041217102526.0b64d965.martin_ml@parvat.com \
    --to=martin_ml@parvat.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).