It's time to port my Tux2 prototype to 2.4, and this has given me the
opportunity to get even more tangled up in the two-cache problem than
ever before.  Right now, Ext2 uses the page cache for data and the
buffer cache for metadata.  This platypus gets through life pretty well
because in Ext2 data and metadata live in separate parts of the
partition - you don't have to worry about aliases.  Tux2 doesn't enfore
such partitioning and therefore has to worry about aliases.

The question is, should I just deal with the aliases or should I bite
the bullet and try to move all my metadata into the page cache?  Tux2 is
a patch to Ext2, and one of its design goals is to stay as close as
possible to Ext2.  This is an argument for just dealing with the
aliasing problems and sticking with Ext2's way of handling metadata.  On
the other hand, switching over entirely to the page cache seems
attractive for many reasons.  Three that come to mind:

  1) Deferred allocation is more natural
  2) Metadata can be memory-mapped
  3) Copy-on-update is simple and cpu-efficient

Tux2 has two metafiles, the inode metafile and the group metafile, each
with a tree of index blocks.  Memory-mapping the group metafile and its
associated index tree is attractive because it's frequently accessed and
isn't too large - 1/8Kth of the filesystem size for 1K blocks and
1/32Kth for 4K blocks.  Allocating the virtual memory isn't a problem.  
A lot of hashes into the page tables can be saved - these hashes are
replaced by hardware PTE lookups.  Using hardware-assisted swapping for
the group metadata seems like a big improvement on Ext2's current
roll-your-own bitmap cache scheme.

There are just two disadvantages I can think of here:

  - It's quite different from what Ext2 does now.  More work.  Bigger
    patch.  More arrows in my back.

  - When block size is smaller than page size I can't tell which of the 
    several blocks on a dirty page is actually dirty so I have to write
    them all.

My feeling is that I should probably do this.  It seems forward looking
and perhaps other filesystems will head in this direction as well.  It's
more work.  Oh well.

The inode metafile presents some additional problems.  It's a lot bigger
than the group metafile, about 1/32 of the filesystem size.  Mapping the
entire table into virtual memory is out of the question - that would be
1 gig for a 32 gig disk.  On the other hand, the inode table's index
tree - again roughly 1/32Kth of the filesystem size for 4K blocks - fits
nicely into virtual memory.  A damper on my enthusiasm is that the inode
cache is accessed much less frequently due to the inode cache so I
probably get any detectable performance improvement.  I guess the code
might be a little simpler though and maybe I can reuse some of my group
metafile code.  Or I might decide to forgo memory mapping while still
using the page cache with a view to tracking the dirty/mapped state of
individual blocks.

The inode index is a Tux2-ism; there is no existing code for such a
thing in Ext2 anyway so I might as well go ahead and get creative.

Though I can't practically memory map the inode table, as noted above, I
can deal with it in much the same way as generic_file_read/write do. 
Again, I get to keep track of the dirty/mapped at a resolution smaller
than the page size.

The only metadata I haven't mentioned so far is per-file data index
blocks.  I haven't thought of anything elegant to do with these.  The
inelegant and temporary approach I'm considering is to map them into the
file's address_space starting at a high index, say 2 gig, imposing a
file size limit of 8 terabytes or so.  I could make it a little cleaner
by adding separate address_space's for the index blocks later, but even
so, this seems, um, like a half-formed idea.

As an aside, and please don't let this distract you from commenting on
the above, I note that the BSD's changed their buffer cache over from
physical-block-address to file-relative-index a long time ago.  This
gives the BSD buffer cache many of the advantages we are now looking for
from our page cache.  Could it be that we have just confused ourselves
about this, and those devils have been right all along?

--
Daniel
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to