btrfs-progs/convert
Qu Wenruo f3353a5e85 btrfs-progs: convert: handle ext4 orphan file feature properly
[BUG]
Since e2fsprog 1.47, even with a newly created empty ext4 filesystem,
btrfs-convert would result an fs that btrfs-check would complain:

  # mkfs.ext4 -F test.img
  # btrfs-convert test.img
  # btrfs-check test.img
  Opening filesystem to check...
  Checking filesystem on test.img
  UUID: e45da158-8967-4e4d-9c9f-66b0d127dbce
  [1/7] checking root items
  [2/7] checking extents
  [3/7] checking free space cache
  [4/7] checking fs roots
  root 5 inode 266 errors 2000, link count wrong
  ERROR: errors found in fs roots
  found 26333184 bytes used, error(s) found <<<
  total csum bytes: 25540
  total tree bytes: 180224
  total fs tree bytes: 49152
  total extent tree bytes: 16384
  btree space waste bytes: 145423
  file data blocks allocated: 33947648
   referenced 26284032

[CAUSE]
Ext4 has a new compat feature, COMPAT_ORPHAN_FILE, as a better way to
track all the orphan inodes.

This new feature would create a new special inode for this purpose, and
such orphan file inode would not be reachable from any other inode, but
only from super block.

Unfortunately btrfs-convert only skip ext2 known special inodes, not the
newer one.

[FIX]
According to the kernel document, we can locate the orphan file inode
using ext2 super block s_orphan_file_inum, and skip it for
btrfs-convert.

And such skip would only happen if we have the definition of
EXT4_FEATURE_COMPAT_ORPHAN_FILE, to be compatible with older e2fsprogs.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-23 19:48:26 +01:00
..
common.c btrfs-progs: fsfeatures: properly merge -O and -R options 2022-10-11 09:08:11 +02:00
common.h btrfs-progs: convert: move simple_range into common.h 2022-10-11 09:08:08 +02:00
main.c btrfs-progs: convert: convert help text to option formatter 2023-02-28 20:11:23 +01:00
Makefile btrfs-progs: build: add stub makefile to convert 2017-03-08 13:00:46 +01:00
source-ext2.c btrfs-progs: convert: handle ext4 orphan file feature properly 2023-03-23 19:48:26 +01:00
source-ext2.h btrfs-progs: convert: update include lists 2022-10-11 09:06:12 +02:00
source-fs.c btrfs-progs: convert: do proper error handling 2022-10-11 09:08:10 +02:00
source-fs.h btrfs-progs: convert: expose intersect_with_reserved() to main.c 2022-10-11 09:08:08 +02:00
source-reiserfs.c btrfs-progs: convert: do proper error handling 2022-10-11 09:08:10 +02:00
source-reiserfs.h btrfs-progs: convert: update include lists 2022-10-11 09:06:12 +02:00