292 points · by jlpcsl · 3y ago · 237 comments
Specifically, robustness to everything around them not performing as required. For example, imagine an evil SSD which had a 1% chance of rolling a sector back to a previous version, a 1% chance of saying a write failed when it didn't, a 1% chance of writing data to the wrong sector number, a 1% chance of flipping some bits in the written data, and a 1% chance of disconnecting and reconnecting a few seconds later.
Real SSD's have bugs that make them do all of these things.
Given this evil SSD, I want to know how long the filesystem can keep going serving the users usecase.
nbdkit memory 10G --filter=error error-rate=1%
... and then nbd-loop-mount that as a block device and create your filesystem on top.Notes:
We're working on making a ublk interface to nbdkit plugins so the loop mount wouldn't be needed.
There are actually better ways to use the error filter, such as triggering it from a file, see the manual: https://www.libguestfs.org/nbdkit-error-filter.1.html
It's an interesting idea to have an "evil" filter that flips bits at random. I might write that!
[0]: https://www.kernel.org/doc/html/latest/admin-guide/device-ma...
The advantage is you can write plugins as regular code in lots of different programming languages, with a stable API and ABI: https://www.libguestfs.org/nbdkit.1.html So it's a lot easier to experiment or write plugins for odd devices.
Also our sparse RAM disk supports huge disks (up to 16 exabytes IIRC, 2^63-1 bytes whatever that is).
There are stories from the ZFS folks of dealing with these issues and things ran just fine.
While not directly involved with ZFS development (IIRC), Bryan Cantrill was very 'ZFS-adjacent' since he used Solaris-based systems for a lot of his career, and he has several rants about firmware that you can find online.
A video that went viral many years ago, with Cantrill and Brendan Gregg, is "Shouting in the Datacenter":
* https://www.youtube.com/watch?v=tDacjrSCeq4
* https://www.youtube.com/watch?v=lMPozJFC8g0 (making of)
Let's say you have 6 drives in raidz2. If you have a 1% silent failure chance per block, then writing a set of 6 blocks has a 0.002% silent failure rate. And ZFS doesn't immediately verify writes, so it won't try again.
If that's applied to 4KB blocks, then we have a 0.002% failure rate per 16KB of data. It will take about 36 thousand sets of blocks to reach 50% odds of losing data, which is only half a gigabyte. If we look at the larger block ZFS uses internally then it's a handful of gigabytes.
And that's without even adding the feature where writing one block will corrupt other blocks.
- A RAIDz1 (RAID5) pool with a second disk start failing while rebuilding from an earlier disk failure (data was fine)
- A water to air CPU cooler leaking, CPU overheated and the water shorted and killed the HBA running a pool (data was fine)
- An SFF-8088 cable half plugged in for months, pool would sometimes hiccup, throw off errors, take a while to list files, but worked fine after plugging it in properly (data was fine after)
Then the usual disk failures which are a non-event with ZFS.
So shrug
mdadm doesn’t checksum data, and just trusts the HDD to either return correct data, or an error. But HDDs return incorrect data all the time, their specs even tell you how much incorrect data they’ll return, and for anything over about 8TB you’re basically guaranteed some silent corruption if you read every byte.
People seem to love ZFS but I had no issues running mdadm. I'm now running a ZFS pool and so far it's been more work (and things to learn), requires a lot more RAM, and the benefits are... escaping me.
RAID is not backup, always remember that!
Like, which manufacturer goes, like "tests show we cannot write more that 400kB without corrupting drive, let us ship this!" ?
According to https://www.sqlite.org/howtocorrupt.html there are such drives:
4.2. Fake capacity USB sticks
There are many fraudulent USB sticks in circulation that report to have a high capacity (ex: 8GB) but are really only capable of storing a much smaller amount (ex: 1GB). Attempts to write on these devices will often result in unrelated files being overwritten. Any use of a fraudulent flash memory device can easily lead to database corruption, therefore. Internet searches such as "fake capacity usb" will turn up lots of disturbing information about this problem.
Bit flips amd overwriting wrong sectors from unrelated files being written are also mentioned. You might think this sort of thing is just cheap USB flash drives, bit I've been told about NVMe SSDs violating their guarantees and causing very strange corruption patterns too. Unfortunately when the cause is a bug in the storage's device own algorithms, the rare corruption event is not necessarily limited to a few bytes or just 1 sector here or there, nor to just the sectors being written.
I don't know how prevalent any of these things are really. The sqlite.org says "most" consumer HDDs lie about commiting data to the platter before reporting they've done so, but when I worked with ext3 barriers back in the mid 2000s, the HDDs I tested had timing consistent with flushing write cache correctly, and turning off barriers did in fact lead to observable filesystem corruption on power loss, which was prevented by turning on barriers. The barriers were so important they made the difference between embedded devices that could be reliably power cycled, vs those which didn't reliably recover on boot.
Those drives have a sudden flip from 0% corruption to 95-100% corruption when you hit their limits. I wouldn't count that as the same thing. And you can't reasonably expect anything to work on those.
> The sqlite.org says "most" consumer HDDs lie about commiting data to the platter before reporting they've done so, but when I worked with ext3 barriers back in the mid 2000s, the HDDs I tested had timing consistent with flushing write cache correctly
Losing a burst of writes every once in a while also manifests extremely differently from steady 1% loss and needs to be handled in a very different way. And if it's at power loss it might be as simple as rolling back the last checkpoint during mount if verification fails.
However, if something like a power failure or firmware crash happens, and the bookkeeping writes never happen, then the end result that the user sees after a reboot is their data written to the wrong sector.
> 1% chance of disconnecting and reconnecting a few seconds later
I actually have such an SSD. It's unusable, when it is in that state. The FS doesn't corrupt the data, but it's hard for the OS to make forward progress, and obviously a lot of writes fail at the application level. (It's a shitty USB implementation on the disk: it disconnects if it's on a USB-3 capable port, and too much transfer occurs. It's USB-2, though; connecting it to a USB-2-only port makes it work just fine.)
At least in Unix the assumption is that disks are always attached (and reliable...) so write errors don't typically bubble up to the application layer. This is why losing an NFS mount typically just hangs the system until it recovers.
I want to say a physical disk being yanked from the system (essentially what was happening, as far as the OS could tell) does cause I/O errors in Linux? I could be wrong though, this isn't exactly something I try to exercise.
As for it being a distributed system … I suppose? But that's what an FS's log is for: when the drive reconnects, there will either be a pending WAL entry, or not. If there is, the write can be persisted, otherwise, it is lost. But consistency should still happen.
Now, an app might not be ready for that, but that's an app bug.
But it can always happen that the power goes out, which in my situation is equivalent to a disk yank. There's also small children, the SO tripping over a cable, etc.
But these are different failure modes from some of what the above post listed, such as disks undoing acknowledged writes, or lying about having persisted the write. (Some of the examples are byzantine, some are not.)
You could also look at this: https://rwmj.wordpress.com/2020/03/21/new-nbdkit-remote-tmpf... We use it for Koji builds, where we actually don't care about keeping the build tree around (we persist only the built objects and artifacts elsewhere). This plugin is pretty fast for this use case because it ignores FUA requests from the filesystem. Obviously don't use it where you care about your data.
Uhh hello, pricing ?
> maybe disable flushes with https://github.com/stewartsmith/libeatmydata
overlayfs has a volatile mount option that has that effect. So stacking a volatile overlayfs with the upper and lower on the same ext4 could provide that behavior even for applications that can't be intercepted with LD_PRELOAD
[1]: https://www.kernel.org/doc/Documentation/blockdev/ramdisk.tx...
[2]: https://blog.delouw.ch/2020/01/29/using-lvm-cache-for-storag...
Because I have the best storage performance you'll ever find anywhere, 100% money-back guaranteed: write to /dev/null. It comes with the downside of 0% reliability.
You can write to a disk without a file-system, sequentially, until space ends. Quite fast actually, and reliable, until you reach the end, then reliability drops dramatically.
On a related note, though, I've considered the idea of creating a "minimally POSIX-compliant" filesystem that randomly reorders and delays I/O operations whenever standards permit it to do so, along with any other odd behavior I can find that remains within the letter of published standards (unusual path limitations, support for exactly two hard links per file, sparse files that require holes to be aligned on 4,099-byte boundaries in spite of the filesystem's reported 509-byte block size, etc., all properly reported by applicable APIs).
P.S. I'm fairly certain that /dev/null would lose my data a bit more often than once a week.
Any files that are important would go to a separate, more reliable filesystem (or uploaded elsewhere).
This is not the kind of frequency you need to protect against. You just need to detect it and replace the drive ASAP.
Bonus points for making the result efficiently support multiple nodes, each with multiple disks.
Also, the original developer of bcachefs (as well as bcache), Kent Overstreet posts status updates from time to time on his Patreon page.[1]
[0] https://bcachefs.org/bcachefs-principles-of-operation.pdf
I was wondering if bcachefs is architectured with NAND-flash SSD hardware in mind (as recently highlighted on HN in the "Is Sequential IO Dead In The Era Of The NVMe Drive" article [1] [2]), to optimize IO and hardware lifecycle.
Skimming through the "bcachefs: Principles Of Operation" PDF, it appears the answer is no.
[1] https://jack-vanlightly.com/blog/2023/5/9/is-sequential-io-d...
Basicaly i just state what size i want that subtree to be and it happens without having to touch underlying block devices. Also i can change it anytime during runtime extremely easily. Eg.:
zfs set quota=42G tank/vps/my_vps
zfs set quota=32G tank/vps/my_vps
zfs set quota=23G tank/vps/my_other_vps
btrfs can kinda do this as well, but the commands are not as straighforward as in zfs.
update: My bad. bcachefs seems to have subvolumes now. there is also some quota support, but so far the documentation is bit lacking, so not yet sure how to use that and if that can be configured per dataset.
Advantages over other filesystems:
* ext4 or xfs — these two don't use ECC to protect your data, only the filesystem metadata
* zfs — zfs is technically great, but binary distribution of the zfs code is tricky, because the CDDL is GPL incompatible
* btrfs — btrfs still doesn't have reliable RAID5
[1] It's been in development for a number of years. It now being proposed for inclusion in the mainline kernel is a major milestone.
Building your own ZFS module is easy enough, for example on Arch with zfs-dkms.
But there's also the issue of compatibility. Sometimes kernel updates will break ZFS. Even minor ones, 6.2.13 IIRC broke it, whereas 6.2.12 was fine.
Right now, 6.3 seems to introduce major compatibility problems.
---
edit: looking through the openzfs issues, I was likely thinking of 6.2.8 breaking it, where 6.2.7 was fine. Point stands, though. https://github.com/openzfs/zfs/issues/14658
Regarding 6.3 support, it apparently is merged in the master branch, but no release as of yet. https://github.com/openzfs/zfs/issues/14622
In my case, the Arch package is more of a "recipe maker". It fetches the Linux headers and the zfs source code and compiles this for local use. As far as they are concerned, there is no distribution of the resulting artifact. IANAL, but I think if there's an issue with that, then OpenZFS is basically never usable under Linux.
Other companies distributed kernels with zfs support directly, such as Ubuntu. I don't recall there being news of them being sued over this, but maybe they managed to work something out.
Oracle is very litigious. However, OpenZFS has been releasing code for more than a decade. Ubuntu shipped integrated ZFS/Linux in 2016. It's certain that Oracle knows all about it and has decided that being vague is more in their interests than actually settling the matter.
On my list of potential legal worries, this is not a priority for me.
The worst case scenarios would be something like Ubuntu being unable to provide compiled modules, but dkms would still be fine. Or the very unlikely ZFS on Linux getting sued, but that would involve a lengthy trial that would allow you to move away from Open ZFS.
> Even minor ones, 6.2.13 IIRC broke it, whereas 6.2.12 was fine.
Interesting!
It's just a shame the license has hindered adoption. Ubuntu were shipping binary ZFS modules at one point, but they have walked back from that.
Still easy. Under Arch, the kernel image isn't signed, so if you enable secure boot you need to fiddle with signing on your own. At that point, you can just sign the kernel once the module is built. Works fine for me.
This is incorrect? Ubuntu is still shipping binary modules.
It's only great due to the lack of competitors in the checksummed-CoW-raid category. It lacks a bunch of things: Defrag, Reflinks, On-Demand Dedup, Rebalance (online raid geometry change, device removal, device shrink). It also wastes RAM due to page cache + ARC.
blinks eyes, shakes head
"It's only great because it's the only thing that's figured out how to do a hard thing really well" may be peak FOSS entitlement syndrome.
Meanwhile, btrfs has rapidly gone nowhere, and, if you read the comments to this PR, bcachefs would love to get to simply nowhere/btrfs status, but is still years away.
ZFS fulfills the core requirement of a filesystem, which is to store your data, such that when you read it back you can be assured it was the data you stored. It's amazing we continue to countenance systems that don't do this, simply because not fulfilling this core requirement was once considered acceptable.
A reminder that it came out in 2009:
* https://en.wikipedia.org/wiki/Btrfs
(ext4 was declared stable in 2008.)
You forgot robust native encryption, network transparent dump/restore (ZFS send/receive) - and broad platform support (not so much anymore).
For a while you could have a solid FS with encryption support for your USB hd that could be safely used with Linux, *BSD, Windows, Open/FOSS Solaris and MacOS.
Even if it doesn’t implement every feature from the real zfs, it would still be handy for OS compatibility reasons.
But credit where credit is due: for a long time, ZFS has been the only fit for purpose filesystem, if you care about the integrity of your data.
btrfs and bcachefs rebalance leave your pool as if you had created it from scratch with the existing data and the new layout.
The data goes through two caches instead of just page cache or just arc as far as I understand it.
Synology offers btrfs + RAID5 without warning the user. I wonder why they’re so confident with it.
I somewhat recall there being a little progress on trying to fix the remaining "write hole" issues, in the past year or two. But in general, I think there's very little pressure to do so because so very many many people run raid-5 for data already & it works great. Getting Metadata off raid1 is low priority, a nice to have.
I use btrfs on most of my Linux systems now (though only one with raid5), except for backup disks and backups volumes: those I intend to keep on ext4 indefinitely.
I’ll very happily move back from MD raid 5 when linear scrub for parity raid lands
I have seen a bunch of changes in the past year go by about how scrubbing is prioritized & what capacity it is allocated. On the one hand, unsettling. But also, good to see folks are prodding at this area.
not a measure of quality in the slightest. btrfs had some serious bugs over the years despise being in mainline
A fast SSD can be set as the target for foreground writes, but that data will be transparently copied in the background to a "background" target, i.e. a large/slow disk.
If this works, it will be awesome.
I can't recommend such a setup though. It works very poorly for me.
I set it up in the past with an mdadm RAID1 array over SSDs as a caching layer in front of another mdadm array over HDDs. It performed quite well in a developer/compute workstation environment.
This is very similar in concept to (or an evolution of?) ZFS's ZIL:
* https://www.servethehome.com/what-is-the-zfs-zil-slog-and-wh...
* https://www.truenas.com/docs/references/zilandslog/
* https://www.45drives.com/community/articles/zfs-caching/
When this feature was first introduced to ZFS in the Solaris 10 days there was an interesting demo from a person at Sun that I ran across: he was based in a Sun office on the US East Coast where he did stuff, but had access to Sun lab equipment across the US. He mounted iSCSI drives that were based in (IIRC) Colorado as a ZFS poool, and was using them for Postgres stuff: the performance was unsurprisingly not good. He then add a local ZIL to the ZFS pool and got I/O that was not too far off from some local (near-LAN) disks he was using for another pool.
Async writes on a default configuration don't hit the ZIL, only RAM for a few seconds then disk. Sync writes are RAM to ZIL, confirm write, then RAM to pool.
Bcache (not bcachefs) is more equivalent to ZIL.
I used it extensively back in the day and it was remarkably solid. https://wiki.archlinux.org/title/bcache
I think it summarizes its features and strengths pretty well, and it has a lot of good technical information.
(...I realise it must be B-cache-fs)
There's a little x86-64 code generator in bcachefs to generate some sort of btree unpacking code.
Like when you have an entry like "bring back function which could make developing viruses easier (through not a vulnerability by themself) related to memory management and code execution" the default answer is nop .. nooop .. never. (Which doesn't mean that it won't come back).
It seems while it's not necessary to have this it's a non-neglible performance difference.
What I'd like to see even more though would be a switch from the existing posix based filesystem APIs to a transaction based system. It is way too complicated to do filesystem operations that are not prone to data corruption should there be any issues.
The only thing to be aware of is to disable CoW/Hashing on database stores or streaming download folders. Otherwise it'll rehash each file update, which isn't needed.
I've not dared try bcachefs out though, I'm quite wary of data loss, even on my laptop. Does anyone have experience to share?
Edit: Reasons for home being btrfs. I set this up a long fucking time ago and it was more or less meant as a stresstest for bcachefs. Since I didn't want data loss on important data (like my home) I left my home as btrfs
There is no single filesystem which is optimized for everything, so you need to specify things like
cross-platform transportability, network transparency, hardware interfaces, hardware capability, reliability requirements, cost-effectiveness, required features, expected workload, licensing
and what the track record is in the real world.
There's a word for 'RW snapshots': clones. E.g.
* https://docs.netapp.com/us-en/ontap/task_admin_clone_data.ht...
* http://doc.isilon.com/onefs/9.4.0/help/en-us/ifs_t_clone_a_f...
* https://openzfs.github.io/openzfs-docs/man/8/zfs-clone.8.htm...
* http://www.voleg.info/lvm2-clone-logical-volume.html
In every other implementation I've come across the word "snapshot" is about read-only copies. I'm not sure why btrfs (and now bcachefs?) thinks it needs to muddy the nomenclature waters.
So what do you call a RO snapshot? Or do you now need to write the prefix "RO" and "RW" everywhere when referring to a "snapshot"?
How do CLI commands work? Will you have "btrfs snapshot" and then have to always define whether you want RO or RW on every invocation? This smells like git's bad front-end CLI porcelain all over again (regardless of how nice the back-end plumbing may be).
This is a solved problem with an established nomenclature IMHO: just use the already-existing nouns/CLI-verbs of "snapshot" and "clone".
> […] is clearer because a snapshot generally doesn't mean simple duplication.
A snapshot generally means a static copy of the data, with bachefs (and ZFS and btrfs) being CoW then it implies new copies are not needed unless/until the source is altered.
If you want deduplication use "dedupe" in your CLI.
There should be no read-only snapshot: it's just a writable snapshot where you don't happen to perform a write
LOL, they know what the problem is at least. I will try it out on some old hard disks. The others (esp. looking at you btrfs) are not good at not losing your entire volumes when disks start to go bad.
slow storage ----> cache ----> export over nfs ---> client
Does it support mountable subvolumes like btrfs?