diff options
| author | Nitin A Kamble <nitin.a.kamble@intel.com> | 2011-06-09 18:12:12 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-30 20:43:07 +0100 |
| commit | 57a2140dc9673c65fea088fbd024fbd002e6937b (patch) | |
| tree | 0694a46fdae4fca6a07887a34ca57efb9221625c | |
| parent | 829dd1d7ca99ec6228d2705cdece4727232797d3 (diff) | |
| download | openembedded-core-57a2140dc9673c65fea088fbd024fbd002e6937b.tar.gz openembedded-core-57a2140dc9673c65fea088fbd024fbd002e6937b.tar.bz2 openembedded-core-57a2140dc9673c65fea088fbd024fbd002e6937b.zip | |
btrfs-tools: new recipe for tools to operate on btrfs images
Added these patches to the recipe to get it to work as desired:
Upstream patches from tmp & for-dragonn branches of repository http://git.kernel.org/?p=linux/kernel/git/mason/btrfs-progs-unstable.git
Also included the debian patches.
Nitin's patch to make the makefile cross friendly
And Xin Zhong's patch to improve mkfs.btrfs
Signed-off-by: Nitin A Kamble <nitin.a.kamble@intel.com>
26 files changed, 4687 insertions, 0 deletions
diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/01-labels.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/01-labels.patch new file mode 100644 index 0000000000..b15a1c98ed --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/01-labels.patch @@ -0,0 +1,29 @@ +Upstream-Status: Inappropriate [distribution: debian] + +Author: Chris Mason <chris.mason@oracle.com> +Description: Allow /'s in labels. + +diff -Naurp btrfs-tools.orig/mkfs.c btrfs-tools/mkfs.c +--- btrfs-tools.orig/mkfs.c 2009-03-15 13:27:12.000000000 +0100 ++++ btrfs-tools/mkfs.c 2009-04-17 20:53:12.000000000 +0200 +@@ -294,7 +294,6 @@ static u64 parse_profile(char *s) + + static char *parse_label(char *input) + { +- int i; + int len = strlen(input); + + if (len > BTRFS_LABEL_SIZE) { +@@ -302,12 +301,6 @@ static char *parse_label(char *input) + BTRFS_LABEL_SIZE); + exit(1); + } +- for (i = 0; i < len; i++) { +- if (input[i] == '/' || input[i] == '\\') { +- fprintf(stderr, "invalid label %s\n", input); +- exit(1); +- } +- } + return strdup(input); + } + diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/02-ftbfs.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/02-ftbfs.patch new file mode 100644 index 0000000000..7b47190757 --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/02-ftbfs.patch @@ -0,0 +1,125 @@ +Upstream-Status: Inappropriate [distribution: debian] + +Authors: + Luca Bruno <lucab@debian.org> + Alexander Kurtz <kurtz.alex@googlemail.com> + Daniel Baumann <daniel@debian.org> +Description: + Patch to properly cast and avoiding compiler warnings. Fixes FTBFS on alpha + and ia64 (Closes: #539433, #583768). + +diff -Naurp btrfs-tools.orig/btrfsctl.c btrfs-tools/btrfsctl.c +--- btrfs-tools.orig/btrfsctl.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/btrfsctl.c 2010-06-05 08:44:05.000000000 +0200 +@@ -234,7 +234,7 @@ int main(int ac, char **av) + args.fd = fd; + ret = ioctl(snap_fd, command, &args); + } else if (command == BTRFS_IOC_DEFAULT_SUBVOL) { +- printf("objectid is %llu\n", objectid); ++ printf("objectid is %llu\n", (long long unsigned int) objectid); + ret = ioctl(fd, command, &objectid); + } else + ret = ioctl(fd, command, &args); +diff -Naurp btrfs-tools.orig/btrfs-list.c btrfs-tools/btrfs-list.c +--- btrfs-tools.orig/btrfs-list.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/btrfs-list.c 2010-06-05 08:47:27.000000000 +0200 +@@ -248,8 +248,9 @@ static int resolve_root(struct root_look + break; + } + } +- printf("ID %llu top level %llu path %s\n", ri->root_id, top_id, +- full_path); ++ printf("ID %llu top level %llu path %s\n", ++ (long long unsigned int) ri->root_id, ++ (long long unsigned int) top_id, full_path); + free(full_path); + return 0; + } +diff -Naurp btrfs-tools.orig/btrfs-map-logical.c btrfs-tools/btrfs-map-logical.c +--- btrfs-tools.orig/btrfs-map-logical.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/btrfs-map-logical.c 2010-06-05 08:48:10.000000000 +0200 +@@ -65,8 +65,9 @@ struct extent_buffer *debug_read_block(s + eb->dev_bytenr = multi->stripes[0].physical; + + fprintf(info_file, "mirror %d logical %Lu physical %Lu " +- "device %s\n", mirror_num, bytenr, eb->dev_bytenr, +- device->name); ++ "device %s\n", mirror_num, ++ (long long unsigned int) bytenr, ++ (long long unsigned int) eb->dev_bytenr, device->name); + kfree(multi); + + if (!copy || mirror_num == copy) +diff -Naurp btrfs-tools.orig/convert.c btrfs-tools/convert.c +--- btrfs-tools.orig/convert.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/convert.c 2010-06-05 08:43:29.000000000 +0200 +@@ -2572,7 +2572,7 @@ int do_rollback(const char *devname, int + ext2_root = btrfs_read_fs_root(root->fs_info, &key); + if (!ext2_root || IS_ERR(ext2_root)) { + fprintf(stderr, "unable to open subvol %llu\n", +- key.objectid); ++ (unsigned long long) key.objectid); + goto fail; + } + +diff -Naurp btrfs-tools.orig/debug-tree.c btrfs-tools/debug-tree.c +--- btrfs-tools.orig/debug-tree.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/debug-tree.c 2010-06-05 08:46:17.000000000 +0200 +@@ -162,7 +162,8 @@ int main(int ac, char **av) + root->nodesize, 0); + } + if (!leaf) { +- fprintf(stderr, "failed to read %llu\n", block_only); ++ fprintf(stderr, "failed to read %llu\n", ++ (long long unsigned int) block_only); + return 0; + } + btrfs_print_tree(root, leaf, 0); +diff -Naurp btrfs-tools.orig/disk-io.c btrfs-tools/disk-io.c +--- btrfs-tools.orig/disk-io.c 2010-06-01 07:18:01.000000000 +0200 ++++ btrfs-tools/disk-io.c 2010-06-05 08:43:29.000000000 +0200 +@@ -678,7 +678,8 @@ struct btrfs_root *open_ctree_fd(int fp, + ~BTRFS_FEATURE_INCOMPAT_SUPP; + if (features) { + printk("couldn't open because of unsupported " +- "option features (%Lx).\n", features); ++ "option features (%Lx).\n", ++ (unsigned long long)features); + BUG_ON(1); + } + +@@ -692,7 +693,8 @@ struct btrfs_root *open_ctree_fd(int fp, + ~BTRFS_FEATURE_COMPAT_RO_SUPP; + if (writes && features) { + printk("couldn't open RDWR because of unsupported " +- "option features (%Lx).\n", features); ++ "option features (%Lx).\n", ++ (unsigned long long) features); + BUG_ON(1); + } + +diff -Naurp btrfs-tools.orig/extent-tree.c btrfs-tools/extent-tree.c +--- btrfs-tools.orig/extent-tree.c 2010-06-01 07:18:01.000000000 +0200 ++++ btrfs-tools/extent-tree.c 2010-06-05 08:43:29.000000000 +0200 +@@ -1448,7 +1448,8 @@ int btrfs_lookup_extent_info(struct btrf + goto out; + if (ret != 0) { + btrfs_print_leaf(root, path->nodes[0]); +- printk("failed to find block number %Lu\n", bytenr); ++ printk("failed to find block number %Lu\n", ++ (unsigned long long) bytenr); + BUG(); + } + +diff -Naurp btrfs-tools.orig/print-tree.c btrfs-tools/print-tree.c +--- btrfs-tools.orig/print-tree.c 2010-06-01 07:22:33.000000000 +0200 ++++ btrfs-tools/print-tree.c 2010-06-05 08:43:29.000000000 +0200 +@@ -494,7 +494,7 @@ void btrfs_print_leaf(struct btrfs_root + case BTRFS_DIR_LOG_ITEM_KEY: + dlog = btrfs_item_ptr(l, i, struct btrfs_dir_log_item); + printf("\t\tdir log end %Lu\n", +- btrfs_dir_log_end(l, dlog)); ++ (unsigned long long) btrfs_dir_log_end(l, dlog)); + break; + case BTRFS_ORPHAN_ITEM_KEY: + printf("\t\torphan item\n"); diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/03-glibc.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/03-glibc.patch new file mode 100644 index 0000000000..dc26148f17 --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/03-glibc.patch @@ -0,0 +1,16 @@ +Upstream-Status: Inappropriate [distribution: debian] + +Author: Colin Watson <cjwatson@debian.org> +Description: Fixes FTBFS with glibc 2.12 (Closes; #586111). + +diff -Naurp btrfs-tools.orig//btrfsck.c btrfs-tools/btrfsck.c +--- btrfs-tools.orig//btrfsck.c 2010-06-05 09:06:38.000000000 +0200 ++++ btrfs-tools/btrfsck.c 2010-06-16 16:16:10.000000000 +0200 +@@ -21,6 +21,7 @@ + #include <stdio.h> + #include <stdlib.h> + #include <fcntl.h> ++#include <sys/stat.h> + #include "kerncompat.h" + #include "ctree.h" + #include "disk-io.h" diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/fix_use_of_gcc.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/fix_use_of_gcc.patch new file mode 100644 index 0000000000..0a5fb349c0 --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/fix_use_of_gcc.patch @@ -0,0 +1,84 @@ +Nitin A Kamble <nitin.a.kamble@intel.com> 2011/06/09 +UpstreamStatus: Pending + +Avoid these kinds of errors while doing cross build: + +| ccache i586-poky-linux-gcc -march=i586 --sysroot=/disk0/pokybuild/build0/tmp/sysroots/qemux86 -Wp,-MMD,./.btrfsctl.o.d,-MT,btrfsctl.o -Wall -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -pipe -g -feliminate-unused-debug-types -c btrfsctl.c +| gcc -O2 -pipe -g -feliminate-unused-debug-types -o btrfsctl btrfsctl.o ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o root-tree.o dir-item.o file-item.o inode-item.o inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o -Wl,-O1 -Wl,--as-needed -luuid +| /usr/bin/ld: i386 architecture of input file `btrfsctl.o' is incompatible with i386:x86-64 output +| /usr/bin/ld: i386 architecture of input file `ctree.o' is incompatible with i386:x86-64 output + +Index: git/Makefile +=================================================================== +--- git.orig/Makefile ++++ git/Makefile +@@ -38,53 +38,53 @@ version: + bash version.sh + + btrfs: $(objects) btrfs.o btrfs_cmds.o +- gcc $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o \ ++ $(CC) $(CFLAGS) -o btrfs btrfs.o btrfs_cmds.o \ + $(objects) $(LDFLAGS) $(LIBS) + + btrfsctl: $(objects) btrfsctl.o +- gcc $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS) + + btrfs-vol: $(objects) btrfs-vol.o +- gcc $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-vol btrfs-vol.o $(objects) $(LDFLAGS) $(LIBS) + + btrfs-show: $(objects) btrfs-show.o +- gcc $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-show btrfs-show.o $(objects) $(LDFLAGS) $(LIBS) + + btrfsck: $(objects) btrfsck.o +- gcc $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfsck btrfsck.o $(objects) $(LDFLAGS) $(LIBS) + + mkfs.btrfs: $(objects) mkfs.o +- gcc $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) + + btrfs-debug-tree: $(objects) debug-tree.o +- gcc $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-debug-tree $(objects) debug-tree.o $(LDFLAGS) $(LIBS) + + btrfs-zero-log: $(objects) btrfs-zero-log.o +- gcc $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-zero-log $(objects) btrfs-zero-log.o $(LDFLAGS) $(LIBS) + + btrfs-select-super: $(objects) btrfs-select-super.o +- gcc $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-select-super $(objects) btrfs-select-super.o $(LDFLAGS) $(LIBS) + + btrfstune: $(objects) btrfstune.o +- gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) + + btrfs-map-logical: $(objects) btrfs-map-logical.o +- gcc $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-map-logical $(objects) btrfs-map-logical.o $(LDFLAGS) $(LIBS) + + btrfs-image: $(objects) btrfs-image.o +- gcc $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-image $(objects) btrfs-image.o -lpthread -lz $(LDFLAGS) $(LIBS) + + dir-test: $(objects) dir-test.o +- gcc $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS) + + quick-test: $(objects) quick-test.o +- gcc $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS) + + convert: $(objects) convert.o +- gcc $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o btrfs-convert $(objects) convert.o -lext2fs -lcom_err $(LDFLAGS) $(LIBS) + + ioctl-test: $(objects) ioctl-test.o +- gcc $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS) + + manpages: + cd man; make diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch new file mode 100644 index 0000000000..847e870669 --- /dev/null +++ b/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch @@ -0,0 +1,183 @@ +Upstream-Status: Pending
+
+This patch is made by xin.zhong@intel.com to implement these supported
+features in mkfs.btrfs:
+ * populate fs image from a directory while creating it
+ * reduce minimum size of the created image from 256MB to around 24MB
+ * while creating image use the specified device name rather than output.img
+
+Patch tested and incorporated in poky by:
+Nitin A Kamble <nitin.a.kamble@intel.com> 2011/06/20
+
+diff --git a/file-item.c b/file-item.c
+index 9732282..aed42c3 100644
+--- a/file-item.c
++++ b/file-item.c
+@@ -193,7 +193,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, u64 alloc_end,
+ u64 bytenr, char *data, size_t len)
+ {
+- int ret;
++ int ret = 0;
+ struct btrfs_key file_key;
+ struct btrfs_key found_key;
+ u64 next_offset = (u64)-1;
+diff --git a/mkfs.c b/mkfs.c
+index 57c88f9..e953a33 100644
+--- a/mkfs.c
++++ b/mkfs.c
+@@ -36,7 +36,7 @@
+ #include <uuid/uuid.h>
+ #include <linux/fs.h>
+ #include <ctype.h>
+-#include <attr/xattr.h>
++#include <sys/xattr.h>
+ #include "kerncompat.h"
+ #include "ctree.h"
+ #include "disk-io.h"
+@@ -517,7 +517,6 @@ static int add_inode_items(struct btrfs_trans_handle *trans,
+ fail:
+ return ret;
+ }
+-
+ static int add_xattr_item(struct btrfs_trans_handle *trans,
+ struct btrfs_root *root, u64 objectid,
+ const char *file_name)
+@@ -532,8 +531,10 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
+
+ ret = llistxattr(file_name, xattr_list, XATTR_LIST_MAX);
+ if (ret < 0) {
+- fprintf(stderr, "get a list of xattr failed for %s\n",
+- file_name);
++ if(errno == ENOTSUP)
++ return 0;
++ fprintf(stderr, "get a list of xattr failed for %s errno %d\n",
++ file_name, errno);
+ return ret;
+ }
+ if (ret == 0)
+@@ -546,8 +547,11 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
+
+ ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
+ if (ret < 0) {
+- fprintf(stderr, "get a xattr value failed for %s\n",
+- cur_name);
++ if(errno == ENOTSUP)
++ return 0;
++ fprintf(stderr, "get a xattr value failed for %s attr %s errno %d\n",
++ file_name, cur_name, errno);
++ return ret;
+ }
+
+ ret = btrfs_insert_xattr_item(trans, root, cur_name,
+@@ -563,7 +567,6 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
+
+ return ret;
+ }
+-
+ static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
+ u64 hint_byte, struct btrfs_key *ins)
+ {
+@@ -923,27 +926,27 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
+ fprintf(stderr, "add_inode_items failed\n");
+ goto fail;
+ }
+-
+ ret = add_xattr_item(trans, root,
+ cur_inum, cur_file->d_name);
+ if (ret) {
+ fprintf(stderr, "add_xattr_item failed\n");
+- goto fail;
++ if(ret != -ENOTSUP)
++ goto fail;
+ }
+-
+ if (S_ISDIR(st.st_mode)) {
+ dir_entry = malloc(sizeof(struct directory_name_entry));
+ dir_entry->dir_name = cur_file->d_name;
+ dir_entry->path = make_path(parent_dir_entry->path,
+ cur_file->d_name);
+ dir_entry->inum = cur_inum;
+- list_add_tail(&dir_entry->list, &dir_head->list);
++ list_add_tail(&dir_entry->list, &dir_head->list);
+ } else if (S_ISREG(st.st_mode)) {
+ ret = add_file_items(trans, root, &cur_inode,
+ cur_inum, parent_inum, &st,
+ cur_file->d_name, out_fd);
+ if (ret) {
+- fprintf(stderr, "add_file_items failed\n");
++ fprintf(stderr, "add_file_items failed %s\n",
++ cur_file->d_name);
+ goto fail;
+ }
+ } else if (S_ISLNK(st.st_mode)) {
+@@ -987,7 +990,7 @@ static int create_chunks(struct btrfs_trans_handle *trans,
+ u64 chunk_size;
+ u64 meta_type = BTRFS_BLOCK_GROUP_METADATA;
+ u64 data_type = BTRFS_BLOCK_GROUP_DATA;
+- u64 minimum_data_chunk_size = 64 * 1024 * 1024;
++ u64 minimum_data_chunk_size = 8 * 1024 * 1024;
+ u64 i;
+ int ret;
+
+@@ -1062,7 +1065,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
+ char path[512];
+ char *file_name = "temp_file";
+ FILE *file;
+- u64 minimum_data_size = 256 * 1024 * 1024; /* 256MB */
+ u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */
+ u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */
+ u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */
+@@ -1101,9 +1103,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
+
+ *num_of_meta_chunks_ret = num_of_meta_chunks;
+
+- if (total_size < minimum_data_size)
+- total_size = minimum_data_size;
+-
+ return total_size;
+ }
+
+@@ -1158,9 +1157,9 @@ int main(int ac, char **av)
+
+ char *source_dir = NULL;
+ int source_dir_set = 0;
+- char *output = "output.img";
+ u64 num_of_meta_chunks = 0;
+ u64 size_of_data = 0;
++ u64 source_dir_size = 0;
+
+ while(1) {
+ int c;
+@@ -1224,8 +1223,6 @@ int main(int ac, char **av)
+ fprintf(stderr, "Illegal nodesize %u\n", nodesize);
+ exit(1);
+ }
+- if (source_dir_set)
+- ac++;
+ ac = ac - optind;
+ if (ac == 0)
+ print_usage();
+@@ -1257,17 +1254,19 @@ int main(int ac, char **av)
+ block_count = dev_block_count;
+ } else {
+ ac = 0;
+- fd = open_target(output);
++ file = av[optind++];
++ fd = open_target(file);
+ if (fd < 0) {
+ fprintf(stderr, "unable to open the %s\n", file);
+ exit(1);
+ }
+
+- file = output;
+ first_fd = fd;
+ first_file = file;
+- block_count = size_sourcedir(source_dir, sectorsize,
++ source_dir_size = size_sourcedir(source_dir, sectorsize,
+ &num_of_meta_chunks, &size_of_data);
++ if(block_count < source_dir_size)
++ block_count = source_dir_size;
+ ret = zero_output_file(fd, block_count, sectorsize);
+ if (ret) {
+ fprintf(stderr, "unable to zero the output file\n");
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 @@ +Upstream-Status: Inappropriate [Backport] +From a6c54702d8973aef081cff81ed8d90427bb21768 Mon Sep 17 00:00:00 2001 +From: Chris Mason <chris.mason@oracle.com> +Date: Wed, 15 Dec 2010 16:00:23 -0500 +Subject: [PATCH 1/5] Fill missing devices so degraded filesystems can be read + +When a device is missing, the btrfs tools need to be able to read alternate +copies from the remaining devices. This creates placeholder devices +that always return -EIO so the tools can limp along. + +Signed-off-by: Chris Mason <chris.mason@oracle.com> +--- + disk-io.c | 1 + + volumes.c | 15 +++++++++++++-- + 2 files changed, 14 insertions(+), 2 deletions(-) + +diff --git a/disk-io.c b/disk-io.c +index 5bd9cfc..f4368f3 100644 +--- a/disk-io.c ++++ b/disk-io.c +@@ -204,6 +204,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, + eb->dev_bytenr = multi->stripes[0].physical; + kfree(multi); + ret = read_extent_from_disk(eb); ++ + if (ret == 0 && check_tree_block(root, eb) == 0 && + csum_tree_block(root, eb, 1) == 0 && + verify_parent_transid(eb->tree, eb, parent_transid) == 0) { +diff --git a/volumes.c b/volumes.c +index 4bb77e2..5773467 100644 +--- a/volumes.c ++++ b/volumes.c +@@ -1263,6 +1263,16 @@ int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) + return readonly; + } + ++static struct btrfs_device *fill_missing_device(u64 devid) ++{ ++ struct btrfs_device *device; ++ ++ device = kzalloc(sizeof(*device), GFP_NOFS); ++ device->devid = devid; ++ device->fd = -1; ++ return device; ++} ++ + static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, + struct extent_buffer *leaf, + struct btrfs_chunk *chunk) +@@ -1313,8 +1323,9 @@ static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, + map->stripes[i].dev = btrfs_find_device(root, devid, uuid, + NULL); + if (!map->stripes[i].dev) { +- kfree(map); +- return -EIO; ++ map->stripes[i].dev = fill_missing_device(devid); ++ printf("warning, device %llu is missing\n", ++ (unsigned long long)devid); + } + + } +-- +1.7.2.3 + 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 @@ +Upstream-Status: Inappropriate [Backport] +From 454a0538680bc17656cefadef1f167917ea0b856 Mon Sep 17 00:00:00 2001 +From: Chris Mason <chris.mason@oracle.com> +Date: Wed, 15 Dec 2010 16:02:45 -0500 +Subject: [PATCH 2/5] Check for RAID10 in set_avail_alloc_bits + +When raid is setup with mkfs, it is supposed to cow the initial filesystem +it creates up to the desired raid level. RAID10 was not in the list +of RAID levels it checked for, so the initial FS created for RAID10 +actually only lived on the first disk. + +This works well enough because all the roots get quickly cowed during the +first mount. The exception is the data relocation tree, which only gets +cowed when we do a balance. + +Signed-off-by: Chris Mason <chris.mason@oracle.com> +--- + extent-tree.c | 1 + + 1 files changed, 1 insertions(+), 0 deletions(-) + +diff --git a/extent-tree.c b/extent-tree.c +index b2f9bb2..108933f 100644 +--- a/extent-tree.c ++++ b/extent-tree.c +@@ -1775,6 +1775,7 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) + { + u64 extra_flags = flags & (BTRFS_BLOCK_GROUP_RAID0 | + BTRFS_BLOCK_GROUP_RAID1 | ++ BTRFS_BLOCK_GROUP_RAID10 | + BTRFS_BLOCK_GROUP_DUP); + if (extra_flags) { + if (flags & BTRFS_BLOCK_GROUP_DATA) +-- +1.7.2.3 + 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 @@ +Upstream-Status: Inappropriate [Backport] +From d5b8b904ac40e4c5dbff4008accd7e588b697085 Mon Sep 17 00:00:00 2001 +From: Chris Mason <chris.mason@oracle.com> +Date: Wed, 15 Dec 2010 16:03:00 -0500 +Subject: [PATCH 3/5] Print the root generation in btrfs-debug-tree + +Signed-off-by: Chris Mason <chris.mason@oracle.com> +--- + print-tree.c | 5 +++-- + 1 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/print-tree.c b/print-tree.c +index ac575d5..85399aa 100644 +--- a/print-tree.c ++++ b/print-tree.c +@@ -505,11 +505,12 @@ void btrfs_print_leaf(struct btrfs_root *root, struct extent_buffer *l) + case BTRFS_ROOT_ITEM_KEY: + ri = btrfs_item_ptr(l, i, struct btrfs_root_item); + read_extent_buffer(l, &root_item, (unsigned long)ri, sizeof(root_item)); +- printf("\t\troot data bytenr %llu level %d dirid %llu refs %u\n", ++ printf("\t\troot data bytenr %llu level %d dirid %llu refs %u gen %llu\n", + (unsigned long long)btrfs_root_bytenr(&root_item), + btrfs_root_level(&root_item), + (unsigned long long)btrfs_root_dirid(&root_item), +- btrfs_root_refs(&root_item)); ++ btrfs_root_refs(&root_item), ++ (unsigned long long)btrfs_root_generation(&root_item)); + if (btrfs_root_refs(&root_item) == 0) { + struct btrfs_key drop_key; + btrfs_disk_key_to_cpu(&drop_key, +-- +1.7.2.3 + 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 @@ +Upstream-Status: Inappropriate [Backport] +From 238f88bb6c4b9ebad727c6bffb57f542e7e412c1 Mon Sep 17 00:00:00 2001 +From: Chris Mason <chris.mason@oracle.com> +Date: Sun, 19 Dec 2010 16:22:31 -0500 +Subject: [PATCH 4/5] Allow partial FS opens for btrfsck scanning + +Signed-off-by: Chris Mason <chris.mason@oracle.com> +--- + btrfsck.c | 10 ++++++++-- + convert.c | 20 ++++++++++++++------ + disk-io.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- + disk-io.h | 5 +++-- + 4 files changed, 66 insertions(+), 26 deletions(-) + +diff --git a/btrfsck.c b/btrfsck.c +index 63e44d1..f760706 100644 +--- a/btrfsck.c ++++ b/btrfsck.c +@@ -2820,6 +2820,7 @@ int main(int ac, char **av) + { + struct cache_tree root_cache; + struct btrfs_root *root; ++ struct btrfs_fs_info *info; + u64 bytenr = 0; + int ret; + int num; +@@ -2856,11 +2857,16 @@ int main(int ac, char **av) + return -EBUSY; + } + +- root = open_ctree(av[optind], bytenr, 0); ++ info = open_fs_info(av[optind], bytenr, 0, 1); + +- if (root == NULL) ++ if (info == NULL) + return 1; + ++ root = info->fs_root; ++ if (!root) { ++ fprintf(stderr, "failed to read the filesystem\n"); ++ exit(1); ++ } + ret = check_extents(root); + if (ret) + goto out; +diff --git a/convert.c b/convert.c +index fbcf4a3..72e3cdc 100644 +--- a/convert.c ++++ b/convert.c +@@ -2342,6 +2342,7 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) + ext2_filsys ext2_fs; + struct btrfs_root *root; + struct btrfs_root *ext2_root; ++ struct btrfs_fs_info *fs_info; + + ret = open_ext2fs(devname, &ext2_fs); + if (ret) { +@@ -2386,11 +2387,12 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) + fprintf(stderr, "unable to update system chunk\n"); + goto fail; + } +- root = open_ctree_fd(fd, devname, super_bytenr, O_RDWR); +- |
