Re: [RFC][PATCH] bcache: cache a block device with an ssd

Previous thread: 2.6.33.2: USB Quickcam Pro 9000 (usb resets)? by Justin Piszcz on Monday, April 5, 2010 - 5:54 am. (1 message)

Next thread: Ooops when working with USB MIDI (2.6.33.1) by Tvrtko Ursulin on Monday, April 5, 2010 - 6:33 am. (9 messages)
From: Kent Overstreet
Date: Monday, April 5, 2010 - 6:23 am

Say you've got a big slow raid 6, and an X-25E or three. Wouldn't it be
nice if you could use them as cache...

Thus bcache (imaginative name, eh?). It's designed around the
performance characteristics of SSDs - it only allocates in erase block
sized buckets, and it uses a bare minimum btree to track cached extants
(which can be anywhere from a single sector to the bucket size). It's
also designed to be very lazy, and use garbage collection to clean stale
pointers.

The code is very rough and there's a number of things missing before it
can actually be useful (like garbage collection), but I've got it
working with an ext4 filesystem on top and it does successfully cache.
It doesn't yet even look at writes though, so read/write access would
quickly explode.

A goal of mine was that it be possible to add and remove a cache to an
existing block device at runtime; this should make it easier and more
practical to use than were it a stacking block device driver.

To that end, I'm hooking in to __generic_make_request, right before it
passes bios to the elevator. This has a number of implications (not
being able to wait on IO makes things tricky), but it seemed like the
least bad way to do it, at least for now. As far as I can tell the only
behavior that changes is that trace_block_remap gets run again if the
make_request_fn returns nonzero (in that case I just resubmit it via
generic_make_request; if part of the btree wasn't in the page cache I
can't simply return it to __generic_make_request). This obviously
requires more code in __generic_make_request - which I was hoping to
avoid or at least make generic, but hopefully one more conditional won't
get me tarred and feathered... or someone will have a better idea.

(There are definitely races here that I'm not pretending to deal with
yet. I don't think it'll be too bad, though. (There's a lot of locking
that needs to happen and isn't yet...))

As previously implied, cache hits are tracked on a per bucket basis.
Each bucket has a ...
From: Jeff Moyer
Date: Tuesday, April 13, 2010 - 8:47 am

I see this has languished without response.  This is an interesting
idea, however the first question that comes to mind is have you looked
at fs-cache?  Does it come anywhere close to suiting your needs?

Cheers,
Jeff

--

Previous thread: 2.6.33.2: USB Quickcam Pro 9000 (usb resets)? by Justin Piszcz on Monday, April 5, 2010 - 5:54 am. (1 message)

Next thread: Ooops when working with USB MIDI (2.6.33.1) by Tvrtko Ursulin on Monday, April 5, 2010 - 6:33 am. (9 messages)