LWN: Comments on "Bcache: Caching beyond just RAM" https://lwn.net/Articles/394672/ This is a special feed containing comments posted to the individual LWN article titled "Bcache: Caching beyond just RAM". en-us Thu, 09 Oct 2025 17:39:49 +0000 Thu, 09 Oct 2025 17:39:49 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Generation number https://lwn.net/Articles/551003/ https://lwn.net/Articles/551003/ wiza <div class="FormattedComment"> I don't quite understand the effect of maintaining the generation number. Since FTL has used some algorithm to avoid wearing out, what good is the generation number?<br> </div> Fri, 17 May 2013 08:55:25 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/397061/ https://lwn.net/Articles/397061/ nix <div class="FormattedComment"> Unfortunately if you want to spot cache invalidations, the lack of leases on NFSv3 is a killer, because you still have to roundtrip to the server to see if your cache is stale, and roundtrips are the slow part :( fs-cache slows NFS *down* quite considerably in my experience, for exactly this reason.<br> <p> </div> Thu, 22 Jul 2010 20:59:00 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/396602/ https://lwn.net/Articles/396602/ neilbrown <div class="FormattedComment"> Yes, NFSv3 helps with writing large files. But metadata operations (create, unlink, chmod, mv) still need to be synchronous and some workloads can be very metadata-heavy (untar is a good example, 'make' on a big project tends to delete and create lots of relatively small files too).<br> So a low-latency cache can definitely improve the performance of an NFS server.<br> <p> </div> Tue, 20 Jul 2010 11:38:56 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/396428/ https://lwn.net/Articles/396428/ intgr <div class="FormattedComment"> How are you planning to protect file systems from being mounted if it has a write-back cache that is not activated or not available? Sounds like there is no infrastructure for this currently, but could badly corrupt data if not recognized.<br> <p> </div> Sat, 17 Jul 2010 16:10:36 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/396409/ https://lwn.net/Articles/396409/ bill_mcgonigle <div class="FormattedComment"> I was wondering the same thing. As I understand it, the main difference is that with Flashcache you tell it, "here, you're in front of this device". And then you mount the flashcache device. <br> <p> bcache uses a kernel feature that lets it hook in 'from the side'. So, you still mount the regular device. In theory you can insert/pull/insert bcache as much as you want and your apps would be fine to keep on running. I think that makes it ultimately more powerful.<br> <p> You could even imagine a workload where you have a bazillion disks that receive sporadic heavy access (maybe remote disks where old data isn't useful), and you could have some sort of monitor that would keep a few SSD's busy by inserting them as bcaches on-demand.<br> <br> </div> Sat, 17 Jul 2010 03:55:10 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/396226/ https://lwn.net/Articles/396226/ bill_mcgonigle There's quite a bit of similarity. L2ARC is read-only, for wide random accesses. bcache aims to be read/write. ZFS also separates out its ZIL for writes. If I'm building a ZFS box I'd use a big MLC drive for the L2ARC and a smaller SLC drive for the ZIL as the workloads differ. You could probably set bcache to be read-only and put a filesystem's journal on a different drive if you wanted a more-like-ZFS segregation. bcache has the nice attribute of just being able to pull it and keep running - ZFS isn't usually set up that way. The L2ARC and ZIL have the checksumming today whereas bcache will get to that. Of course, bcache is much more general and useful in situations where ZFS has no relevance. It's good to have chisels <i>and</i> screwdrivers. Thu, 15 Jul 2010 22:59:54 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395797/ https://lwn.net/Articles/395797/ rilder <div class="FormattedComment"> I recently came across L2ARC caching used in Solaris with ZFS + SSD. Is there any improvement or difference between that and bcache ? <br> </div> Mon, 12 Jul 2010 20:30:01 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395792/ https://lwn.net/Articles/395792/ rilder <div class="FormattedComment"> Interesting project. However, I wonder how this will work with something like cleancache(<a href="http://lwn.net/Articles/389873/">http://lwn.net/Articles/389873/</a>). Cleancache works in the realm of VM. So is bcache supposed to complement cleancache or is a replacement for it.<br> <p> The transparency of bcache is quite nice. Is bcache available as module(so that it can be built out of tree and used) ?<br> </div> Mon, 12 Jul 2010 19:50:04 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395724/ https://lwn.net/Articles/395724/ etienne <div class="FormattedComment"> <font class="QuotedText">&gt; there is a feature in the firmware of the drives which auto-parks the heads after 8 seconds of inactivity</font><br> <p> Probably maximum power saving more, you can usually see/adjust (and save the setup) using hdparm.<br> </div> Mon, 12 Jul 2010 09:16:41 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395713/ https://lwn.net/Articles/395713/ MisterIO <div class="FormattedComment"> Well, with kernel bugs I meant kernel bugs not affecting this code and which by no means start writing random songs of some unknown guy(yeah, sorry, I don't know him) over your data, but still freeze the system. At that point basically the only real problem you could have is losing data on your hd(either just the data that didn't make it to the hd or the whole file you were writing at the time of the failure. The second case happened to me frequently with ext4 and I lost many normal data files because of it, while I was able instead to save some sources I was coding simply because I used git and I committed quite often).<br> </div> Mon, 12 Jul 2010 00:14:08 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395710/ https://lwn.net/Articles/395710/ alankila <div class="FormattedComment"> Excellent news. I look forwards to using this technology.<br> </div> Sun, 11 Jul 2010 14:39:50 +0000 bcache and cluster filesystems? https://lwn.net/Articles/395705/ https://lwn.net/Articles/395705/ koverstreet <div class="FormattedComment"> Yeah, nothing more complicated than that. Make a new bio flag to invalidate a region of cache, and make sure everything that isn't a cache ignores it. Making bcache handle it would be trivial, it'd just be a matter of making sure ocfs2 always invalidates what it needs to.<br> </div> Sun, 11 Jul 2010 03:22:46 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395704/ https://lwn.net/Articles/395704/ koverstreet <div class="FormattedComment"> Yeah, that's all correct :)<br> <p> Kernel bugs are a different matter entirely though - if a program doesn't do what you think it does, it could be doing anything. If it's buggy it could be overwriting all your important data with Rick Astley songs, or opening the door the the velociraptor cages. There's just no way to tell at that point.<br> <p> You test everything as best you can, but software's complicated, there's always something lurking and no complete guarantees.<br> </div> Sun, 11 Jul 2010 03:20:03 +0000 O_DIRECT read of sector 0 https://lwn.net/Articles/395695/ https://lwn.net/Articles/395695/ wstearns <div class="FormattedComment"> You're correct; bcache does cache block devices. I phrased it poorly; the idea I failed to get across was that the filesystems we'd normally submit to bcache to cache are on individual partitions (which linux treats as block devices) as opposed to the entire drive, allowing you to bypass bcache on sector 0 and still cache the partitions.<br> </div> Sat, 10 Jul 2010 21:13:53 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395693/ https://lwn.net/Articles/395693/ dlang <div class="FormattedComment"> if the data isn't written to the bcache HD and you do not have battery backed cache on the system, the data will be lost. This is the same as with any storage/filesystem.<br> <p> however (once the write behind features are in bcache) once the data is written to the bcache storage it should push those changes back to the real device after the next boot. If it doesn't the write-behind feature can't be considered done and useable ;-)<br> </div> Sat, 10 Jul 2010 20:32:45 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395682/ https://lwn.net/Articles/395682/ MisterIO <div class="FormattedComment"> Ooouuuh, it's so cold being alone in the shadow on winter!<br> <p> Was my previous question very retarded? I noticed it's the only comment in the thread which was completely ignored. So I thought that knowing to have said something really stupid is still more useful than nothing. Thus, this post was born.<br> <p> </div> Sat, 10 Jul 2010 16:18:16 +0000 bcache and cluster filesystems? https://lwn.net/Articles/395674/ https://lwn.net/Articles/395674/ skissane <div class="FormattedComment"> it would be interesting to work out, what extra features would bcache need to provide so that a clustered filesystem could use it without issue... i assume just some API to tell bcache to invalidate some block...<br> </div> Sat, 10 Jul 2010 11:20:46 +0000 O_DIRECT read of sector 0 https://lwn.net/Articles/395673/ https://lwn.net/Articles/395673/ eludias <div class="FormattedComment"> I was under the impression that bcache cached block devices (hence the name ), and not filesystems. But you have a good point: if I would cache the partition and not the whole device, I might be able to circumvent it by reading outside the partition.<br> </div> Sat, 10 Jul 2010 10:45:52 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395669/ https://lwn.net/Articles/395669/ koverstreet <div class="FormattedComment"> It is. Currently if you shut down uncleanly it'll invalidate the cache as it'll be inconsistent, but handling that is part of safe write behind caching on, which I'm working on now.<br> </div> Sat, 10 Jul 2010 08:59:59 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395662/ https://lwn.net/Articles/395662/ giraffedata Is it persistent across reboots? I.e. will my frequently accessed data still be available from the SSD after a reboot? Sat, 10 Jul 2010 03:20:12 +0000 O_DIRECT read of sector 0 https://lwn.net/Articles/395606/ https://lwn.net/Articles/395606/ wstearns <div class="FormattedComment"> Since bcache can only cache individual filesystems and I assume your actual filesystems are on partitions (as opposed to a single filesystem covering the entire drive), bcache won't be caching sector 0 as that's not part of a filesystem.<br> </div> Fri, 09 Jul 2010 15:37:35 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395590/ https://lwn.net/Articles/395590/ eludias <div class="FormattedComment"> How will O_DIRECT be handled? I need this to circumvent any caching layer to keep my hardware healthy.<br> <p> Background: I've also got one of those nasty WD Caviar Green (1Tb) drives, and there is a feature in the firmware of the drives which auto-parks the heads after 8 seconds of inactivity. This interacts quite badly with an OS which saves its data once per 30 seconds, resulting in a drive worn down in about 6 months.<br> <p> Now the way to circumvent this behaviour is to read something from the drive, say once per 5 seconds. And the most efficient way to do so is to read from the cache of the drive, so we re-read sector 0 over and over again. With O_DIRECT we can bypass the disk cache of Linux traditionally, but will this also be the case when using bcache?<br> </div> Fri, 09 Jul 2010 12:27:39 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395569/ https://lwn.net/Articles/395569/ MisterIO <div class="FormattedComment"> Is it safe in the presence of kernel bugs(or similar problems) for writes? I mean, we've seen things link ext4 delaying writes for 30 secs, but that had obvious relayability problems. Let's say that bcache successfully caches a certain amount of writes(that is they are complete on the cache), but then the system freezes, so the cache isn't written back to the actual hd. At the next boot, does bcache remember to perform those writes?<br> </div> Fri, 09 Jul 2010 08:03:22 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395559/ https://lwn.net/Articles/395559/ koverstreet <div class="FormattedComment"> Completely different design and completely unrelated. I started bcache a couple months before flashcache was announced. Flashcache is simpler and being used in production now. Bcache has, in my opinion, a lot more potential than flashcache.<br> </div> Fri, 09 Jul 2010 03:52:31 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395558/ https://lwn.net/Articles/395558/ mwalls <div class="FormattedComment"> Isn't this substantially duplicating Facebook's flashcache, so are they related?<br> </div> Fri, 09 Jul 2010 03:36:02 +0000 bcache and cluster filesystems? https://lwn.net/Articles/395557/ https://lwn.net/Articles/395557/ koverstreet <div class="FormattedComment"> Yeah, it'd quickly explode. Probably be fun to watch, though.<br> </div> Fri, 09 Jul 2010 03:28:34 +0000 bcache and cluster filesystems? https://lwn.net/Articles/395556/ https://lwn.net/Articles/395556/ skissane <div class="FormattedComment"> How would this interact with a cluster file system such as OCFS?<br> I assume it wouldn't work, unless the cluster file system was aware of the<br> bcache, and had some way to do cache invalidation of the blocks which had<br> been changed by other nodes in the cluster....<br> </div> Fri, 09 Jul 2010 02:56:25 +0000 Bcache and filesystem recovery https://lwn.net/Articles/395552/ https://lwn.net/Articles/395552/ koverstreet <div class="FormattedComment"> It doesn't handle barriers just yet. That's coming soon, it's needed for write behind caching.<br> <p> This isn't a correctness issue, if you don't have barriers you just have to wait for writes to complete before you start another to guarantee ordering. Barriers have historically taken awhile to add to things like raid, lvm and drbd, bcache is nothing special.<br> <p> There is a bug in that if you're running bcache on something that supports barriers, bcache won't indicated that they're no longer supported... I haven't worried much about that since you can disable them in the filesystem and it's only till I get barriers implemented in bcache.<br> </div> Fri, 09 Jul 2010 02:15:24 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395548/ https://lwn.net/Articles/395548/ koverstreet <div class="FormattedComment"> You could stuff everything into a filesystem, sure, but what would be the point? Caching really is doing something else, it wouldn't really be able to share any filesystem code, and it'd be tied to that one filesystem.<br> <p> The main thing is the allocation strategy you want for caching is _completely_ different than for filesystems. Fragmentation isn't a real problem in the cache, since we can free fixed sized chunks regardless of what's in them. This means we're free to write data to the cache however we want to get the best performance. A filesystem has to retain data for an arbitrary amount of time, and thus needs to pay a lot of attention to making sure free space doesn't fragment too much.<br> <p> Putting an external journal on an SSD gets you a bit of what bcache is after, but it'll only help with writes, and not to the extent bcache can. How would you effectively use an 80 gb journal? With bcache, you'll be able to fill up your caches with almost all dirty writes, and then write them out to your RAID6 with no restrictions on ordering - potentially turning a huge portion of random writes into mostly sequential ones, and even more will get overwritten in the cache before the raid ever sees them.<br> </div> Fri, 09 Jul 2010 01:21:26 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395540/ https://lwn.net/Articles/395540/ akumria <div class="FormattedComment"> <p> Perhaps I'm not understanding everything.<br> <p> But it seems to me, that you could move the bcache functionality into the filesystem.<br> <p> i.e. Why can't btrfs store all writes on that faster medium and them replicate them back to the slower one?<br> <p> Also, isn't this akin to storing the journal of a filesystem externally (I've never done it). i.e. Why not point the ext3/ext4 journal at the SSD?<br> <p> Would you get the same (or better) benefit?<br> <p> It seem bcache is useful is the underlying filesystem doesn't do it, but in the above two cases, is there much benefit?<br> <p> Insight appreciated.<br> <p> Thanks,<br> Anand<br> </div> Fri, 09 Jul 2010 00:08:54 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/395537/ https://lwn.net/Articles/395537/ koverstreet <div class="FormattedComment"> <font class="QuotedText">&gt; (Reliable, crash resistant)</font><br> <p> That's what I've been working towards :)<br> <p> Safe write behind caching really is a large step up in terms of the guarantees the cache has to be able to make - with writethrough caching, you just have to make sure you return good data, or nothing. And btree code is hard enough, so I've been working on getting the easy cases rock solid first - but safe write behind caching is absolutely happening. I've got some of the preliminary stuff out of the way and I'm hoping to have a rough initial version before too long, depending on how debugging the new stuff goes.<br> </div> Thu, 08 Jul 2010 23:32:25 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/395535/ https://lwn.net/Articles/395535/ jlayton <div class="FormattedComment"> <font class="QuotedText">&gt; NFS servers are supposed to do synchronous writes, right? (Reliable, crash resistant) write behind caching would be outstanding.</font><br> <p> Not since NFSv3 was implemented. That gave the ability to do safe asynchronous writes. The client sends a bunch of WRITEs to the server and then issues a COMMIT. If the server crashes, the client will reissue uncommitted writes.<br> <p> With NFSv2 however, you're correct that the server is supposed to do sync writes (and most do these days, at least by default).<br> <p> </div> Thu, 08 Jul 2010 23:26:42 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/395532/ https://lwn.net/Articles/395532/ koverstreet <div class="FormattedComment"> Bootloaders are a special situation - the most practical thing to do would be to just not enable write behind caching for /boot. For everything else, sync happens when you switch off write behind caching, and sync without switching it off doesn't really make any sense, the cached device is going to be inconsistent as long as write behind caching is on.<br> </div> Thu, 08 Jul 2010 23:19:43 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395527/ https://lwn.net/Articles/395527/ koverstreet <div class="FormattedComment"> Checksumming won't save you here - what's it supposed to compared the checksum against? If you fill up your cache, turn of caching, write some data, and then turn caching back on without telling bcache about it... well, computers can't always save you from rm -rf either.<br> <p> I am looking into invalidating the cache contents if a filesystem was already opened read write, or perhaps checking if the first page or so matches what it previously had - this would catch it provided the filesystem superblock changed. But the real performance gains are to be had with write behind caching, and none of this really matters there, since the cached device is now inconsistent if you use it without the cache. By the time bcache saw the cache was out of date it'd be too late to do anything.<br> </div> Thu, 08 Jul 2010 23:16:01 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395462/ https://lwn.net/Articles/395462/ sflintham <blockquote>This approach of intercepting bio requests in the background allows us to start and stop caching on the fly, to add and remove cache devices, and to boot with or without bcache</blockquote> Am I right in thinking this will only be possible once the checksumming feature mentioned at the bottom of the article is in place? Otherwise, what would stop the cache returning an out-of-date copy of a block modified while it was offline? Thu, 08 Jul 2010 17:34:52 +0000 Bcache and filesystem recovery https://lwn.net/Articles/395453/ https://lwn.net/Articles/395453/ abacus <div class="FormattedComment"> An important issue has not been discussed in the above article, and that is how file system recovery works when using Bcache. Does Bcache honor the write ordering requirements communicated by filesystems such that e.g. journal-based filesystem recovery still works ?<br> </div> Thu, 08 Jul 2010 16:54:50 +0000 Unique UUIDs https://lwn.net/Articles/395447/ https://lwn.net/Articles/395447/ wstearns <div class="FormattedComment"> You're correct; at least in the case of RAID 1 mdadm, the md device and the underlying partitions all share the exact same UUID. When I use bcache on a raid array, I don't cache the underlying partitions, I cache the raid device itself. That lets the raid code handle a missing component partition, raid resync, and any other raid issues internally.<br> If you copy a filesystem with dd or raid split as you mention, you still have to tell bcache both what UUID and what block device to cache, letting you specify the original partition or the new copy, whichever you want cached. So bcache shouldn't introduce new problems; a non-bcache linux system will have problems already if you have 2 different filesystems with the same UUID as others have mentioned.<br> </div> Thu, 08 Jul 2010 16:19:10 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395437/ https://lwn.net/Articles/395437/ martinfick <div class="FormattedComment"> Why would you want it in front of a DRBD device? If you really want to sacrifice reliability for performance with a DRBD device, simply use protocol B or C, it will likely be more reliable.<br> </div> Thu, 08 Jul 2010 15:40:35 +0000 Bcache: Caching beyond just RAM https://lwn.net/Articles/395424/ https://lwn.net/Articles/395424/ faramir <div class="FormattedComment"> Given that many distributions now use UUIDs rather then device names in /etc/fstab, not having unique UUIDs is already a recipe for disaster.<br> </div> Thu, 08 Jul 2010 14:57:49 +0000 Ramdisks and hard drives as cache devices https://lwn.net/Articles/395422/ https://lwn.net/Articles/395422/ etienne <div class="FormattedComment"> <font class="QuotedText">&gt; I imagine that Bcache caches O_DIRECT reads and writes, which could give a caching advantage even where an application has elected to bypass the ordinary buffer cache.</font><br> <p> An application like a boot-loader installation/upgrade which tries to tell which disk sectors to load from the MBR?<br> I hope there is a sync() to write to (the real destination) disk.<br> </div> Thu, 08 Jul 2010 14:57:08 +0000