btrfsprogs/0120-btrfs-progs-Check-metadata-mirrors-in-find-root.patch
David Sterba db07609875 - btrfs-progs-fix-open_ctree_usage_segfaults.patch: fix
segfaults from bnc#710486 due to unchecked usage of return
  value of open_ctree()
  [fixed compilation warnings]

- pull upstream, replace existing patches, spec update
- update 'restore' utility
  - lzo support
  - tools may now take earlies superblock when opening the fs
  - other fixes
- pull integration-20111030 branch
  - mkfs: force mkfs if desired
  - other fixes
- add btrfs-dump-super to mkinitrd
- other fixes
  - skip non-existent devices or without media
  - documentation updates
  - scrubbing single device
  - graceful error handling when opening fs fails

- updated mkinitrd script to scan devices before mount (bnc#727383)

OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=115
2011-12-14 23:25:51 +00:00

56 lines
1.5 KiB
Diff

From a1ebf7b951c6796039748601404aa01fd283ddef Mon Sep 17 00:00:00 2001
From: David Marcin <djmarcin@google.com>
Date: Wed, 16 Nov 2011 12:18:08 -0800
Subject: [PATCH 21/35] btrfs-progs: Check metadata mirrors in find-root.
Signed-off-by: David Marcin <djmarcin@google.com>
---
find-root.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/find-root.c b/find-root.c
index c0f38b8..2899632 100644
--- a/find-root.c
+++ b/find-root.c
@@ -361,6 +361,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)) {
@@ -377,8 +379,10 @@ static int find_root(struct btrfs_root *root)
}
offset = metadata_offset;
}
+ mirror_num = 1;
+ again:
err = __btrfs_map_block(&root->fs_info->mapping_tree, READ,
- offset, &map_length, &type, &multi, 0);
+ offset, &map_length, &type, &multi, mirror_num);
if (err) {
offset += map_length;
continue;
@@ -396,9 +400,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.7.6.233.gd79bc