summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch')
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch64
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch
new file mode 100644
index 0000000000..e4665335ee
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch
@@ -0,0 +1,64 @@
1Upstream-Status: Inappropriate [Backport]
2From a6c54702d8973aef081cff81ed8d90427bb21768 Mon Sep 17 00:00:00 2001
3From: Chris Mason <chris.mason@oracle.com>
4Date: Wed, 15 Dec 2010 16:00:23 -0500
5Subject: [PATCH 1/5] Fill missing devices so degraded filesystems can be read
6
7When a device is missing, the btrfs tools need to be able to read alternate
8copies from the remaining devices. This creates placeholder devices
9that always return -EIO so the tools can limp along.
10
11Signed-off-by: Chris Mason <chris.mason@oracle.com>
12---
13 disk-io.c | 1 +
14 volumes.c | 15 +++++++++++++--
15 2 files changed, 14 insertions(+), 2 deletions(-)
16
17diff --git a/disk-io.c b/disk-io.c
18index 5bd9cfc..f4368f3 100644
19--- a/disk-io.c
20+++ b/disk-io.c
21@@ -204,6 +204,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
22 eb->dev_bytenr = multi->stripes[0].physical;
23 kfree(multi);
24 ret = read_extent_from_disk(eb);
25+
26 if (ret == 0 && check_tree_block(root, eb) == 0 &&
27 csum_tree_block(root, eb, 1) == 0 &&
28 verify_parent_transid(eb->tree, eb, parent_transid) == 0) {
29diff --git a/volumes.c b/volumes.c
30index 4bb77e2..5773467 100644
31--- a/volumes.c
32+++ b/volumes.c
33@@ -1263,6 +1263,16 @@ int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset)
34 return readonly;
35 }
36
37+static struct btrfs_device *fill_missing_device(u64 devid)
38+{
39+ struct btrfs_device *device;
40+
41+ device = kzalloc(sizeof(*device), GFP_NOFS);
42+ device->devid = devid;
43+ device->fd = -1;
44+ return device;
45+}
46+
47 static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
48 struct extent_buffer *leaf,
49 struct btrfs_chunk *chunk)
50@@ -1313,8 +1323,9 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key,
51 map->stripes[i].dev = btrfs_find_device(root, devid, uuid,
52 NULL);
53 if (!map->stripes[i].dev) {
54- kfree(map);
55- return -EIO;
56+ map->stripes[i].dev = fill_missing_device(devid);
57+ printf("warning, device %llu is missing\n",
58+ (unsigned long long)devid);
59 }
60
61 }
62--
631.7.2.3
64