Created attachment 303733 [details] mdb_copy reproducer 1. Please describe the problem: The mdb_copy operation on btrfs produces a corrupted database. It works just fine on ext4! Requirements: sudo dnf install lmdb ## BTRFS $ tar xf mdb_copy_reproducer.tar.xz $ ./reproducer.sh Current directory: /home/asn/mdb Filesystem information for current directory: Filesystem Type 1024-blocks Used Available Capacity Mounted on /dev/mapper/luks-feea5c33-1033-4e33-a507-4ea83cbaf610 btrfs 248378368 209424480 37336592 85% /home Checksum of samba-dc.ldb: 2307b6aef35ee923c9f9c2f02541ca72760116a39cad62d8455e972cddcabd0a Backup samba-dc.ldb with mdb_copy to samba-dc.ldb.backup LMDB 0.9.29: (March 16, 2021) Checksum of samba-dc.ldb.backup: e9f8ede21831aec0da3897b5880b3008761fb8942d0f4fe086c637319fde4c61 FATAL: The checksums don't match! ## EXT4 $ ./reproducer.sh Current directory: /home/asn/mdb Filesystem information for current directory: Filesystem Type 1024-blocks Used Available Capacity Mounted on /dev/mapper/cr_md1 ext4 1921722432 1752912108 71118376 97% /home Checksum of samba-dc.ldb: 2307b6aef35ee923c9f9c2f02541ca72760116a39cad62d8455e972cddcabd0a Backup samba-dc.ldb with mdb_copy to samba-dc.ldb.backup LMDB 0.9.29: (March 16, 2021) Checksum of samba-dc.ldb.backup: 2307b6aef35ee923c9f9c2f02541ca72760116a39cad62d8455e972cddcabd0a The checksums match 2. What is the Version-Release number of the kernel: Linux krikkit 6.1.9-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Feb 2 00:21:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux 3. Did it work previously? It also fails on Fedora 36: Linux samba-cli01 6.0.5-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 26 15:55:21 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Thanks for providing the minimal reproducer, Andreas. This looks like a regression as a result of the btrfs_direct_write()->fault_in_iov_iter_readable() retry logic added via 51bd9563b6783de8315f38f7baed949e77c42311 .
For anyone landing here, I assume the following is a fix for this issue: https://lore.kernel.org/all/ae81e48b0e954bae1c3451c0da1a24ae7146606c.1676684984.git.boris@bur.io/