summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn')
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch64
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch35
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch33
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch253
-rw-r--r--meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch75
5 files changed, 460 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
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch
new file mode 100644
index 0000000000..c8557f7863
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch
@@ -0,0 +1,35 @@
1Upstream-Status: Inappropriate [Backport]
2From 454a0538680bc17656cefadef1f167917ea0b856 Mon Sep 17 00:00:00 2001
3From: Chris Mason <chris.mason@oracle.com>
4Date: Wed, 15 Dec 2010 16:02:45 -0500
5Subject: [PATCH 2/5] Check for RAID10 in set_avail_alloc_bits
6
7When raid is setup with mkfs, it is supposed to cow the initial filesystem
8it creates up to the desired raid level. RAID10 was not in the list
9of RAID levels it checked for, so the initial FS created for RAID10
10actually only lived on the first disk.
11
12This works well enough because all the roots get quickly cowed during the
13first mount. The exception is the data relocation tree, which only gets
14cowed when we do a balance.
15
16Signed-off-by: Chris Mason <chris.mason@oracle.com>
17---
18 extent-tree.c | 1 +
19 1 files changed, 1 insertions(+), 0 deletions(-)
20
21diff --git a/extent-tree.c b/extent-tree.c
22index b2f9bb2..108933f 100644
23--- a/extent-tree.c
24+++ b/extent-tree.c
25@@ -1775,6 +1775,7 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags)
26 {
27 u64 extra_flags = flags & (BTRFS_BLOCK_GROUP_RAID0 |
28 BTRFS_BLOCK_GROUP_RAID1 |
29+ BTRFS_BLOCK_GROUP_RAID10 |
30 BTRFS_BLOCK_GROUP_DUP);
31 if (extra_flags) {
32 if (flags & BTRFS_BLOCK_GROUP_DATA)
33--
341.7.2.3
35
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch
new file mode 100644
index 0000000000..ad416208b2
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch
@@ -0,0 +1,33 @@
1Upstream-Status: Inappropriate [Backport]
2From d5b8b904ac40e4c5dbff4008accd7e588b697085 Mon Sep 17 00:00:00 2001
3From: Chris Mason <chris.mason@oracle.com>
4Date: Wed, 15 Dec 2010 16:03:00 -0500
5Subject: [PATCH 3/5] Print the root generation in btrfs-debug-tree
6
7Signed-off-by: Chris Mason <chris.mason@oracle.com>
8---
9 print-tree.c | 5 +++--
10 1 files changed, 3 insertions(+), 2 deletions(-)
11
12diff --git a/print-tree.c b/print-tree.c
13index ac575d5..85399aa 100644
14--- a/print-tree.c
15+++ b/print-tree.c
16@@ -505,11 +505,12 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l)
17 case BTRFS_ROOT_ITEM_KEY:
18 ri = btrfs_item_ptr(l, i, struct btrfs_root_item);
19 read_extent_buffer(l, &root_item, (unsigned long)ri, sizeof(root_item));
20- printf("\t\troot data bytenr %llu level %d dirid %llu refs %u\n",
21+ printf("\t\troot data bytenr %llu level %d dirid %llu refs %u gen %llu\n",
22 (unsigned long long)btrfs_root_bytenr(&root_item),
23 btrfs_root_level(&root_item),
24 (unsigned long long)btrfs_root_dirid(&root_item),
25- btrfs_root_refs(&root_item));
26+ btrfs_root_refs(&root_item),
27+ (unsigned long long)btrfs_root_generation(&root_item));
28 if (btrfs_root_refs(&root_item) == 0) {
29 struct btrfs_key drop_key;
30 btrfs_disk_key_to_cpu(&drop_key,
31--
321.7.2.3
33
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch
new file mode 100644
index 0000000000..cf8700723f
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch
@@ -0,0 +1,253 @@
1Upstream-Status: Inappropriate [Backport]
2From 238f88bb6c4b9ebad727c6bffb57f542e7e412c1 Mon Sep 17 00:00:00 2001
3From: Chris Mason <chris.mason@oracle.com>
4Date: Sun, 19 Dec 2010 16:22:31 -0500
5Subject: [PATCH 4/5] Allow partial FS opens for btrfsck scanning
6
7Signed-off-by: Chris Mason <chris.mason@oracle.com>
8---
9 btrfsck.c | 10 ++++++++--
10 convert.c | 20 ++++++++++++++------
11 disk-io.c | 57 +++++++++++++++++++++++++++++++++++++++++----------------
12 disk-io.h | 5 +++--
13 4 files changed, 66 insertions(+), 26 deletions(-)
14
15diff --git a/btrfsck.c b/btrfsck.c
16index 63e44d1..f760706 100644
17--- a/btrfsck.c
18+++ b/btrfsck.c
19@@ -2820,6 +2820,7 @@ int main(int ac, char **av)
20 {
21 struct cache_tree root_cache;
22 struct btrfs_root *root;
23+ struct btrfs_fs_info *info;
24 u64 bytenr = 0;
25 int ret;
26 int num;
27@@ -2856,11 +2857,16 @@ int main(int ac, char **av)
28 return -EBUSY;
29 }
30
31- root = open_ctree(av[optind], bytenr, 0);
32+ info = open_fs_info(av[optind], bytenr, 0, 1);
33
34- if (root == NULL)
35+ if (info == NULL)
36 return 1;
37
38+ root = info->fs_root;
39+ if (!root) {
40+ fprintf(stderr, "failed to read the filesystem\n");
41+ exit(1);
42+ }
43 ret = check_extents(root);
44 if (ret)
45 goto out;
46diff --git a/convert.c b/convert.c
47index fbcf4a3..72e3cdc 100644
48--- a/convert.c
49+++ b/convert.c
50@@ -2342,6 +2342,7 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr)
51 ext2_filsys ext2_fs;
52 struct btrfs_root *root;
53 struct btrfs_root *ext2_root;
54+ struct btrfs_fs_info *fs_info;
55
56 ret = open_ext2fs(devname, &ext2_fs);
57 if (ret) {
58@@ -2386,11 +2387,12 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr)
59 fprintf(stderr, "unable to update system chunk\n");
60 goto fail;
61 }
62- root = open_ctree_fd(fd, devname, super_bytenr, O_RDWR);
63- if (!root) {
64+ fs_info = open_ctree_fd(fd, devname, super_bytenr, O_RDWR, 0);
65+ if (!fs_info) {
66 fprintf(stderr, "unable to open ctree\n");
67 goto fail;
68 }
69+ root = fs_info->fs_root;
70 ret = cache_free_extents(root, ext2_fs);
71 if (ret) {
72 fprintf(stderr, "error during cache_free_extents %d\n", ret);
73@@ -2447,11 +2449,13 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr)
74 goto fail;
75 }
76
77- root = open_ctree_fd(fd, devname, 0, O_RDWR);
78- if (!root) {
79+ fs_info = open_ctree_fd(fd, devname, 0, O_RDWR, 0);
80+ if (!fs_info) {
81 fprintf(stderr, "unable to open ctree\n");
82 goto fail;
83 }
84+ root = fs_info->fs_root;
85+
86 /* move chunk tree into system chunk. */
87 ret = fixup_chunk_mapping(root);
88 if (ret) {
89@@ -2525,6 +2529,7 @@ int do_rollback(const char *devname, int force)
90 struct btrfs_key key;
91 struct btrfs_path path;
92 struct extent_io_tree io_tree;
93+ struct btrfs_fs_info *fs_info;
94 char *buf;
95 char *name;
96 u64 bytenr;
97@@ -2546,11 +2551,14 @@ int do_rollback(const char *devname, int force)
98 fprintf(stderr, "unable to open %s\n", devname);
99 goto fail;
100 }
101- root = open_ctree_fd(fd, devname, 0, O_RDWR);
102- if (!root) {
103+
104+ fs_info = open_ctree_fd(fd, devname, 0, O_RDWR, 0);
105+ if (!fs_info) {
106 fprintf(stderr, "unable to open ctree\n");
107 goto fail;
108 }
109+ root = fs_info->fs_root;
110+
111 ret = may_rollback(root);
112 if (ret < 0) {
113 fprintf(stderr, "unable to do rollback\n");
114diff --git a/disk-io.c b/disk-io.c
115index f4368f3..dc100b0 100644
116--- a/disk-io.c
117+++ b/disk-io.c
118@@ -441,7 +441,8 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
119 btrfs_super_generation(disk_super) + 1);
120
121 fs_info->log_root_tree = log_root;
122- BUG_ON(!log_root->node);
123+ if (!log_root->node)
124+ return -EIO;
125 return 0;
126 }
127
128@@ -571,10 +572,11 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info,
129 return root;
130 }
131
132-struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes)
133+struct btrfs_fs_info *open_fs_info(const char *filename, u64 sb_bytenr,
134+ int writes, int partial)
135 {
136 int fp;
137- struct btrfs_root *root;
138+ struct btrfs_fs_info *fs_info;
139 int flags = O_CREAT | O_RDWR;
140
141 if (!writes)
142@@ -585,14 +587,25 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes)
143 fprintf (stderr, "Could not open %s\n", filename);
144 return NULL;
145 }
146- root = open_ctree_fd(fp, filename, sb_bytenr, writes);
147+ fs_info = open_ctree_fd(fp, filename, sb_bytenr, writes, partial);
148+
149 close(fp);
150+ return fs_info;
151+}
152
153- return root;
154+
155+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes)
156+{
157+ struct btrfs_fs_info *fs_info;
158+
159+ fs_info = open_fs_info(filename, sb_bytenr, writes, 0);
160+ if (fs_info)
161+ return fs_info->fs_root;
162+ return NULL;
163 }
164
165-struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
166- int writes)
167+struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
168+ int writes, int partial)
169 {
170 u32 sectorsize;
171 u32 nodesize;
172@@ -727,7 +740,8 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
173
174 if (!(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_METADUMP)) {
175 ret = btrfs_read_chunk_tree(chunk_root);
176- BUG_ON(ret);
177+ if (ret)
178+ goto fail;
179 }
180
181 blocksize = btrfs_level_size(tree_root,
182@@ -737,25 +751,32 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
183 tree_root->node = read_tree_block(tree_root,
184 btrfs_super_root(disk_super),
185 blocksize, generation);
186- BUG_ON(!tree_root->node);
187+ if (!tree_root->node)
188+ goto fail;
189+
190 ret = find_and_setup_root(tree_root, fs_info,
191 BTRFS_EXTENT_TREE_OBJECTID, extent_root);
192- BUG_ON(ret);
193+ if (ret)
194+ goto fail;
195+
196 extent_root->track_dirty = 1;
197
198 ret = find_and_setup_root(tree_root, fs_info,
199 BTRFS_DEV_TREE_OBJECTID, dev_root);
200- BUG_ON(ret);
201+ if (ret)
202+ goto fail;
203+
204 dev_root->track_dirty = 1;
205
206 ret = find_and_setup_root(tree_root, fs_info,
207 BTRFS_CSUM_TREE_OBJECTID, csum_root);
208- BUG_ON(ret);
209+ if (ret)
210+ goto fail;
211 csum_root->track_dirty = 1;
212
213- BUG_ON(ret);
214-
215- find_and_setup_log_root(tree_root, fs_info, disk_super);
216+ ret = find_and_setup_log_root(tree_root, fs_info, disk_super);
217+ if (ret)
218+ goto fail;
219
220 fs_info->generation = generation + 1;
221 btrfs_read_block_groups(fs_info->tree_root);
222@@ -769,7 +790,11 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
223 fs_info->metadata_alloc_profile = (u64)-1;
224 fs_info->system_alloc_profile = fs_info->metadata_alloc_profile;
225
226- return fs_info->fs_root;
227+ return fs_info;
228+fail:
229+ if (partial)
230+ return fs_info;
231+ return NULL;
232 }
233
234 int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr)
235diff --git a/disk-io.h b/disk-io.h
236index 7ebec24..03c5eee 100644
237--- a/disk-io.h
238+++ b/disk-io.h
239@@ -44,8 +44,9 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
240 int clean_tree_block(struct btrfs_trans_handle *trans,
241 struct btrfs_root *root, struct extent_buffer *buf);
242 struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes);
243-struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
244- int writes);
245+struct btrfs_fs_info *open_fs_info(const char *filename, u64 sb_bytenr, int writes, int partial);
246+struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
247+ int writes, int partial);
248 int close_ctree(struct btrfs_root *root);
249 int write_all_supers(struct btrfs_root *root);
250 int write_ctree_super(struct btrfs_trans_handle *trans,
251--
2521.7.2.3
253
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch
new file mode 100644
index 0000000000..54123f729d
--- /dev/null
+++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch
@@ -0,0 +1,75 @@
1Upstream-Status: Inappropriate [Backport]
2From e3064e90cfd0be823b2da3edff64f97756fcc245 Mon Sep 17 00:00:00 2001
3From: Chris Mason <chris.mason@oracle.com>
4Date: Mon, 25 Apr 2011 16:31:40 -0400
5Subject: [PATCH 5/5] Temporary debugging for dragonn
6
7Signed-off-by: Chris Mason <chris.mason@oracle.com>
8---
9 btrfsck.c | 3 +++
10 disk-io.c | 16 ++++++++--------
11 2 files changed, 11 insertions(+), 8 deletions(-)
12
13diff --git a/btrfsck.c b/btrfsck.c
14index f760706..cb3dee0 100644
15--- a/btrfsck.c
16+++ b/btrfsck.c
17@@ -855,6 +855,7 @@ static u64 count_csum_range(struct btrfs_root *root, u64 start, u64 len)
18 u64 csum_end;
19 u16 csum_size = btrfs_super_csum_size(&root->fs_info->super_copy);
20
21+ return 0;
22 btrfs_init_path(&path);
23
24 key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
25@@ -2666,6 +2667,8 @@ static int add_root_to_pending(struct extent_buffer *buf,
26 struct cache_tree *nodes,
27 struct btrfs_key *root_key)
28 {
29+ if (root_key->objectid == 7)
30+ return 0;
31 if (btrfs_header_level(buf) > 0)
32 add_pending(nodes, seen, buf->start, buf->len);
33 else
34diff --git a/disk-io.c b/disk-io.c
35index dc100b0..c242364 100644
36--- a/disk-io.c
37+++ b/disk-io.c
38@@ -614,12 +614,12 @@ struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
39 u32 stripesize;
40 u64 generation;
41 struct btrfs_key key;
42- struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root));
43- struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root));
44- struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root));
45- struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root));
46- struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root));
47- struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info));
48+ struct btrfs_root *tree_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
49+ struct btrfs_root *extent_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
50+ struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
51+ struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
52+ struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS);
53+ struct btrfs_fs_info *fs_info = kzalloc(sizeof(*fs_info), GFP_NOFS);
54 int ret;
55 struct btrfs_super_block *disk_super;
56 struct btrfs_fs_devices *fs_devices = NULL;
57@@ -767,13 +767,13 @@ struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr,
58 goto fail;
59
60 dev_root->track_dirty = 1;
61-
62+#if 0
63 ret = find_and_setup_root(tree_root, fs_info,
64 BTRFS_CSUM_TREE_OBJECTID, csum_root);
65 if (ret)
66 goto fail;
67 csum_root->track_dirty = 1;
68-
69+#endif
70 ret = find_and_setup_log_root(tree_root, fs_info, disk_super);
71 if (ret)
72 goto fail;
73--
741.7.2.3
75