218848695f
Sync to a long-awaited upstream release. Version update. Only a handful of local packages that will be upstreamed later. This set of changes is not suitable for direct copy to currently released products because there are changes in mkfs defaults (12.x, 13.x, SLES). Fine for Factory. OBS-URL: https://build.opensuse.org/request/show/208357 OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=147
57 lines
1.6 KiB
Diff
57 lines
1.6 KiB
Diff
From 4469ed43b26b6e7d5ad5cfea45e99708e39de4a6 Mon Sep 17 00:00:00 2001
|
|
From: David Marcin <djmarcin@google.com>
|
|
Date: Wed, 16 Nov 2011 12:18:08 -0800
|
|
Subject: [PATCH 169/170] btrfs-progs: Check metadata mirrors in find-root.
|
|
|
|
Signed-off-by: David Marcin <djmarcin@google.com>
|
|
---
|
|
btrfs-find-root.c | 13 ++++++++++++-
|
|
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
|
|
index 7f7b64f..ffbdde1 100644
|
|
--- a/btrfs-find-root.c
|
|
+++ b/btrfs-find-root.c
|
|
@@ -236,6 +236,8 @@ static int find_root(struct btrfs_root *root)
|
|
while (1) {
|
|
u64 map_length = 4096;
|
|
u64 type;
|
|
+ int mirror_num;
|
|
+ int num_copies;
|
|
|
|
if (offset >
|
|
btrfs_super_total_bytes(root->fs_info->super_copy)) {
|
|
@@ -257,9 +259,11 @@ static int find_root(struct btrfs_root *root)
|
|
printf("Checking metadata chunk %Lu, size %Lu"
|
|
"\n", metadata_offset, metadata_size);
|
|
}
|
|
+ mirror_num = 1;
|
|
+ again:
|
|
err = __btrfs_map_block(&root->fs_info->mapping_tree, READ,
|
|
offset, &map_length, &type,
|
|
- &multi, 0, NULL);
|
|
+ &multi, mirror_num, NULL);
|
|
if (err) {
|
|
offset += map_length;
|
|
continue;
|
|
@@ -278,9 +282,16 @@ static int find_root(struct btrfs_root *root)
|
|
|
|
err = read_physical(root, fd, offset, bytenr, map_length);
|
|
if (!err) {
|
|
+ /* Found the root. */
|
|
ret = 0;
|
|
break;
|
|
} else if (err < 0) {
|
|
+ num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
|
|
+ offset, map_length);
|
|
+ mirror_num++;
|
|
+ if (mirror_num <= num_copies)
|
|
+ goto again;
|
|
+ /* Unrecoverable error in read. */
|
|
ret = err;
|
|
break;
|
|
}
|
|
--
|
|
1.8.3.1
|
|
|