maharmstone / ntfs2btrfs

GNU General Public License v2.0
658 stars 29 forks source link

Bad filesystem state after converting two separate NTFS partitions to BTRFS #23

Closed urbenlegend closed 2 years ago

urbenlegend commented 3 years ago

I've converted two NTFS partitions now using this tool and both filesystems have had issues that would cause it to drop down into read only mode. Scrub seems to work okay, indicating that the data is at least not corrupted, but attempting to remove image/ntfs.img or doing a defrag will cause the mount to switch into read-only mode.

Below is what I got in my system logs after I finished converting a 2TB Western Digital My Passport external USB disk and then attempted to delete the image subvolume.

Steps to reproduce

  1. ntfs2btrfs /dev/sdf1
  2. mount -o compress-force=zstd:2 /dev/sdf1 "/mnt/My Passport"
  3. btrfs subvolume delete "/mnt/My Passport/image"
Jun 16 16:41:52 username kernel: BTRFS: Transaction aborted (error -75)
Jun 16 16:41:52 username kernel: WARNING: CPU: 6 PID: 45545 at fs/btrfs/file-item.c:908 btrfs_del_csums+0x3b8/0x410 [btrfs]
Jun 16 16:41:52 username kernel: Modules linked in: nvidia_uvm(POE) ses enclosure scsi_transport_sas uinput wireguard curve25519_x86_64 libchacha20poly1305 chacha_x86_64 poly1305_x86_64 libblake2s blake2s_x86_64 libcurve25519_generic libchacha libblake2s_generic ip6_udp_tunnel udp_tunnel nft_masq snd_seq_dummy snd_hrtimer snd_seq nft_objref nf_conntrack_netbios_ns nf_conntrack_broadcast ccm rfcomm nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables nfnetlink uvcvideo hid_logitech_hidpp videobuf2_vmalloc videobuf2_memops nvidia_drm(POE) videobuf2_v4l2 nvidia_modeset(POE) videobuf2_common snd_usb_audio videodev snd_usbmidi_lib uas snd_rawmidi snd_seq_device usb_storage mc nvidia(POE) cmac algif_hash algif_skcipher af_alg bnep joydev iwlmvm snd_hda_codec_realtek intel_rapl_msr mousedev snd_hda_codec_generic hid_logitech_dj intel_rapl_common mac80211 snd_hda_codec_hdmi ledtrig_audio snd_hda_intel vfat libarc4
Jun 16 16:41:52 username kernel:  edac_mce_amd kvm_amd ccp rng_core iwlwifi btusb snd_intel_dspcfg fat btrtl snd_intel_sdw_acpi drm_kms_helper kvm btbcm snd_hda_codec cfg80211 btintel snd_hda_core cec bluetooth snd_hwdep usbhid igb snd_pcm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel aesni_intel wmi_bmof snd_timer mxm_wmi syscopyarea snd sysfillrect crypto_simd i2c_algo_bit ecdh_generic cryptd sp5100_tco ecc sysimgblt rapl pcspkr fb_sys_fops rfkill crc16 soundcore dca k10temp i2c_piix4 wmi pinctrl_amd mac_hid acpi_cpufreq drm fuse crypto_user agpgart bpf_preload ip_tables x_tables btrfs blake2b_generic libcrc32c crc32c_generic xor raid6_pq xhci_pci crc32c_intel xhci_pci_renesas
Jun 16 16:41:52 username kernel: CPU: 6 PID: 45545 Comm: btrfs-transacti Tainted: P           OE     5.12.10-arch1-1 #1
Jun 16 16:41:52 username kernel: Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./X570 Taichi, BIOS P4.30 04/14/2021
Jun 16 16:41:52 username kernel: RIP: 0010:btrfs_del_csums+0x3b8/0x410 [btrfs]
Jun 16 16:41:52 username kernel: Code: 8d 93 48 0a 00 00 f0 48 0f ba 2a 03 72 22 83 f8 fb 74 45 83 f8 e2 74 40 89 c6 48 c7 c7 c0 a1 55 c0 89 44 24 04 e8 15 dc 99 d2 <0f> 0b 8b 44 24 04 89 c1 ba 8c 03 00 00 4c 89 e7 89 44 24 04 48 c7
Jun 16 16:41:52 username kernel: RSP: 0018:ffffa0bbd4467b30 EFLAGS: 00010286
Jun 16 16:41:52 username kernel: RAX: 0000000000000000 RBX: ffff921a9bad6000 RCX: 0000000000000027
Jun 16 16:41:52 username kernel: RDX: ffff92209eb986e8 RSI: 0000000000000001 RDI: ffff92209eb986e0
Jun 16 16:41:52 username kernel: RBP: ffff921e54830e00 R08: 0000000000000000 R09: ffffa0bbd4467960
Jun 16 16:41:52 username kernel: R10: ffffa0bbd4467958 R11: ffff9220bf2a94a8 R12: ffff921991e300d0
Jun 16 16:41:52 username kernel: R13: ffff921b840f5800 R14: ffff921c4821eb00 R15: 0000000001336000
Jun 16 16:41:52 username kernel: FS:  0000000000000000(0000) GS:ffff92209eb80000(0000) knlGS:0000000000000000
Jun 16 16:41:52 username kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Jun 16 16:41:52 username kernel: CR2: 00000000e706b000 CR3: 0000000252c0e000 CR4: 0000000000350ee0
Jun 16 16:41:52 username kernel: Call Trace:
Jun 16 16:41:52 username kernel:  __btrfs_free_extent+0x4e4/0x940 [btrfs]
Jun 16 16:41:52 username kernel:  __btrfs_run_delayed_refs+0x24f/0xfe0 [btrfs]
Jun 16 16:41:52 username kernel:  ? update_load_avg+0x7e/0x620
Jun 16 16:41:52 username kernel:  ? cpuacct_charge+0x32/0x80
Jun 16 16:41:52 username kernel:  btrfs_run_delayed_refs+0x73/0x1f0 [btrfs]
Jun 16 16:41:52 username kernel:  btrfs_commit_transaction+0xf6/0xb70 [btrfs]
Jun 16 16:41:52 username kernel:  ? start_transaction+0xce/0x5d0 [btrfs]
Jun 16 16:41:52 username kernel:  transaction_kthread+0x12e/0x1a0 [btrfs]
Jun 16 16:41:52 username kernel:  ? btrfs_cleanup_transaction.isra.0+0x570/0x570 [btrfs]
Jun 16 16:41:52 username kernel:  kthread+0x133/0x150
Jun 16 16:41:52 username kernel:  ? kthread_associate_blkcg+0xc0/0xc0
Jun 16 16:41:52 username kernel:  ret_from_fork+0x22/0x30
Jun 16 16:41:52 username kernel: ---[ end trace b2a10b3577fbf3e6 ]---
Jun 16 16:41:52 username kernel: BTRFS: error (device sdf1) in btrfs_del_csums:908: errno=-75 unknown
Jun 16 16:41:52 username kernel: BTRFS info (device sdf1): forced readonly
Jun 16 16:41:52 username kernel: BTRFS: error (device sdf1) in __btrfs_free_extent:3216: errno=-75 unknown
Jun 16 16:41:52 username kernel: BTRFS: error (device sdf1) in btrfs_run_delayed_refs:2163: errno=-75 unknown

I did the conversion on an up-to-date Arch system using a June 14 build of ntfs2btrfs from the AUR.

Kernel 5.12.10-arch1-1 btrfs-progs 5.12.1

Similar issues occured with a Seagate 4TB SHDD.

jsebean commented 3 years ago

Just wanted to chime in, this was exactly my experience as well. Unfortunately, I nuked the fs and restored a backup, otherwise I'd post the dmesg output too, but just wanted to indicate I had the same experience in just the last few days. Also on Arch with kernel 5.12.

urbenlegend commented 3 years ago

Glad to know I am not the only one. Seems like ntfs2btrfs isn't really reliable right now. I am also thinking about nuking the FS and just formatting it as BTRFS from Linux, but I'll wait a few more days for a dev response in case they need some extra debug info.

TheMadHau5 commented 3 years ago

Same experience as well (issue #16)

axet commented 2 years ago

Yep. I have a lot of issues after converting partition with ntfs2btrfs.

btrfs check (with or without --repair) report no errors.

Trying to use the partition cause a lot of: __btrfs_free_extent or btrfs_del_csums (errno=-75 unknown) errors.

For test I'm using: Path of Exile game client, which trying to update its Content.ggpk

EDIT: I had this 4cc5a323f95a8ae26206ffbbc27843830efa8c6e ntfs2btrfs version

maharmstone commented 2 years ago

Thanks. Errno 75 is EOVERFLOW, which as far as I can tell probably originates in split_leaf in fs/btrfs/ctree.c.

My guess would be that it comes from the FIXME at: https://github.com/maharmstone/ntfs2btrfs/blob/226f55f92fc40b64632a4557f74e20ce29b29e53/src/ntfs2btrfs.cpp#L2668

axet commented 2 years ago

'btrfs_free_extentbtrfs_free_extent' also comes with 'errno=-2 No such entry'

I already drop this bugged partition and recreate it freshly under linux - no issues so far. New tests should be done on clear, freshly converted partition after a fix.

What is worrying me the most - 'btrfs checks' sees no issues with a filesystem, regardless some fundamentals errors persists (based on fact using fs causing a lot of btrfs errors and ro access shortly after a mount) on a filesystem.

btrfs is good, but 'btrfs check' has to be a better utility with deeper analysis.

maharmstone commented 2 years ago

btrfs is good, but 'btrfs check' has to be a better utility with deeper analysis.

I agree - once I figure out what the issue is, I'll submit a patch to them when I get the chance.

maharmstone commented 2 years ago

I managed to reproduce this:

[54163.884602] ------------[ cut here ]------------
[54163.884606] BTRFS: Transaction aborted (error -75)
[54163.884614] WARNING: CPU: 3 PID: 25900 at fs/btrfs/file-item.c:909 btrfs_del_csums+0x38f/0x3a0
[54163.884621] Modules linked in: nvidia_drm(PO) nvidia_modeset(PO) nvidia(PO) drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops hid_steam drm ath9k ath9k_common ath9k_hw backlight ath thermal
[54163.884634] CPU: 3 PID: 25900 Comm: umount Tainted: P           O      5.14.1-gentoo #2
[54163.884637] Hardware name: Gigabyte Technology Co., Ltd. B450 GAMING X/B450 GAMING X, BIOS F50 11/27/2019
[54163.884639] RIP: 0010:btrfs_del_csums+0x38f/0x3a0
[54163.884641] Code: 0f 82 74 76 84 00 83 f8 fb 0f 84 6b 76 84 00 83 f8 e2 0f 84 62 76 84 00 89 c6 48 c7 c7 08 d4 4c 82 89 44 24 04 e8 d6 20 83 00 <0f> 0b 8b 44 24 04 e9 45 76 84 00 e8 a1 19 89 00 90 41 57 41 56 41
[54163.884643] RSP: 0018:ffffc9001037bab8 EFLAGS: 00010286
[54163.884646] RAX: 0000000000000000 RBX: ffff888163844000 RCX: 0000000000000027
[54163.884647] RDX: ffff8887fe8d2ef8 RSI: 0000000000000001 RDI: ffff8887fe8d2ef0
[54163.884649] RBP: ffff88845b3b50e0 R08: ffff88881f3313a8 R09: 00000000ffffdfff
[54163.884650] R10: ffff88881f2513c0 R11: ffff88881f2513c0 R12: ffff888531fbe478
[54163.884651] R13: ffff88857444e800 R14: ffff88813552e100 R15: 00000000321a3000
[54163.884652] FS:  00007f6c9ea55b80(0000) GS:ffff8887fe8c0000(0000) knlGS:0000000000000000
[54163.884654] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[54163.884656] CR2: 00007fe4ff7f6000 CR3: 00000003e4e60000 CR4: 0000000000350ee0
[54163.884657] Call Trace:
[54163.884661]  ? wake_up_q+0x45/0x80
[54163.884665]  __btrfs_free_extent+0x4b2/0x840
[54163.884669]  __btrfs_run_delayed_refs+0x24c/0xf80
[54163.884673]  ? set_extent_buffer_dirty+0x10/0x100
[54163.884676]  btrfs_run_delayed_refs+0x6e/0x1c0
[54163.884679]  btrfs_start_dirty_block_groups+0x27c/0x4c0
[54163.884684]  btrfs_commit_transaction+0x7af/0x9c0
[54163.884686]  ? btrfs_attach_transaction_barrier+0x1a/0x40
[54163.884689]  sync_filesystem+0x6f/0x90
[54163.884693]  generic_shutdown_super+0x1d/0x100
[54163.884697]  kill_anon_super+0x9/0x20
[54163.884699]  btrfs_kill_super+0xd/0x20
[54163.884701]  deactivate_locked_super+0x2c/0x90
[54163.884704]  cleanup_mnt+0x12c/0x180
[54163.884707]  task_work_run+0x57/0x90
[54163.884709]  exit_to_user_mode_prepare+0x120/0x130
[54163.884713]  syscall_exit_to_user_mode+0x1d/0x40
[54163.884718]  do_syscall_64+0x48/0x90
[54163.884720]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[54163.884724] RIP: 0033:0x7f6c9eba3a07
[54163.884726] Code: d4 0b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 01 c3 48 8b 15 31 d4 0b 00 f7 d8 64 89 02 b8
[54163.884728] RSP: 002b:00007fffdfe10aa8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
[54163.884730] RAX: 0000000000000000 RBX: 00007f6c9ecc5f84 RCX: 00007f6c9eba3a07
[54163.884731] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000055bd3beb3670
[54163.884733] RBP: 000055bd3beb3440 R08: 0000000000000000 R09: 00007fffdfe0f800
[54163.884734] R10: 00007f6c9eab7e10 R11: 0000000000000246 R12: 000055bd3beb3550
[54163.884735] R13: 000055bd3beb3670 R14: 0000000000000000 R15: 0000000000000000
[54163.884737] ---[ end trace e564ddc2fae87816 ]---
[54163.884739] BTRFS: error (device nbd0p1) in btrfs_del_csums:909: errno=-75 unknown
[54163.884742] BTRFS info (device nbd0p1): forced readonly
[54163.884744] BTRFS: error (device nbd0p1) in __btrfs_free_extent:3188: errno=-75 unknown
[54163.884746] BTRFS: error (device nbd0p1) in btrfs_run_delayed_refs:2150: errno=-75 unknown
[54163.884745] BTRFS: error (device nbd0p1) in btrfs_del_csums:909: errno=-75 unknown
[54163.884750] BTRFS: error (device nbd0p1) in __btrfs_free_extent:3188: errno=-75 unknown
[54163.884752] BTRFS: error (device nbd0p1) in btrfs_run_delayed_refs:2150: errno=-75 unknown

This happened consistently when I did btrfs subvolume delete image on Linux 5.14.1, but on 5.8.0 it worked fine. I'll continue to investigate, but there's a possibility it's a bug in Linux rather than ntfs2btrfs.

axet commented 2 years ago

You are right. I did remove subvolume. My kernel is 5.10.0-8-amd64

maharmstone commented 2 years ago

This is fixed as of the latest master.