btrfs-progs/check
Qu Wenruo 517ba2d9e5 btrfs-progs: convert: insert a dummy inode item before inode ref for ext2/4
[BUG]
There is a report about failed btrfs-convert, which shows the following
error:

  Create btrfs metadata
  corrupt leaf: root=5 block=5001931145216 slot=1 ino=89911763, invalid previous key objectid, have 89911762 expect 89911763
  leaf 5001931145216 items 336 free space 7 generation 90 owner FS_TREE
  leaf 5001931145216 flags 0x1(WRITTEN) backref revision 1
  fs uuid 8b69f018-37c3-4b30-b859-42ccfcbe2449
  chunk uuid 448ce78c-ea41-49f6-99dc-46ad80b93da9
          item 0 key (89911762 INODE_REF 3858733) itemoff 16222 itemsize 61
                  index 171 namelen 51 name: [FILENAME1]
          item 1 key (89911763 INODE_REF 3858733) itemoff 16161 itemsize 61
                  index 103 namelen 51 name: [FILENAME2]

[CAUSE]
When iterating a directory, btrfs-convert would insert the DIR_ITEMs,
along with the INODE_REF of that inode.

This leads to above stray INODE_REFs, and trigger the tree-checker.

This can only happen for large fs, as for most cases we have all these
modified tree blocks cached, thus tree-checker won't be triggered.
But when the tree block cache is not hit, and we have to read from disk,
then such behavior can lead to above tree-checker error.

[FIX]
Insert a dummy INODE_ITEM for the INODE_REF first, the inode items would
be updated when iterating the child inode of the directory.

Issue: #731
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2024-01-17 01:47:39 +01:00
..
common.h btrfs-progs: add extra chunk alignment checks 2024-01-16 19:14:37 +01:00
main.c btrfs-progs: add extra chunk alignment checks 2024-01-16 19:14:37 +01:00
mode-common.c btrfs-progs: check: drop unsigned long long casts for printf 2023-11-03 18:04:37 +01:00
mode-common.h btrfs-progs: convert: insert a dummy inode item before inode ref for ext2/4 2024-01-17 01:47:39 +01:00
mode-lowmem.c btrfs-progs: add extra chunk alignment checks 2024-01-16 19:14:37 +01:00
mode-lowmem.h btrfs-progs: check: update error bit definitions 2023-11-03 18:04:37 +01:00
mode-original.h btrfs-progs: check: update error bit definitions 2023-11-03 18:04:37 +01:00
qgroup-verify.c btrfs-progs: check: drop unsigned long long casts for printf 2023-11-03 18:04:37 +01:00
qgroup-verify.h btrfs-progs: check: update include lists 2022-10-11 09:06:12 +02:00
repair.c btrfs-progs: fix all variable shadowing 2023-10-10 19:16:29 +02:00
repair.h btrfs-progs: clean up includes, using include-what-you-use 2023-10-03 01:11:57 +02:00