APFS Errors: fsck can't repair TL;DR

Asked the same question on Apple communities, nothing useful.
Find the post here: https://discussions.apple.com/thread/8123614

bash-3.2# fsck_apfs -d -l /dev/disk5
fletcher64_init:58: Selecting AVX2 implementation of fletcher64
** Checking volume.
** Checking the container superblock.
** Checking the EFI jumpstart record.
** Checking the space manager.
** Checking the object map.
** Checking the APFS volume superblock.
warning: apfs_sb at apfs_fs_index (0): apfs_features has unrecognized features (2)
** Checking the object map.
** Checking the fsroot tree.
error: btn: key (2) compare error: 22
   fsroot tree is invalid.
** The volume /dev/disk5 could not be verified completely.


Hardware iMac (27-inch, Late 2013), 256GB stock SSD, nothing special, nothing fancy. 

Standard issue hardware and I am certain that this hardware is flawless- since I run Linux/Freebsd on it. 

Drive is a default single partitioned GPT for fresh install of High Sierra. I simply erased the whole drive, set a new GPT scheme, formatted it as HFS+ and started the installer from USB. This went ok, but after a few days I checked the Volume after power outage and found that I can't repair it anymore... 

Disk Utility.app says the same what fsck does. Disk Utility is basically executing fsck in the background anyways, if you think it's not then start Disk Utility directly through Terminal and you will see it in stdout.

I couldn't find any useful documentation, just some marketing flavoured mambo-jumbo without any technical depth.

I installed the 10.13.1 Public Beta release with hopes that maybe it will recognize the unrecognized features, now it says more or less the same and still can't repair the volume - although it does not complain about unrecognized features.

I read somewhere that APFS is close related to ZFS, so maybe one can work with ZFS tools or other software that explicitly is designed to repair APFS similar to a back story here: http://dtrace.org/blogs/ahl/2016/06/15/apple_and_zfs/

Sub-topics


Is there a way to opt-out of APFS on SSD? 
Is there a way to convert back to HFS+


During installation the installer didn't asked about conversion (or maybe I missed it) and now im stuck with a drive I can't use.



Update II:
After reading a bit about ZFS and then references from Wikipedia entry about APFS (correct me if I am wrong) APFS implementation should take care off any faults on it's own, and, theoretically there is no need for a fsck command. Well, thinking of it, I never had to fsck a BTRFS volume either, if there were some issues there were scrubbed at boot time, guess this is how APFS is supposed to work as well - since fault tolerance is one of it's core features.

More technical details by reverse engineering APFS are here 

Update III (07.01.2018)

After some weeks of APFs testing on native Apple and non-Apple hardware by doing a lot of common and some not so-common testing - I recommend to stay away from it until the Linux kernel is able to mount an APFS volume in R/W mode. From my experience one can expect to have a really bad day if your APFS based storage crashes for some reason and won't be able to self-heal. In most cases it does the job and can repair itself - however in 8 weeks I landed in more then 5 cases where it couldn't- despite no hardware failure. I was not able to repair/reuse the volume without reformatting therefore I'm not using APFS until it's well documented and mountable in Linux in R/W mode for anything else then system files.

SSD vs. non-SSD
If you are running APFS on non-SSD: it will be slower then HFS. Period.
APFS is (currently) only reasonable on internal SSD drives and on can be on  hybrid drives (although Apple installer won't agree). Magnetic hard drives don't benefit from APFS in any way. External SSD drive performance is not really comparable since the amount data you can squeeze through USB-C is limited and HFS+ wont't be a bottleneck.
Same advice as the Apple forums. Backup and reformat your system.

Apple has not released an APFS specification or code yet. As you have found, only very rough reverse engineering has been done. Trying to interpret what key 2 miscompare in the fsroot tree is pure speculation at this point.

There is no way to convert back to HFS+. There is an unofficial way to opt out though.

There is no need for a fsck command means that the FS will try to fix anything wrong on-the-fly, online. No filesystem can be immune from all potential damage or implementation bugs. If something can't be fixed by fsck offline, then there really is no chance to have it fixed online.

However, one potential scenario is a bug with fsck and not the system code, but again that's pure speculation without being able to understand what's wrong. It's your choice, but a reformat is the safest point.