Skip to contentSkip to conversation

btrfs-progs: image: Rebuild dev extents for restore

PATCH New Qu Wenruo 1 participant 1 message Aug 17, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs-progs: image: Rebuild dev extents for restore

When restoring image from a dump of multiple device, we just restore device as is, even the restore destination is just a single device.

In that case, due to dev extents mismatch, latest kernel will refuse to mount it as it detects such mismatch as good as btrfs check.

Fix it by rebuilding the whole device tree when finishing restore, so kernel or btrfs check will give no complain about restore image any more.

This fixes misc/021 test case.

---
 ctree.h      |   6 +++
 image/main.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 135 insertions(+)
ctree.h +6 -0
index 4719962df67d..69bf3be4b9b1 100644
@@ -1707,6 +1707,12 @@ BTRFS_SETGET_FUNCS(dev_extent_chunk_offset, struct btrfs_dev_extent,
 		   chunk_offset, 64);
 BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64);
 
+BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_tree, struct btrfs_dev_extent,
+		   chunk_tree, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_objectid,
+		   struct btrfs_dev_extent, chunk_objectid, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_chunk_offset, struct btrfs_dev_extent,
+		   chunk_offset, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_dev_extent_length, struct btrfs_dev_extent,
 			 length, 64);
 
image/main.c +129 -0

141 lines not on this page · raw message

Signature · 1 line
2.18.0