News for hackers. Stuff that matters.
Re:What’s New in Apple Filesystems [pdf] by vardump on Tuesday June 11, 2019 @01:15PM (#20157414)
So containers with a new bi-directional hardlink "Firmlink" (intended to be invisible to applications, link between encrypted containers), with read only volumes protecting system software.

ZFS send/receive style volume serialization for replication backup, etc. File system snapshot support included.

iOS or should I say iPadOS supports external USB media and SMB.

What seems to be missing is block level checksumming and integrity checks, scrubbing, block level duplication to protect important files, etc. No whiff of deduplication either, but that might be too memory intensive for Apple's purposes.

Re:What’s New in Apple Filesystems [pdf] by jandrese on Tuesday June 11, 2019 @01:31PM (#20157562)
My understanding is that deduplication has generally been not worth the effort for a general use filesystem. The cost in memory, cpu, and sheer complexity doesn't pay off in enough storage savings. Disk space is relatively cheap. Filesystem crashes/corruption are not.
Re:What’s New in Apple Filesystems [pdf] by vardump on Tuesday June 11, 2019 @01:35PM (#20157585)
Yeah, block level deduplication is not useful for files on a typical consumer laptop. I can imagine it's even less useful for files on iOS devices.

However it is often great for virtual machines and other software development related things, as long as all the underlying block sizes and alignments match.

You really do want strong integrity guarantees though. One corrupted block can cause a lot of damage.

Re:What’s New in Apple Filesystems [pdf] by Scaevolus on Tuesday June 11, 2019 @02:04PM (#20157894)
The filesystem encryption used on iOS probably makes deduplication even less effective.
Re:What’s New in Apple Filesystems [pdf] by vardump on Tuesday June 11, 2019 @02:20PM (#20158068)
Depends on the layering order. You can do both dedup and encryption in the same time, if the encryption occurs on a lower layer.
Re:What’s New in Apple Filesystems [pdf] by eridius on Tuesday June 11, 2019 @02:25PM (#20158125)
Encryption in iOS is per-file. I'm not sure the OS really wants to go ahead and individual decrypt large numbers of files just to check if there are any duplicated blocks.
Re:What’s New in Apple Filesystems [pdf] by Damogran6 on Tuesday June 11, 2019 @01:55PM (#20157788)
Not only that, but a Server with 100 VM's is going to have a substantial percentage of each OS image as identical...not so much on an average consumer laptop.
Re:What’s New in Apple Filesystems [pdf] by FPGAhacker on Tuesday June 11, 2019 @01:40PM (#20157639)
Disk space isn’t cheap on a Mac laptop.
Re:What’s New in Apple Filesystems [pdf] by mikepurvis on Tuesday June 11, 2019 @01:46PM (#20157703)
Yeah, but that's a customer cost, not an Apple cost.

In any case, dedup just makes things more confusing to the customer— like, "you have X GB in files on your computer, but more than N-X GB free space because of magical deduplication." Or worse, "You deleted all those files, but didn't actually free up any space because they were dupes. So sad."

Re:What’s New in Apple Filesystems [pdf] by Wowfunhappy on Tuesday June 11, 2019 @01:56PM (#20157799)
> In any case, dedup just makes things more confusing to the customer— like, "you have X GB in files on your computer, but more than N-X GB free space because of magical deduplication." Or worse, "You deleted all those files, but didn't actually free up any space because they were dupes. So sad."

For what it's worth, this can already happen in APFS. While they don't have real deduplication, if you copy a file within Finder, that copy won't take up extra space.

Re:What’s New in Apple Filesystems [pdf] by jjoonathan on Tuesday June 11, 2019 @03:28PM (#20158715)
How granular is the COW? If you touch a byte, does just a block get copied or the whole file?
Re:What’s New in Apple Filesystems [pdf] by cmurf on Tuesday June 11, 2019 @04:53PM (#20159441)
It depends on the application. Often applications do a kind of COW on their own, behind the scene they write out a new file with a randomized naming scheme, when that succeeds, do a rename/replace. So in this case you're getting a new file, as in, a file with a new inode.

If your application is smarter, then it could just COW one block, whatever the minimum block size is for that file system. e.g. for Btrfs it's page size, so x86 that's 4KiB, ppc64le it's 64KiB. I'm not sure what it is for APFS, I'd guess 4KiB. It could actually be inefficient depending on the use case, e.g. a 1MiB file with a single byte change in the middle, if it were a single 1MiB extent, becomes three extents with COW:

    0-500KiB - extent 1
    500-504KiB - hole where stale data is
    504KiB-1MiB - extent 3
    4KiB   - extent 2, with new data, a copy of 4095 bytes from the above hole, with 1 bytes of new data.
Edit: 2nd paragraph suggests the application would COW if it's smarter; that's not correct. If it's smarter, it would request an overwrite of some portion of the file and the file system is what would COW (if it's a COW file system). Granularity depends on a combination of application and file system.

Edit 2: More detailed answer on Btrfs. The whole file system on a zram device is about 260 lines using 'btrfs inspect-internal dump-tree' command. I'll excerpt just the file extents.

1. 'dd if=/dev/zero of=/mnt/test/bunchofzeros.txt bs=M count=1' results in this:

    item 7 key (257 EXTENT_DATA 0) itemoff 3409 itemsize 53
    generation 7 type 1 (regular)
    extent data disk byte 5283840 nr 1048576
    extent data offset 0 nr 1048576 ram 1048576
    extent compression 0 (none)
2. Using vi to change one character and save as the same file, ':wq', I get:

    item 7 key (262 EXTENT_DATA 0) itemoff 3409 itemsize 53
    generation 9 type 1 (regular)
    extent data disk byte 7401472 nr 1052672
    extent data offset 0 nr 1052672 ram 1052672
    extent compression 0 (none)
So you can see it's a new file, new inode, and looks like length is changed too, maybe something to do with encoding.

3. Delete that file and create a new one with the same 'dd' command as in 1.

    item 7 key (266 EXTENT_DATA 0) itemoff 3409 itemsize 53
    generation 11 type 1 (regular)
    extent data disk byte 5283840 nr 1048576
    extent data offset 0 nr 1048576 ram 1048576
    extent compression 0 (none)

    [root@flap ~]# dd conv=notrunc if=/dev/urandom bs=1 seek=524290 count=1 of=/mnt/test/bunchofzeros.txt 
    [root@flap ~]# hexdump -C /mnt/test/bunchofzeros.txt | more
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00080000  00 00 5d 00 00 00 00 00  00 00 00 00 00 00 00 00  |..].............|
    00080010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00100000

    item 7 key (266 EXTENT_DATA 0) itemoff 3409 itemsize 53
    generation 11 type 1 (regular)
    extent data disk byte 5283840 nr 1048576
    extent data offset 0 nr 524288 ram 1048576
    extent compression 0 (none)
    item 8 key (266 EXTENT_DATA 524288) itemoff 3356 itemsize 53
    generation 14 type 1 (regular)
    extent data disk byte 5242880 nr 4096
    extent data offset 0 nr 4096 ram 4096
    extent compression 0 (none)
    item 9 key (266 EXTENT_DATA 528384) itemoff 3303 itemsize 53
    generation 11 type 1 (regular)
    extent data disk byte 5283840 nr 1048576
    extent data offset 528384 nr 520192 ram 1048576
    extent compression 0 (none)
Clever. item7 and item9 actually reference the same original 1MiB data extent, but use offsets to point to the unchanged portion "creating" a 4KiB hole, and that hole is filed by item 8, a 4KiB extent containing the change. So it really did only COW one block.
Re:What’s New in Apple Filesystems [pdf] by Wowfunhappy on Tuesday June 11, 2019 @06:13PM (#20159993)
Sorry, I can’t tell, are you still talking about APFS?
Re:What’s New in Apple Filesystems [pdf] by cmurf on Tuesday June 11, 2019 @10:05PM (#20161148)
No the example under Edit 2 is Btrfs. On the details I'd expect APFS to differ. But the gist is that how changes manifest on disk do also depend on the application being used. On any file system, an edit in vi means a whole new file is written out, so it's effectively COW at an application level. Whereas an edit with an application that does byte level overwrites, would get translated into COW on a COW file system like Btrfs, APFS or ZFS. And I'd expect this COW operation to operate at the file system's minimum block level size.
Re:What’s New in Apple Filesystems [pdf] by mindajar on Tuesday June 11, 2019 @04:18PM (#20159149)
Just a block
Re:What’s New in Apple Filesystems [pdf] by duskwuff on Tuesday June 11, 2019 @02:11PM (#20157978)
Or even worse: "You no longer have any free space on your hard disk because you made a change to a large file that had a deduplicated copy."
Re:What’s New in Apple Filesystems [pdf] by voxadam on Tuesday June 11, 2019 @02:15PM (#20158022)
Block level deduplication should limit the impact of this case.
Re:What’s New in Apple Filesystems [pdf] by duskwuff on Tuesday June 11, 2019 @03:41PM (#20158841)
Only if the change is localized to specific blocks.

Besides, block-level dedup is expensive to maintain. Unless you're expecting to find a lot of duplicates -- which probably isn't the case on most end-user devices -- it's a net loss.

Re:What’s New in Apple Filesystems [pdf] by avani on Tuesday June 11, 2019 @04:33PM (#20159262)
Expect about 30%, most of it in smaller system files and libraries. Block-level dedup is great for pretty much anything where you have a consistent workflow.
Re:What’s New in Apple Filesystems [pdf] by macintux on Tuesday June 11, 2019 @08:49PM (#20160826)
A consistent workflow sounds like something you’re going to find more regularly on a server than a mobile device or home computer.
Re:What’s New in Apple Filesystems [pdf] by dictum on Tuesday June 11, 2019 @02:06PM (#20157926)
In my opinion storing, not deleting, is the most important job of a file system. Increased efficiency and free space is a better proposition than replicating the average user's mental model of free space in the volume.

(If my opinion holds true, then deduplicating is a problem when it comes to storage: a copy made to prevent bitrot/other damage to the original data doesn't work as such.)

Re:What’s New in Apple Filesystems [pdf] by Wowfunhappy on Tuesday June 11, 2019 @04:10PM (#20159084)
> Increased efficiency and free space is a better proposition than replicating the average user's mental model of free space in the volume.

I'm not sure if I agree.

In an ideal world, it makes sense that performance should be paramount. In reality, I think it's often more important that computers do what we expect them to, so we can predict when they'll break and know how to resolve the problem when they do. This is all the more important in consumer software.

"My hard drive is out of space" is a very basic computer problem that most users will run into at some point. The intuitive solution is to delete stuff. If that solution doesn't work, it could be a major problem.

Re:What’s New in Apple Filesystems [pdf] by voxadam on Tuesday June 11, 2019 @02:18PM (#20158050)
Storing vs deleting is one of the reasons that I'd love to see more research done on log based filesystems.
Re:What’s New in Apple Filesystems [pdf] by jandrese on Tuesday June 11, 2019 @02:52PM (#20158375)
It's cheaper than the memory upgrade you need to support dedup properly.
Re:What’s New in Apple Filesystems [pdf] by leiroigh on Tuesday June 11, 2019 @03:19PM (#20158623)
Not really. ZFS dedup is just brain-dead stupid. Rabin-Karp chunking plus spatial locality / opportunistic dedup allow you to gracefully scale down: you keep a complete table of successfully deduped blocks, plus a small fraction of other blocks, like e.g. smallest 1% of hashes, first blocks in files and final blocks in files. If you have a 12 MB (100 blocks) stretch that matches, you have 63% (1-1/e) chance of discovering one of these blocks as a match, and then use spatial locality to dedup adjacent blocks (duplicate blocks tend to come in bunches).
Re:What’s New in Apple Filesystems [pdf] by jandrese on Tuesday June 11, 2019 @04:56PM (#20159465)
Then why does turning on dedup on ZFS suddenly make it chomp through 4GB of memory? Is there some tuneable you're supposed to be setting to make it less insane?
Re:What’s New in Apple Filesystems [pdf] by bluedino on Tuesday June 11, 2019 @01:58PM (#20157835)
They do RAM compression, I thought disk compression was soon to follow after Apple went all-flash storage
Re:What’s New in Apple Filesystems [pdf] by yakkers on Tuesday June 11, 2019 @11:24PM (#20161513)
APFS does indeed do compression, the rationale being that compute is cheaper than I/O.

Even if most files on a typical personal computer are already inherently compressed (JPEG photos, lossy audio, etc.), you're not losing any performance, and are gaining some extra space where possible.

Re:What’s New in Apple Filesystems [pdf] by twoodfin on Tuesday June 11, 2019 @07:32PM (#20160466)
Presumably not particularly valuable since most of what takes up consumer storage these days (pictures, videos, app assets) is already in some highly compressed format.
Re:What’s New in Apple Filesystems [pdf] by ghaff on Tuesday June 11, 2019 @01:57PM (#20157816)
Relative to what? I've been around long enough it's hard for me to see just about any disk storage as expensive even if it costs more than whatever is on sale at Newegg.
Re:What’s New in Apple Filesystems [pdf] by FPGAhacker on Tuesday June 11, 2019 @03:44PM (#20158866)
Mac laptops aren’t upgradable without goofy adapters to convert nvme ssd m.2 to apple’s form factor, at which point your case won’t close up without flexing the aluminum or main board or both. For many MacBook Pro users, upgrading storage is buying a new laptop.

That’s expensive in my opinion.

OWC has made drives that fit Apple’s form factor (assuming your laptop is old enough) for a nice premium. Depending on which laptop you have, this can still be a science experiment.

Re:What’s New in Apple Filesystems [pdf] by api on Tuesday June 11, 2019 @10:21PM (#20161213)
Same with transparent compression in most cases.
Re:What’s New in Apple Filesystems [pdf] by sneak on Tuesday June 11, 2019 @01:48PM (#20157729)
It is a real bummer that there are still no content checksums available. One can work around this by doing sums and scrubs in userspace by storing mtime+hash in an xattr and periodically verifying and updating them. There is a utility to do this but I forgot the name.
Re:What’s New in Apple Filesystems [pdf] by zeotroph on Tuesday June 11, 2019 @02:23PM (#20158101)
For a company which primarily sells consumer products it makes sense to omit hardware checksums: You just detect errors which the end user might never notice, a bit flip in a picture you never look at again might not be that bad.

For anyone who has ever heard of checksums this makes APFS a no-go of course.

Re:What’s New in Apple Filesystems [pdf] by privateSFacct on Tuesday June 11, 2019 @02:38PM (#20158251)
I guess NTFS is also a "no go" for file storage then as well.

What about ext4? Oh wait - no file data checksums - so a "no go".

Actually, it turns out plenty of folks have built plenty of storage on these platforms - including APFS.

In particular, for APFS, apple uses ECC for all hardware, uses fletcher checksums for metadata and I believe does a copy on write approach to help handle sudden power loss events etc. It seems to be working out OK for them given the prices they charge.

Re:What’s New in Apple Filesystems [pdf] by rhinoceraptor on Tuesday June 11, 2019 @04:32PM (#20159260)
Just because you can't currently see any problems doesn't mean you're not surrounded by them. You can't see the problems because no one has turned on the lights.
Re:What’s New in Apple Filesystems [pdf] by isomorphic on Tuesday June 11, 2019 @03:46PM (#20158890)
Your point that other filesystems get by without checksums stands, but Apple does not use ECC for all hardware.

Also, we are left to wonder if their "reliable" SSDs are as reliable as checksums at the filesystem layer (or as reliable as both). I suspect the answer is yes, for the majority of applications running atop APFS (which is to say, iOS). Probably not for video assets on that Promise MPX bay (i.e. "external" non-Apple storage media).

Re:What’s New in Apple Filesystems [pdf] by AlphaSite on Wednesday June 12, 2019 @03:54AM (#20162596)
I do t think zfs can handle memory correction without ecc either, so is no better in this case.
Re:What’s New in Apple Filesystems [pdf] by sneak on Tuesday June 11, 2019 @04:48PM (#20159397)
I use removable storage. SD cards, USB flash drives, USB hard disks.

Apple’s hardware choices are irrelevant.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Wednesday June 12, 2019 @07:55AM (#20163618)
Those other file systems were designed a while ago.

If you're going to design one now, is there any reason to not have a checksuming capability? At least as an option, even though it may be default-off.

Re:What’s New in Apple Filesystems [pdf] by zeotroph on Tuesday June 11, 2019 @04:32PM (#20159259)
All the next gen, copy on write filesystems have checksums: NTFS+ (ReFS) has it, ext4+ (btrfs) has it, but HPFS++ (APFS) has not. Bummer.

At least optional checksums should be supported, then watchOS does not waste time with it but a user with 10k+ mac workstation who might still uses spinning rust for bulk data storage is SOL.

Re:What’s New in Apple Filesystems [pdf] by floatboth on Tuesday June 11, 2019 @05:29PM (#20159703)
> NTFS+ (ReFS), ext4+ (btrfs)

That's.. an extremely confusing way to put it. ReFS and btrfs are from-scratch new FSes.

Re:What’s New in Apple Filesystems [pdf] by privateSFacct on Tuesday June 11, 2019 @06:43PM (#20160183)
is ext4+ really shipping in volume? I checked RHEL, not the default.

Is NTFS+ the default on Windows 10 / Windows Server 2016 or 2019?

APFS is shipping today in quantity / as default and I believe they back migrated literally millions of devices to it something like a year ago.

I don't understand the user use case with a 10K workstation and no raid (ie, with parity etc) + SSD with internal error correction. So this is a $10K workstation with magnetic disks and no other error correcting option / layer? Why do this?

Re:What’s New in Apple Filesystems [pdf] by zeotroph on Tuesday June 11, 2019 @07:20PM (#20160405)
SLES (Suse) is going all in with btrfs, it is no ZFS but better than the equivalent RH solution of offering an LVM or other blocklevel layer of checksums.

Not to mention all the ..BSD or ZfsOnLinux based storage solutions.

I am not denying that APFS is a good FS, but not even having the option of checksums given its contemporaries was clearly a political and financial decision to benefit Apple and not its users. Pointing to an opaque mix of raid (and indeed, raid10 is not even enough), super-reliable SSDs and the full stack control doesn't make the lack of checksums any better.

Re:What’s New in Apple Filesystems [pdf] by jplayer01 on Wednesday June 12, 2019 @05:04AM (#20162923)
I don't really understand what the deal is with ReFS. Is this ever intended to reach normal consumers or are they happy with NTFS?
Re:What’s New in Apple Filesystems [pdf] by Hackbraten on Tuesday June 11, 2019 @02:00PM (#20157851)
I’m thinking of moving back from ZFS to APFS if I had such a workaround. Block- or file-level integrity is now the only thing that keeps me back.
Re:What’s New in Apple Filesystems [pdf] by privateSFacct on Tuesday June 11, 2019 @02:45PM (#20158300)
What are the use cases folks have with super high reliability needs?

I'm generally more worried about an SSD falling over entirely - so focus is on duplication (raid with hot spare -> offsite S3 backup).

Re:What’s New in Apple Filesystems [pdf] by wang_li on Tuesday June 11, 2019 @03:53PM (#20158937)
From a user perspective it's effectively a zero cost feature. Apple should add it in.
Re:What’s New in Apple Filesystems [pdf] by privateSFacct on Tuesday June 11, 2019 @06:47PM (#20160198)
OK - so they do a block level checksum (no error correction but it would let you know that something went wrong). Now something goes wrong with checksum. Is this a "zero cost" feature to have every app updated to handle this checksum error. What is gained? If you need reliability do something like SSD or a raid option and a backup.
Re:What’s New in Apple Filesystems [pdf] by wang_li on Tuesday June 11, 2019 @07:05PM (#20160321)
The apps don't have to deal with it. It's a read error. Presumably something they already deal with. There's no operational difference for the end user between a block that can't be read and a block than can be read but with corrupted data. And yes, storage would ideally be paired with another physical device to provide redundancy and a mechanism to correct the error on the erroring device.
Re:What’s New in Apple Filesystems [pdf] by zeotroph on Tuesday June 11, 2019 @07:25PM (#20160431)
Or just pair it with iCloud and "cloud heal" the corrupted local data. Then mark the sector as bad and enjoy longer lifetime for the device.
Re:What’s New in Apple Filesystems [pdf] by sneak on Tuesday June 11, 2019 @05:17PM (#20159623)
I just built an external storage server on a supermicro 2U with 80TB of hdd and 2TB of fast flash running ZFS and connected to my Mac via 10GE. Best of both worlds.
Re:What’s New in Apple Filesystems [pdf] by sneak on Tuesday June 11, 2019 @05:02PM (#20159513)
https://github.com/ludios/bitscrub

This is one that does it with CRC32, which may or may not be sufficient for detecting bitrot. It is probably trivial to modify to support a stronger hash.

Re:What’s New in Apple Filesystems [pdf] by tobias3 on Tuesday June 11, 2019 @02:21PM (#20158071)
For internal storage Apple has control over the hardware. They can just choose hardware with better internal error correction/detection, so block level checksumming on the software side doesn't make much sense in this case. For external storage it would be nice, though.
Re:What’s New in Apple Filesystems [pdf] by rhinoceraptor on Tuesday June 11, 2019 @02:52PM (#20158376)
You can't know how many uncorrectable errors you have if you're not check summing. You can't see because there are no lights. And IMO it's just negligent to believe your flash memory is 100% perfect.
Re:What’s New in Apple Filesystems [pdf] by bayindirh on Tuesday June 11, 2019 @03:27PM (#20158708)
However the flash memory knows the checksum on the hardware level, and running its own internal checks for data integrity.

Flash controllers reserve a certain amount of blocks for CRC and check summing, so flash is much more intelligent and knowledgeable than it seems.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Tuesday June 11, 2019 @03:55PM (#20158954)
> * However the flash memory knows the checksum on the hardware level, and running its own internal checks for data integrity.*

Assuming that the flash controller has no bugs and doesn't fetch the wrong sector/LBA.

The OS asks for LBA X, but instead Y is fetched, and the sum(Y) passes so the data is sent back as "OK". If you don't have checksums at a layer above the hardware, how do you know if the right sector was sent to you? (I've seen reports of ZFS catching errors like this.)

Re:What’s New in Apple Filesystems [pdf] by bayindirh on Tuesday June 11, 2019 @04:37PM (#20159288)
Yes, that's a possibility. Flash level checksum only guarantees that the written or read LBA is intact.

However, I've never seen an enterprise storage system to do a mistake like that. My archaic OCZ Vectors or Mac SSDs also didn't do something similar. The problem you mention is as sinister as bit-rot.

It's always nice that the FS is self aware about its integrity, however it may be overkill for consumer class devices and installations. Maybe making the flash controller and the storage itself more reliable should be better in the long run for these type of devices IMHO.

Re:What’s New in Apple Filesystems [pdf] by monocasa on Tuesday June 11, 2019 @05:37PM (#20159755)
Flash level checksums also generally cover the flash translation layer (ie. the mapping of physical to logical sectors).

It's probably not needed for a vertically integrated stack of APFS on a Apple SSD controller.

It'd be nice to have fir external drives though.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Wednesday June 12, 2019 @10:45AM (#20165162)
> It's probably not needed for a vertically integrated stack of APFS on a Apple SSD controller.

Apple code has no bugs that could send back bad data? Apple has access to hardware that does not experience bit rot? Apple's gear is not susceptible to firmware hacking?

* https://www.wired.com/2015/02/nsa-firmware-hacking/

The various old school SAN vendors have all sorts of control for storage controllers and disk firmware, and I've seen ZFS checksum errors appear on scrubs with them.

Re:What’s New in Apple Filesystems [pdf] by monocasa on Wednesday June 12, 2019 @11:11AM (#20165402)
> Apple code has no bugs that could send back bad data? Apple has access to hardware that does not experience bit rot? Apple's gear is not susceptible to firmware hacking?

'It' being checksums over data that they already know is checksummed by the F2L layer and they know the semantics of.

If you're hacking the firmware, you know that APFS is running on top of it, so you would just fix-up it's checksums too. APFS having checksums doesn't get you anything there either.

> The various old school SAN vendors have all sorts of control for storage controllers and disk firmware, and I've seen ZFS checksum errors appear on scrubs with them.

You have next to zero introspection into how those drives actually work, or where the semantics of their F2L breaks down the easiest (they hide all of that out of patent concerns). For instance do those drives work around a write ahead log primarily, or is it a more traditional block renaming tree? How many generations are there? All the BS counters in the world are next to meaningless without some base implementation knowledge that's missing.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Wednesday June 12, 2019 @11:36AM (#20165710)
Say you have a bug that corrupts data which somehow happens after writes so filesystem level checksums can detect it and you run that filesystem on desktop/laptop/mobile without redundancy. Does it actually help you with anything since you can't correct that error on the same filesystem level? Of course not. Does it at least prevent inconsistency? No, it doesn't unless failed checksums stop filesystem from doing new reads and writes. So the only sensible place for checksumming is on the level where such errors can be automatically corrected. Without redundancy that's just your disk controller or applications designed with data recovery in mind that also can do checksumming, not filesystems though.
Re:What’s New in Apple Filesystems [pdf] by bayindirh on Wednesday June 12, 2019 @07:36PM (#20170451)
Data doesn't fly from CPU to disk. It has to pass the RAM, storage controller, some caches most of the time and then it reaches to the medium that stores the data.

Data can be corrupted in anywhere in this chain. Checksum or block can end up in a bad memory cell, your storage controller can bit-flip or the universe can corrupt your data on the bus. Larger storage systems also add more connections, controllers, caches and disks. So the probability increases. This is why your flash, RAID controller, transmission protocols, HDDs, RAM and everything in between have error correction capabilities in enterprise systems. However consumer systems lack some of these.

Also, not all data ends up in a cutting edge SSD. HDDs are still present and being produced. While HDDs also have some block level error correction, they are susceptible to bit rot.

At the end of the day, FS level checksumming is desirable but, it costs space and computation. Instead of reducing the runtime and performance of the computer, consumer devices rely on the recovery mechanisms of the hardware and prevent most of the problems most of the times with good-enough resiliency and reliability.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Wednesday June 12, 2019 @08:21PM (#20170730)
> Data can be corrupted in anywhere in this chain.

Of course, but most of this kind of corruption is trivial to recover from with just retries, that's why checksumming there works, but not on the filesystem level, where it can only detect corruption. What makes a bit more sense is something like erasure coding. Filesystem with erasure coding would probably be useful for all the broken FTLs on SD cards, eMMCs, SSDs, but at the end of the day wouldn't provide any significant level of resilience for a single disk to be worth the effort and the overhead. And checksumming alone still won't be useful.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @09:15AM (#20174499)
> Of course, but most of this kind of corruption is trivial to recover from with just retries, that's why checksumming there works, but not on the filesystem level, where it can only detect corruption.

FS-level checksum saves you from the situation when the underlying storage thinks everything is okay but it is not:

> This means there was a data error on the drive. But it’s worse than a typical data error — this is an error that was not detected by the hardware.

* http://changelog.complete.org/archives/9769-silent-data-corr...

* https://research.cs.wisc.edu/wind/Publications/zfs-corruptio...

* https://news.ycombinator.com/item?id=13851349 (via)

It's not an either-or situation, but rather both-and hardware- and FS-level checks.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @09:29AM (#20174625)
> FS-level checksum saves you from the situation when the underlying storage thinks everything is okay but it is not:

It doesn't save you from anything, it just turns bit flips into full blocks of data loss and introduces overhead. If your application can deal with data loss it can deal with bit flips too. Filesystem-level checksumming is still useless.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @09:48AM (#20174785)
It tells you that your data is corrupted, which gives you options on dealing with the situation.

> If your application can deal with data loss it can deal with bit flips too.

No, it may not. The file may mostly be okay except for a place where a single bit flip causes the value to go from positive to negative:

* https://en.wikipedia.org/wiki/Signed_number_representations

Hardware not-handling bit flips is a documented phenomenon per my citations above. It does cause issues further up the stack. FS-level checksumming gives people the option to at least detect these errors, and depending on the situation, also perhaps fix them.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @10:03AM (#20174939)
People already have a much better option by doing checksumming if necessary on the application level, much closer to the source of data actually with even less possibilities to miss corruption.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @10:19AM (#20175104)
Yes, doing it at the application level would be better. But doesn't preclude it doing it at other layers as well.

It's why we have Ethernet checksums, IP checksums, TCP/UDP checksums, etc. Defense in depth.

Re:What’s New in Apple Filesystems [pdf] by monocasa on Thursday June 13, 2019 @02:48PM (#20177580)
We don't have IP checksums, and only have TCP and UDP checksums because it's optional on Ethernet, and TCP/UDP doesn't always run over Ethernet anyway.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Friday June 14, 2019 @08:12AM (#20182307)
Re:What’s New in Apple Filesystems [pdf] by vardump on Thursday June 13, 2019 @02:15AM (#20172240)
> Of course, but most of this kind of corruption is trivial to recover from with just retries...

Retries won't help you when the data was corrupted on its way to be stored.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @09:15AM (#20174496)
> Retries won't help you when the data was corrupted on its way to be stored.

Why not? This is exactly how such corruption is traditionally fixed. On crc error data is rejected before it is stored and retry then fixes the problem. And it's not that big of a deal either, only applications can get data checksummed in the earliest possible moment anyway. The hard part is automatically recovering from data loss and corruption later, which also makes it even unnecessary to verify if data is stored without corruption.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @09:23AM (#20174565)
> > Retries won't help you when the data was corrupted on its way to be stored.

> Why not?

1. Data is fine in memory

2. Data is fine over PCIe.

3. Data is corrupted by firmware bug in storage controller.

4. Data (now corrupted) is sent to disk, which generates checksums for each LBA, and sends the bits to the storage medium.

5. Some time later the data is requested, disk reads bits from sectors, checksums pass, corrupted data is sent back up the stack to the application.

This is not a fantasy scenario:

* http://www.cs.toronto.edu/~bianca/papers/fast08.pdf

* https://storagemojo.com/2007/09/19/cerns-data-corruption-res...

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @09:42AM (#20174733)
You are missing the point: checksums can't save you from data corruption and data loss. They are unnecessary without automatic recovery mechanisms and even make things worse.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @09:59AM (#20174898)
> You are missing the point: checksums can't save you from data corruption and data loss.

No, I am not. The point is: checksums allow you to know that data corruption happened in the first place. Knowing this, you can then make informed decisions.

What saves you from "data corruption and data loss" is backups. But how do you know you have to go to backups if you're not aware that your data has problems?

> They are unnecessary without automatic recovery mechanisms and even make things worse.

Checksums allow you do know that there is a problem in the first place. If you don't know there's a problem, how can you invoke "recovery mechanisms", automatic or otherwise?

If you use (say) ZFS with some level of RAID-Z over multiple disks, then you get an "automatic recover mechanism". But even for a single-disk situation, it would be handy (for me at least), to know a file is bad so I can restore it from (say) my Time Machine backup.

But I have to know that the file is corrupted in the first place. And checksums would give me that.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @10:19AM (#20175099)
> What saves you from "data corruption and data loss" is backups. But how do you know you have to go to backups if you're not aware that your data has problems?

It doesn't actually. It introduces inconsistencies unless on first detected corruption your filesystem stops all reads and writes until you recover corrupted block from backup and you might not even have it in backup, because backup is not synchronous replication.

> Checksums allow you do know that there is a problem in the first place. If you don't know there's a problem, how can you invoke "recovery mechanisms", automatic or otherwise?

You do your own appropriate checksumming suitable for recovery mechanism that you have. It's hardly as primitive as you think, because you have to respond fast, without corruption, transparently on request, you also have to schedule a check whether you actually need to heal anything, maybe it was a transient error, then mark it as corrupted, find what to resync from where, all of which also has to be fast, which means a bit complicated algorithms with sort of checksum databases on each replica, etc.

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @10:25AM (#20175153)
What do you do as a living? Because I think we are living in different realities.

I, as a sysadmin, have been helped by (ZFS) checksums multiple times. This includes times where I had to go to tape manually because the really expensive SAN has said "everything is fine" when it wasn't.

So telling me "checksums do not help" is contrary to my life experience.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @10:31AM (#20175212)
I mostly speak from experience designing, implementing and operating a distributed database/storage system and traditional storages, databases before that.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @10:39AM (#20175301)
And you've never seen the storage stack give back bad data?

You seem to be saying "checksums don't matter because there may be nothing we can do about about the corrupted data". So we should just blindly accept all the bits from the lower levels of the stack? We should do nothing to verify that those levels of the stack are working correctly?

You've mentioned application-level checksumming: yes, that would be good. But until every single dev adds code to checksum (and correct?) their data structures and file formats, having more checksums allows for beter information about when corruption occurs IMHO.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Thursday June 13, 2019 @11:00AM (#20175524)
My point is checksumming is not a solution for data corruption, never was, never will be. It's only a tiny part of more complex algorithms and systems that detect and fix corrupted data automatically, never something usable on its own.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @11:44AM (#20175960)
Checksumming is necessary, but not sufficient, for proper data integrity. But if you don't have it, you can't do anything else.

So why does it seem you are agruing against checksums?

Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @09:06AM (#20174407)
> Does it actually help you with anything since you can't correct that error on the same filesystem level? Of course not.

Given that I run Time Machine, yes it does: it tells me I have to restore the file from a backup.

I also use SuperDuper to create bootable clones on a rotating set of drives that I take to work for offsite backup, so the file would probably be there as well. (Though this is a bit extreme for a non-geek to do.)

Re:What’s New in Apple Filesystems [pdf] by bayindirh on Wednesday June 12, 2019 @02:04AM (#20162135)
Flash level checksums are an integral part of wear-leveling and flash block allocation strategy. So they are also used for block migration/retirement controls. In other words, it's not trivial or desirable to remove flash level ECC or other checksums from physical flash management layer.

I cannot find the article now, but the flash storage is way less reliable than it seems and it's correcting bit errors silently without reporting most of the time.

This article [0] shows some of the things behind the curtain in flash storage configuration and lifetime. I'd edit or add the other article if I can find it.

[0]: https://goughlui.com/2015/04/05/teardown-optimization-comsol...

Re:What’s New in Apple Filesystems [pdf] by monocasa on Wednesday June 12, 2019 @11:00AM (#20165309)
I'm saying that flash level checksums on a vertically integrated stack make checksumming again at the FS layer moot, assuming you have proper control and reporting on both sides of the block device abstraction boundary. Apple's about the only one who can pull this off with their vertically integrated stack.
Re:What’s New in Apple Filesystems [pdf] by bayindirh on Wednesday June 12, 2019 @07:23PM (#20170372)
> ...flash level checksums on a vertically integrated stack make checksumming again at the FS layer moot...

This is simply not true. First, flash is not always the place data ends at. Flash is prevalent in more points in the storage chain. Predominantly on RAID controllers' caches in last 3-5 years and hybrid drives used in laptops. So, flash-level checksumming can guarantee that the data is retrieved in the form it's written and allows neat tricks like wear-leveling and such. On the other hand data can get corrupted in other places.

e.g. Data can get corrupted in RAM, bit-rot in hard drives, RAID controllers can add a thick layer of complexity which you cannot manage or the filesystem can just make mistakes due to bugs (I've seen it all). So flash-level checksum can protect the data on the flash, but cannot guarantee that the data is correct in the first place. So if you checksummed the data and wrote it differently, FS or RAID level checksumming will catch it. This will prevent domino effects which the corrupted data can create.

Data management gets complicated fast when you need more than a few disk's aggregate capacity with high performance and reliability and, FS level checksumming is a powerful tool to ensure that.

> ...assuming you have proper control and reporting on both sides of the block device abstraction boundary.

Again this will only guarantee that the device reads the data it has written, but it won't guarantee that it had received the correct data in the first place.

> Apple's about the only one who can pull this off with their vertically integrated stack.

While Apple can do a lot of exotic stuff with the hardware, it won't be wise to create a custom flash controller and protocol to fuse FS and flash level checksums. It'll increase the software and integration cost, limit their options in hardware scene, slow down product development and plainly limit them in the long run.

I had an Intel 4 channel RAID card which corrupted the array when it wakes up from the wrong side of the bed and, it spent hours to verify and rebuild the array from the block level checksums it created on the disks during array creation. I've never lost data, but decided that it didn't worth the effort to keep the array alive and well. So, I eventually ditched it. However its activity LEDs on the board was kinda nice.

Re:What’s New in Apple Filesystems [pdf] by monocasa on Thursday June 13, 2019 @02:35PM (#20177469)
> While Apple can do a lot of exotic stuff with the hardware, it won't be wise to create a custom flash controller and protocol to fuse FS and flash level checksums. It'll increase the software and integration cost, limit their options in hardware scene, slow down product development and plainly limit them in the long run.

I mean, tell that to them, because that's what they've done. The T2 chip's feature set is very married to APFS. AFAIK, Linux still doesn't have working drivers for it despite it sort of looking like an NVMe drive.

Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Wednesday June 12, 2019 @11:38AM (#20165741)
Anyone can pull this off, because filesystem level checksumming without an additional place to recover data from is useless.
Re:What’s New in Apple Filesystems [pdf] by bayindirh on Wednesday June 12, 2019 @07:38PM (#20170468)
Exchange the checksumming with hamming codes or with another ECC system with >=2 bit detection/correction capability and you're all set.
Re:What’s New in Apple Filesystems [pdf] by zzzcpan on Wednesday June 12, 2019 @08:29PM (#20170782)
Not really set, but even assuming you can make it work this is already way beyond checksumming the lack of which people complain about for some reason.
Re:What’s New in Apple Filesystems [pdf] by bayindirh on Thursday June 13, 2019 @07:02AM (#20173551)
Most of the big storage vendors are making it work with Erasure or Hamming Codes. They compensate damaged or missing disks in the arrays transparently and send you a small e-mail about the details of the disk you need to change.

RAID-5 and RAID-6 is the most primitive and probably most deployed version of this checksum based compensation and recovery methods.

Erasure/Hamming is used for bigger arrays where RAID-5/6 cannot build the disks in a reasonable amount time while they are under I/O load.

Re:What’s New in Apple Filesystems [pdf] by monocasa on Thursday June 13, 2019 @02:36PM (#20177481)
Pretty much every NAND flash device out there uses full ECC rather than just a checksum. The whole industry relies on it for yield reasons.
Re:What’s New in Apple Filesystems [pdf] by throw0101a on Thursday June 13, 2019 @10:10AM (#20175007)
> However, I've never seen an enterprise storage system to do a mistake like that.

Unless you're using a checksumming file system (a la ZFS), how would you know? And even if you were using ZFS, it would probably just do a re-read from another part of the mirror/RAID-Z and fix it behind the scenes.

That's the issue with people saying "things are fine": how do they actually know since we're not verifying things?

Up until fairly recently, we haven't really been looking too closely, simply trusting the lower levels of the stack:

* http://www.cs.toronto.edu/~bianca/papers/fast08.pdf

Re:What’s New in Apple Filesystems [pdf] by monocasa on Tuesday June 11, 2019 @03:17PM (#20158599)
Their flash translation layer has block level checksums. Most of the time that's not enough, because the SSD vendor doesn't give you a lot of introspection into their failures or how their F2L works. But this is something you gain from vertical integration like Apple's.
Re:What’s New in Apple Filesystems [pdf] by dwaite on Tuesday June 11, 2019 @03:03PM (#20158474)
I thought the storage itself had the integrity check.
Re:What’s New in Apple Filesystems [pdf] by rhinoceraptor on Tuesday June 11, 2019 @04:24PM (#20159201)
I'm sure it has some special Apple magic, but I really think the hardware-only approach isn't the path forward. Hardware faults happen, and papering over that fact with un-debuggable, un-observable firmware is not a good choice.
Re:What’s New in Apple Filesystems [pdf] by eclipxe on Tuesday June 11, 2019 @01:30PM (#20157552)
iOS on iPhone also supports external USB media and SMB.
Re:What’s New in Apple Filesystems [pdf] by pwinnski on Tuesday June 11, 2019 @02:05PM (#20157914)
I was surprised to see this. From the original keynote, it seemed like an iPadOS-only option, but this video made it clear that it applies to both.
Re:What’s New in Apple Filesystems [pdf] by dwaite on Tuesday June 11, 2019 @03:07PM (#20158510)
There's still a lot of effort to keep subsystems and application code-bases the same - iPad OS I believe is mostly a sign that there may continue to be UX deviation (widgets on home screen, drag and drop between applications, split view multitasking, etc)
Re:What’s New in Apple Filesystems [pdf] by scarface74 on Tuesday June 11, 2019 @05:52PM (#20159858)
Each supported device has always had its own image, so I assume it’s not exactly the same codebase.

The only reason I know this is because the last time I had to upgrade iOS using iTunes - going from iOS 4 to 5, I had three separate devices that required separate downloads for my iPhone 4, iPod Touch, and iPad.

Re:What’s New in Apple Filesystems [pdf] by Angostura on Tuesday June 11, 2019 @04:54PM (#20159452)
And Samba shares, which from my perspective is even more interesting.
Re:What’s New in Apple Filesystems [pdf] by scarface74 on Tuesday June 11, 2019 @05:49PM (#20159829)
Minor correction. Will support USB media in iOS 13.