btrfs-progs: mkfs: Enforce 4k sectorsize by default
Quoted 20 lines · Qu Wenruo
On 2023/3/21 18:07, Hector Martin wrote:
[...]Quoted 7 lines
btrfs/140 is the first one that looks bad. Looks like the corruption correction didn't work for some reason.
... and then btrfs/142 which is similar actually managed to log a bunch of errors on our NVMe controller. Nice.
Quoted 8 lines
[ 1240.000104] nvme-apple 393cc0000.nvme: RTKit: syslog message: host_ans2.c:1564: cmd parsing error for tag 12 fast decode err 0x1 [ 1240.000767] nvme0n1: Read(0x2) @ LBA 322753843, 0 blocks, Invalid Field in Command (sct 0x0 / sc 0x2) [ 1240.000771] nvme-apple 393cc0000.nvme: RTKit: syslog message: host_ans2.c:1469: tag 12, completed with err BAD_CMD- [ 1240.000775] operation not supported error, dev nvme0n1, sector2582030751 op 0x0:(READ) flags
0x80700phys_seg1 prio class 2
Quoted 1 line
Mind to share the reproducibility?
100% as far as I can tell. I'm using 20G devices for everything. It instantly hits that bug.
Good news is it's not a btrfs bug though :)
common/dmdust: DUST_TABLE="0 $DEV_SIZE dust $SCRATCH_DEV 0 512"
The dust device is created with 512 byte sectors, while the NVMe on these machines has 4K sectors. Changing that to 4K and the respective block size calculation in the tests (142/143) (physical / 512 -> physical / 4096) makes it pass. It's not reading 0 bytes, it's reading 512 bytes (which gets truncated to 0 sectors).
And then that explains why 140 doesn't work: it also assumes 512, but in a way that just fails instead of causing kernel explosions. Same with btrfs/265, 266, 267, 269.
So there's two problems here: a bunch of tests assume 512 byte sectors, and the kernel DM dust device is missing a check that should reject creation with an invalid sector size instead of just causing wreckage further down the block device chain.
Quoted 3 lines
Quoted 1 line
213 failed to balance with ENOSPC.
Passed with 5x10G LVs as scratch dev pool.
5x20G GPT partitions here, and I can reliably repro this one. Maybe it's also related to the 4K sectors?
Quoted 2 lines
I hope it's not Apple Silicon too fast to trigger it, or it would be pretty hard to reproduce...
FWIW, there's also the whole thing where Apple Silicon is *really* good at triggering memory ordering and concurrency problems, since it is such a wide architecture. I found a bug in the core kernel workqueue code that had been there for years on ARM64...
Quoted 4 lines
Quoted 2 lines
generic/251 then failed too, with dmesg logs about failing to trim block groups.
It takes much longer time but still passed here.
Reliably fails here, and this is another 4K sector one and actually a btrfs bug I think. It tries to do discards that are not 4K-aligned. Here's the call trace leading to the bad discard attempt:
[ 70.571872] btrfs_issue_discard+0x224/0x260 [ 70.571874] btrfs_discard_extent+0x128/0x1dc [ 70.571876] do_trimming+0xc4/0x220 [ 70.571878] trim_no_bitmap+0x21c/0x3f0 [ 70.571879] btrfs_trim_block_group+0x88/0x170 [ 70.571880] btrfs_trim_fs+0xf0/0x3a0 [ 70.571882] btrfs_ioctl_fitrim+0x100/0x1dc [ 70.571885] btrfs_ioctl+0x1550/0x25bc [ 70.571887] __arm64_sys_ioctl+0x464/0xbb0 [ 70.571891] invoke_syscall.constprop.0+0x78/0xd0 [ 70.571894] do_el0_svc+0x58/0x170 [ 70.571896] el0_svc+0x38/0xf0 [ 70.571900] el0t_64_sync_handler+0xf4/0x120 [ 70.571902] el0t_64_sync+0x190/0x194
Note that discard size is actually a *separate* device property from sector size, so this is doubly wrong. btrfs probably needs to explicitly align to the discard size.
Quoted 2 lines
I'll try my best to got some runs on real Apple machines meanwhile, but don't expect any improvement on my hardware situation any time soon...
Hope you can repro with the 4K sector hint. Last time I had emulate that I used a loop device with 4K sectors, but I don't know if that supports discard... not sure if there is a better way.
Quoted 22 lines
Thanks,
QuQuoted 17 lines
generic/520 failed with an EBUSY on umount, but I suspect this might be some desktop/systemd stuff trying to use the mount?
generic/563 suggests there may be cgroup accounting issues
generic/619 seems known to be pathologically slow on arm64, so I killed it (https://www.spinics.net/lists/linux-btrfs/msg131553.html).
generic/708 failed but that pointed to a known kernel bug that we don't have the fix for yet (this is running on 6.2 + asahi patches).
Run output and some select dmesg sections:
https://gist.github.com/marcan/822a34266bcaf4f4cffaa6a198b4c616Let me know if you need anything else.
- Hector