Bug 217042 - mdb_copy produces a corrupted database on btrfs
Summary: mdb_copy produces a corrupted database on btrfs
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: BTRFS virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-15 08:41 UTC by Andreas Schneider
Modified: 2023-02-18 07:25 UTC (History)
4 users (show)

See Also:
Kernel Version: 6.1.9-200.fc37.x86_64
Subsystem:
Regression: No
Bisected commit-id:


Attachments
mdb_copy reproducer (106.95 KB, application/x-xz)
2023-02-15 08:41 UTC, Andreas Schneider
Details

Description Andreas Schneider 2023-02-15 08:41:41 UTC
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
Comment 1 David Disseldorp 2023-02-15 23:23:07 UTC
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 .
Comment 2 The Linux kernel's regression tracker (Thorsten Leemhuis) 2023-02-18 07:25:37 UTC
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/

Note You need to log in before you can comment on or make changes to this bug.