btrfs-progs/kernel-shared
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
..
backref.c btrfs-progs: move transaction.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
backref.h btrfs-progs: move extent_io.c to kernel-shared/ 2020-08-31 17:01:04 +02:00
ctree.c btrfs-progs: backport btrfs_check_node() from kernel 2021-09-07 14:20:41 +02:00
ctree.h btrfs-progs: introduce OPEN_CTREE_ALLOW_TRANSID_MISMATCH flag 2021-09-20 12:17:29 +02:00
delayed-ref.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
delayed-ref.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
dir-item.c btrfs-progs: make btrfs_lookup_dir_index in parity with kernel code 2020-08-31 17:09:49 +02:00
disk-io.c btrfs-progs: introduce OPEN_CTREE_ALLOW_TRANSID_MISMATCH flag 2021-09-20 12:17:29 +02:00
disk-io.h btrfs-progs: introduce OPEN_CTREE_ALLOW_TRANSID_MISMATCH flag 2021-09-20 12:17:29 +02:00
extent-tree.c btrfs-progs: add and use bit masks for RAID1 and RAID56 profiles 2021-09-06 16:36:18 +02:00
extent_io.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
extent_io.h btrfs-progs: move extent_io.c to kernel-shared/ 2020-08-31 17:01:04 +02:00
file-item.c btrfs-progs: delete bogus zero checksum check 2021-05-08 00:58:51 +02:00
file.c btrfs-progs: move transaction.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
free-space-cache.c btrfs-progs: check: batch v1 space cache inodes when clearing 2021-07-22 16:26:05 +02:00
free-space-cache.h btrfs-progs: check: batch v1 space cache inodes when clearing 2021-07-22 16:26:05 +02:00
free-space-tree.c btrfs-progs: add add_block_group_free_space helper 2021-09-06 16:36:17 +02:00
free-space-tree.h btrfs-progs: add add_block_group_free_space helper 2021-09-06 16:36:17 +02:00
inode-item.c btrfs-progs: move transaction.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
inode.c btrfs-progs: make btrfs_lookup_dir_index in parity with kernel code 2020-08-31 17:09:49 +02:00
print-tree.c btrfs-progs: switch %Lu to %llu format 2021-06-19 22:07:49 +02:00
print-tree.h btrfs-progs: dump-tree: add options to dump checksums 2021-06-19 22:07:49 +02:00
root-tree.c btrfs-progs: move transaction.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
send.h btrfs-progs: remove stale declaration from send.h 2021-09-07 19:27:59 +02:00
transaction.c btrfs-progs: zoned: redirty clean extent buffers 2021-05-06 16:41:45 +02:00
transaction.h btrfs-progs: move transaction.c to kernel-shared/ 2020-08-31 17:01:06 +02:00
ulist.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
ulist.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
uuid-tree.c btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
volumes.c btrfs-progs: rename and move group_profile_max_safe_loss 2021-09-07 16:38:56 +02:00
volumes.h btrfs-progs: rename and move group_profile_max_safe_loss 2021-09-07 16:38:56 +02:00
zoned.c btrfs-progs: handle EINVAL when reading zone size on older kernels 2021-09-20 11:31:09 +02:00
zoned.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00