Skip to content

btrfs-progs: image: Fix error when restoring multi-disk image to single disk

Qu Wenruo linux-btrfs 2 versions Applied

Status from this message: Merged to devel, thanks. I've switched strerror(-ret) to the errno

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest5 patches 10 repliesApplied
  2. v15 patches 10 repliesSuperseded

Changes in v2 from the cover letter

- Parameter list cleanup
* Use trans->fs_info to remove fs_info parameter
* Remove trans parameter for function who doesn't need
- Merge dev extents removal code with rebuild code
- Refactor btrfs_alloc_dev_extent() into 2 functions
* btrfs_insert_dev_extent() for convert and dev extent rebuild
* btrfs_alloc_dev_extent() for old use case

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/5btrfs-progs: image: Refactor fixup_devices() to fixup_chunks_and_devices()image/main.c+36 -167 replies
2/5btrfs-progs: image: Fix block group item flags when restoring multi-device image to single deviceimage/main.c+46 -00 replies
3/5btrfs-progs: volumes: Refactor btrfs_alloc_dev_extent() into two functionsvolumes.c volumes.h+33 -181 reply
4/5btrfs-progs: image: Remove all existing dev extents for later rebuildimage/main.c+102 -00 replies
5/5btrfs-progs: misc-tests/021: Do extra btrfs check before mountingtests/misc-tests/021-image-multi-devices/test.sh+3 -01 reply

Reviews trailers per patch

3 of 5 patches have a Reviewed-by or Acked-by.

PatchNikolay Borisov
1/5R-b
2/5
3/5R-b
4/5
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/5] btrfs-progs: image: Fix error when restoring multi-disk image to single disk

This patchset can be fetched from github:
https://github.com/adam900710/btrfs-progs/tree/image_recover

The base commit is as usual, the latest stable tag, v4.19.

Test case misc/021 will fail if using latest upstream kernel.

This is due to the enhanced code in kernel to check block group <-> chunk <-> dev extent mapping.

This means from the very beginning, btrfs-image can't really restore a multi-disk image to single-disk one correctly.

The problem is, although we modified chunk item, we didn't modify block group item's flags or dev extents.

This patch will reset block group flags, then rebuild the whole dev extents by removing existing ones first, then re-add the correct dev extents calculated from chunk map.

Now it could pass all misc tests and fsck tests.

Changelog:
v2:
- Parameter list cleanup
* Use trans->fs_info to remove fs_info parameter
* Remove trans parameter for function who doesn't need
- Merge dev extents removal code with rebuild code
- Refactor btrfs_alloc_dev_extent() into 2 functions
* btrfs_insert_dev_extent() for convert and dev extent rebuild
* btrfs_alloc_dev_extent() for old use case

Qu Wenruo (5):
btrfs-progs: image: Refactor fixup_devices() to
fixup_chunks_and_devices()
btrfs-progs: image: Fix block group item flags when restoring
multi-device image to single device
btrfs-progs: volumes: Refactor btrfs_alloc_dev_extent() into two
functions
btrfs-progs: image: Remove all existing dev extents for later rebuild
btrfs-progs: misc-tests/021: Do extra btrfs check before mounting

 image/main.c                                  | 200 ++++++++++++++++--
 .../021-image-multi-devices/test.sh           |   3 +
 volumes.c                                     |  48 +++--
 volumes.h                                     |   3 +
 4 files changed, 220 insertions(+), 34 deletions(-)
Signature · 1 line
2.19.2