btrfs-progs/cmds
Qu Wenruo 60651ad9da btrfs-progs: introduce OPEN_CTREE_ALLOW_TRANSID_MISMATCH flag
[BUG]
There is a report that, btrfstune can even work while the fs has transid
mismatch problems.

  $ btrfstune -f -u /dev/sdb1
  Current fsid: b2b5ae8d-4c49-45f0-b42e-46fe7dcfcb07
  New fsid: b2b5ae8d-4c49-45f0-b42e-46fe7dcfcb07
  Set superblock flag CHANGING_FSID
  Change fsid in extents
  parent transid verify failed on 792854528 wanted 20103 found 20091
  parent transid verify failed on 792854528 wanted 20103 found 20091
  parent transid verify failed on 792854528 wanted 20103 found 20091
  Ignoring transid failure
  parent transid verify failed on 792870912 wanted 20103 found 20091
  parent transid verify failed on 792870912 wanted 20103 found 20091
  parent transid verify failed on 792870912 wanted 20103 found 20091
  Ignoring transid failure
  parent transid verify failed on 792887296 wanted 20103 found 20091
  parent transid verify failed on 792887296 wanted 20103 found 20091
  parent transid verify failed on 792887296 wanted 20103 found 20091
  Ignoring transid failure
  ERROR: child eb corrupted: parent bytenr=38010880 item=69 parent level=1 child level=1
  ERROR: failed to change UUID of metadata: -5
  ERROR: btrfstune failed

This leaves a corrupted fs even more corrupted, and due to the extra
CHANGING_FSID flag, btrfs check will not even try to run on it:

  Opening filesystem to check...
  ERROR: Filesystem UUID change in progress
  ERROR: cannot open file system

[CAUSE]
Unlike kernel, btrfs-progs has a less strict check on transid mismatch.

In read_tree_block() we will fall back to use the tree block even its
transid mismatch if we can't find any better copy.

However not all commands in btrfs-progs needs this feature, only
btrfs-check (which may fix the problem) and btrfs-restore (it just tries
to ignore any problems) really utilize this feature.

[FIX]
Introduce a new open ctree flag, OPEN_CTREE_ALLOW_TRANSID_MISMATCH, to
be explicit about whether we really want to ignore transid error.

Currently only btrfs-check and btrfs-restore will utilize this new flag.

Also add btrfs-image to allow opening such fs with transid error.

Link: https://www.reddit.com/r/btrfs/comments/pivpqk/failure_during_btrfstune_u/
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-09-20 12:17:29 +02:00
..
balance.c btrfs-progs: factor out profile parsing to common utils 2021-09-07 13:58:44 +02:00
commands.h btrfs-progs: remove stale command declarations 2021-08-20 14:24:55 +02:00
device.c btrfs-progs: device remove: add support for cancel 2021-05-20 22:14:18 +02:00
filesystem-du.c
filesystem-usage.c btrfs-progs: add and use bit masks for RAID1 and RAID56 profiles 2021-09-06 16:36:18 +02:00
filesystem-usage.h
filesystem.c btrfs-progs: fix defrag -c option parsing 2021-09-18 17:48:32 +02:00
inspect-dump-super.c
inspect-dump-tree.c btrfs-progs: dump-tree: add options to dump checksums 2021-06-19 22:07:49 +02:00
inspect-tree-stats.c btrfs-progs: switch %Lu to %llu format 2021-06-19 22:07:49 +02:00
inspect.c btrfs-progs: fix inspect-internal --help incomplete sentence 2021-05-17 14:26:32 +02:00
property.c btrfs-progs: merge props.c to cmds/property.c 2021-09-07 19:41:24 +02:00
props.h btrfs-progs: move props.h to cmds/ 2021-09-07 19:33:24 +02:00
qgroup.c btrfs-progs: move all private definitions to cmds/qgroup.c 2021-09-07 19:21:14 +02:00
qgroup.h btrfs-progs: move all private definitions to cmds/qgroup.c 2021-09-07 19:21:14 +02:00
quota.c
receive-dump.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
receive-dump.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
receive.c btrfs-progs: open code btrfs_list_get_path_rootid 2021-09-08 16:35:47 +02:00
replace.c
rescue-chunk-recover.c btrfs-progs: add and use bit masks for RAID1 and RAID56 profiles 2021-09-06 16:36:18 +02:00
rescue-super-recover.c
rescue.c
rescue.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
restore.c btrfs-progs: introduce OPEN_CTREE_ALLOW_TRANSID_MISMATCH flag 2021-09-20 12:17:29 +02:00
scrub.c
send.c btrfs-progs: move send.h to kernel-shared/ 2021-09-07 19:26:46 +02:00
subvolume.c btrfs-progs: open code btrfs_list_get_path_rootid 2021-09-08 16:35:47 +02:00