From 2f7b3710d2879ae55ec7e5d0b11958a29cfe96e5 Mon Sep 17 00:00:00 2001 From: Nitin A Kamble Date: Tue, 15 Nov 2011 17:00:50 -0800 Subject: btrfs-tools: update to the latest git commit Remove all the upstreamed and not needed patches. Signed-off-by: Nitin A Kamble --- .../btrfs-tools/btrfs-tools/debian/01-labels.patch | 29 - .../btrfs-tools/btrfs-tools/debian/02-ftbfs.patch | 125 --- .../btrfs-tools/btrfs-tools/debian/03-glibc.patch | 16 - .../btrfs-tools/btrfs-tools/fix_use_of_gcc.patch | 77 +- .../btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch | 183 ---- ...g-devices-so-degraded-filesystems-can-be-.patch | 64 -- ...-Check-for-RAID10-in-set_avail_alloc_bits.patch | 35 - ...t-the-root-generation-in-btrfs-debug-tree.patch | 33 - ...low-partial-FS-opens-for-btrfsck-scanning.patch | 253 ----- .../0005-Temporary-debugging-for-dragonn.patch | 75 -- ...-add-a-btrfs-select-super-command-to-over.patch | 170 --- ...gs-use-safe-string-manipulation-functions.patch | 152 --- ...0003-Btrfs-progs-utils-Informative-errors.patch | 37 - ...-page-to-new-defragment-command-interface.patch | 99 -- ...prove-error-handling-in-the-btrfs-command.patch | 510 --------- ...progs-update-super-fields-for-space-cache.patch | 57 - ...-add-support-for-mixed-data-metadata-bloc.patch | 403 ------- .../upstream-tmp/0008-Update-for-lzo-support.patch | 203 ---- ...pdate-clean-up-btrfs-help-and-man-page-V2.patch | 272 ----- ...0-Deprecate-btrfsctl-btrfs-show-btrfs-vol.patch | 152 --- ...11-Add-the-btrfs-filesystem-label-command.patch | 390 ------- ...-Update-man-page-for-mixed-data-metadata-.patch | 42 - ...-Add-new-feature-to-mkfs.btrfs-to-make-fi.patch | 1108 -------------------- ...-fix-wrong-extent-buffer-size-when-readin.patch | 33 - ...5-btrfs-progs-add-discard-support-to-mkfs.patch | 110 -- .../btrfs-tools/btrfs-tools_git.bb | 32 +- 26 files changed, 16 insertions(+), 4644 deletions(-) delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/01-labels.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/02-ftbfs.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/03-glibc.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0002-Btrfs-progs-use-safe-string-manipulation-functions.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0003-Btrfs-progs-utils-Informative-errors.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0004-update-man-page-to-new-defragment-command-interface.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0006-Btrfs-progs-update-super-fields-for-space-cache.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0007-Btrfs-progs-add-support-for-mixed-data-metadata-bloc.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0008-Update-for-lzo-support.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0009-Update-clean-up-btrfs-help-and-man-page-V2.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0010-Deprecate-btrfsctl-btrfs-show-btrfs-vol.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0011-Add-the-btrfs-filesystem-label-command.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0012-Btrfs-progs-Update-man-page-for-mixed-data-metadata-.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0013-btrfs-progs-Add-new-feature-to-mkfs.btrfs-to-make-fi.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0014-btrfs-progs-fix-wrong-extent-buffer-size-when-readin.patch delete mode 100644 meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0015-btrfs-progs-add-discard-support-to-mkfs.patch 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 deleted file mode 100644 index b15a1c98ed..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/01-labels.patch +++ /dev/null @@ -1,29 +0,0 @@ -Upstream-Status: Inappropriate [distribution: debian] - -Author: Chris Mason -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 deleted file mode 100644 index 7b47190757..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/02-ftbfs.patch +++ /dev/null @@ -1,125 +0,0 @@ -Upstream-Status: Inappropriate [distribution: debian] - -Authors: - Luca Bruno - Alexander Kurtz - Daniel Baumann -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 deleted file mode 100644 index dc26148f17..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/debian/03-glibc.patch +++ /dev/null @@ -1,16 +0,0 @@ -Upstream-Status: Inappropriate [distribution: debian] - -Author: Colin Watson -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 - #include - #include -+#include - #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 index 2d5315f140..7f6594a343 100644 --- 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 @@ -12,73 +12,20 @@ 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 \ +@@ -41,13 +41,13 @@ btrfs: $(objects) btrfs.o btrfs_cmds.o s $(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) + calc-size: $(objects) calc-size.o +- gcc $(CFLAGS) -o calc-size calc-size.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o calc-size calc-size.o $(objects) $(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) + find-root: $(objects) find-root.o +- gcc $(CFLAGS) -o find-root find-root.o $(objects) $(LDFLAGS) $(LIBS) ++ $(CC) $(CFLAGS) -o find-root find-root.o $(objects) $(LDFLAGS) $(LIBS) - btrfstune: $(objects) btrfstune.o -- gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) -+ $(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) + restore: $(objects) restore.o +- gcc $(CFLAGS) -o restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_LIBS) ++ $(CC) $(CFLAGS) -o restore restore.o $(objects) $(LDFLAGS) $(LIBS) $(RESTORE_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 + btrfsctl: $(objects) btrfsctl.o + $(CC) $(CFLAGS) -o btrfsctl btrfsctl.o $(objects) $(LDFLAGS) $(LIBS) 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 deleted file mode 100644 index 847e870669..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/mkfs-xin-fixes.patch +++ /dev/null @@ -1,183 +0,0 @@ -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 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 - #include - #include --#include -+#include - #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 deleted file mode 100644 index e4665335ee..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0001-Fill-missing-devices-so-degraded-filesystems-can-be-.patch +++ /dev/null @@ -1,64 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From a6c54702d8973aef081cff81ed8d90427bb21768 Mon Sep 17 00:00:00 2001 -From: Chris Mason -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 ---- - 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 deleted file mode 100644 index c8557f7863..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0002-Check-for-RAID10-in-set_avail_alloc_bits.patch +++ /dev/null @@ -1,35 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From 454a0538680bc17656cefadef1f167917ea0b856 Mon Sep 17 00:00:00 2001 -From: Chris Mason -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 ---- - 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 deleted file mode 100644 index ad416208b2..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0003-Print-the-root-generation-in-btrfs-debug-tree.patch +++ /dev/null @@ -1,33 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From d5b8b904ac40e4c5dbff4008accd7e588b697085 Mon Sep 17 00:00:00 2001 -From: Chris Mason -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 ---- - 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 deleted file mode 100644 index cf8700723f..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0004-Allow-partial-FS-opens-for-btrfsck-scanning.patch +++ /dev/null @@ -1,253 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From 238f88bb6c4b9ebad727c6bffb57f542e7e412c1 Mon Sep 17 00:00:00 2001 -From: Chris Mason -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 ---- - 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); -- if (!root) { -+ fs_info = open_ctree_fd(fd, devname, super_bytenr, O_RDWR, 0); -+ if (!fs_info) { - fprintf(stderr, "unable to open ctree\n"); - goto fail; - } -+ root = fs_info->fs_root; - ret = cache_free_extents(root, ext2_fs); - if (ret) { - fprintf(stderr, "error during cache_free_extents %d\n", ret); -@@ -2447,11 +2449,13 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) - goto fail; - } - -- root = open_ctree_fd(fd, devname, 0, O_RDWR); -- if (!root) { -+ fs_info = open_ctree_fd(fd, devname, 0, O_RDWR, 0); -+ if (!fs_info) { - fprintf(stderr, "unable to open ctree\n"); - goto fail; - } -+ root = fs_info->fs_root; -+ - /* move chunk tree into system chunk. */ - ret = fixup_chunk_mapping(root); - if (ret) { -@@ -2525,6 +2529,7 @@ int do_rollback(const char *devname, int force) - struct btrfs_key key; - struct btrfs_path path; - struct extent_io_tree io_tree; -+ struct btrfs_fs_info *fs_info; - char *buf; - char *name; - u64 bytenr; -@@ -2546,11 +2551,14 @@ int do_rollback(const char *devname, int force) - fprintf(stderr, "unable to open %s\n", devname); - goto fail; - } -- root = open_ctree_fd(fd, devname, 0, O_RDWR); -- if (!root) { -+ -+ fs_info = open_ctree_fd(fd, devname, 0, O_RDWR, 0); -+ if (!fs_info) { - fprintf(stderr, "unable to open ctree\n"); - goto fail; - } -+ root = fs_info->fs_root; -+ - ret = may_rollback(root); - if (ret < 0) { - fprintf(stderr, "unable to do rollback\n"); -diff --git a/disk-io.c b/disk-io.c -index f4368f3..dc100b0 100644 ---- a/disk-io.c -+++ b/disk-io.c -@@ -441,7 +441,8 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root, - btrfs_super_generation(disk_super) + 1); - - fs_info->log_root_tree = log_root; -- BUG_ON(!log_root->node); -+ if (!log_root->node) -+ return -EIO; - return 0; - } - -@@ -571,10 +572,11 @@ struct btrfs_root *btrfs_read_fs_root(struct btrfs_fs_info *fs_info, - return root; - } - --struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes) -+struct btrfs_fs_info *open_fs_info(const char *filename, u64 sb_bytenr, -+ int writes, int partial) - { - int fp; -- struct btrfs_root *root; -+ struct btrfs_fs_info *fs_info; - int flags = O_CREAT | O_RDWR; - - if (!writes) -@@ -585,14 +587,25 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes) - fprintf (stderr, "Could not open %s\n", filename); - return NULL; - } -- root = open_ctree_fd(fp, filename, sb_bytenr, writes); -+ fs_info = open_ctree_fd(fp, filename, sb_bytenr, writes, partial); -+ - close(fp); -+ return fs_info; -+} - -- return root; -+ -+struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes) -+{ -+ struct btrfs_fs_info *fs_info; -+ -+ fs_info = open_fs_info(filename, sb_bytenr, writes, 0); -+ if (fs_info) -+ return fs_info->fs_root; -+ return NULL; - } - --struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, -- int writes) -+struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, -+ int writes, int partial) - { - u32 sectorsize; - u32 nodesize; -@@ -727,7 +740,8 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - - if (!(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_METADUMP)) { - ret = btrfs_read_chunk_tree(chunk_root); -- BUG_ON(ret); -+ if (ret) -+ goto fail; - } - - blocksize = btrfs_level_size(tree_root, -@@ -737,25 +751,32 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - tree_root->node = read_tree_block(tree_root, - btrfs_super_root(disk_super), - blocksize, generation); -- BUG_ON(!tree_root->node); -+ if (!tree_root->node) -+ goto fail; -+ - ret = find_and_setup_root(tree_root, fs_info, - BTRFS_EXTENT_TREE_OBJECTID, extent_root); -- BUG_ON(ret); -+ if (ret) -+ goto fail; -+ - extent_root->track_dirty = 1; - - ret = find_and_setup_root(tree_root, fs_info, - BTRFS_DEV_TREE_OBJECTID, dev_root); -- BUG_ON(ret); -+ if (ret) -+ goto fail; -+ - dev_root->track_dirty = 1; - - ret = find_and_setup_root(tree_root, fs_info, - BTRFS_CSUM_TREE_OBJECTID, csum_root); -- BUG_ON(ret); -+ if (ret) -+ goto fail; - csum_root->track_dirty = 1; - -- BUG_ON(ret); -- -- find_and_setup_log_root(tree_root, fs_info, disk_super); -+ ret = find_and_setup_log_root(tree_root, fs_info, disk_super); -+ if (ret) -+ goto fail; - - fs_info->generation = generation + 1; - btrfs_read_block_groups(fs_info->tree_root); -@@ -769,7 +790,11 @@ struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - fs_info->metadata_alloc_profile = (u64)-1; - fs_info->system_alloc_profile = fs_info->metadata_alloc_profile; - -- return fs_info->fs_root; -+ return fs_info; -+fail: -+ if (partial) -+ return fs_info; -+ return NULL; - } - - int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr) -diff --git a/disk-io.h b/disk-io.h -index 7ebec24..03c5eee 100644 ---- a/disk-io.h -+++ b/disk-io.h -@@ -44,8 +44,9 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, - int clean_tree_block(struct btrfs_trans_handle *trans, - struct btrfs_root *root, struct extent_buffer *buf); - struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes); --struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, -- int writes); -+struct btrfs_fs_info *open_fs_info(const char *filename, u64 sb_bytenr, int writes, int partial); -+struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, -+ int writes, int partial); - int close_ctree(struct btrfs_root *root); - int write_all_supers(struct btrfs_root *root); - int write_ctree_super(struct btrfs_trans_handle *trans, --- -1.7.2.3 - 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 deleted file mode 100644 index 54123f729d..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-for-dragonn/0005-Temporary-debugging-for-dragonn.patch +++ /dev/null @@ -1,75 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From e3064e90cfd0be823b2da3edff64f97756fcc245 Mon Sep 17 00:00:00 2001 -From: Chris Mason -Date: Mon, 25 Apr 2011 16:31:40 -0400 -Subject: [PATCH 5/5] Temporary debugging for dragonn - -Signed-off-by: Chris Mason ---- - btrfsck.c | 3 +++ - disk-io.c | 16 ++++++++-------- - 2 files changed, 11 insertions(+), 8 deletions(-) - -diff --git a/btrfsck.c b/btrfsck.c -index f760706..cb3dee0 100644 ---- a/btrfsck.c -+++ b/btrfsck.c -@@ -855,6 +855,7 @@ static u64 count_csum_range(struct btrfs_root *root, u64 start, u64 len) - u64 csum_end; - u16 csum_size = btrfs_super_csum_size(&root->fs_info->super_copy); - -+ return 0; - btrfs_init_path(&path); - - key.objectid = BTRFS_EXTENT_CSUM_OBJECTID; -@@ -2666,6 +2667,8 @@ static int add_root_to_pending(struct extent_buffer *buf, - struct cache_tree *nodes, - struct btrfs_key *root_key) - { -+ if (root_key->objectid == 7) -+ return 0; - if (btrfs_header_level(buf) > 0) - add_pending(nodes, seen, buf->start, buf->len); - else -diff --git a/disk-io.c b/disk-io.c -index dc100b0..c242364 100644 ---- a/disk-io.c -+++ b/disk-io.c -@@ -614,12 +614,12 @@ struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - u32 stripesize; - u64 generation; - struct btrfs_key key; -- struct btrfs_root *tree_root = malloc(sizeof(struct btrfs_root)); -- struct btrfs_root *extent_root = malloc(sizeof(struct btrfs_root)); -- struct btrfs_root *chunk_root = malloc(sizeof(struct btrfs_root)); -- struct btrfs_root *dev_root = malloc(sizeof(struct btrfs_root)); -- struct btrfs_root *csum_root = malloc(sizeof(struct btrfs_root)); -- struct btrfs_fs_info *fs_info = malloc(sizeof(*fs_info)); -+ struct btrfs_root *tree_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS); -+ struct btrfs_root *extent_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS); -+ struct btrfs_root *chunk_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS); -+ struct btrfs_root *dev_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS); -+ struct btrfs_root *csum_root = kzalloc(sizeof(struct btrfs_root), GFP_NOFS); -+ struct btrfs_fs_info *fs_info = kzalloc(sizeof(*fs_info), GFP_NOFS); - int ret; - struct btrfs_super_block *disk_super; - struct btrfs_fs_devices *fs_devices = NULL; -@@ -767,13 +767,13 @@ struct btrfs_fs_info *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - goto fail; - - dev_root->track_dirty = 1; -- -+#if 0 - ret = find_and_setup_root(tree_root, fs_info, - BTRFS_CSUM_TREE_OBJECTID, csum_root); - if (ret) - goto fail; - csum_root->track_dirty = 1; -- -+#endif - ret = find_and_setup_log_root(tree_root, fs_info, disk_super); - if (ret) - goto fail; --- -1.7.2.3 - diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch deleted file mode 100644 index 2102f08e96..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch +++ /dev/null @@ -1,170 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From 70c6c10134b502fa69955746554031939b85fb0c Mon Sep 17 00:00:00 2001 -From: Chris Mason -Date: Thu, 9 Dec 2010 16:36:29 -0500 -Subject: [PATCH 01/15] Btrfs-progs: add a btrfs-select-super command to overwrite the super - -Btrfs stores multiple copies of the superblock, and for common power-failure -crashes where barriers were not in use, one of the super copies is often -valid while the first copy is not. - -This adds a btrfs-select-super -s N /dev/xxx command, which can -overwrite all the super blocks with a copy that you have already -determined is valid with btrfsck -s - -Signed-off-by: Chris Mason ---- - Makefile | 3 ++ - btrfs-select-super.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ - disk-io.c | 2 +- - disk-io.h | 1 + - 4 files changed, 104 insertions(+), 1 deletions(-) - create mode 100644 btrfs-select-super.c - -diff --git a/Makefile b/Makefile -index 6e6f6c6..d65f6a2 100644 ---- a/Makefile -+++ b/Makefile -@@ -62,6 +62,9 @@ btrfs-debug-tree: $(objects) debug-tree.o - btrfs-zero-log: $(objects) btrfs-zero-log.o - gcc $(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) -+ - btrfstune: $(objects) btrfstune.o - gcc $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS) - -diff --git a/btrfs-select-super.c b/btrfs-select-super.c -new file mode 100644 -index 0000000..f12f36c ---- /dev/null -+++ b/btrfs-select-super.c -@@ -0,0 +1,99 @@ -+/* -+ * Copyright (C) 2007 Oracle. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public -+ * License v2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public -+ * License along with this program; if not, write to the -+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -+ * Boston, MA 021110-1307, USA. -+ */ -+ -+#define _XOPEN_SOURCE 500 -+#define _GNU_SOURCE 1 -+#include -+#include -+#include -+#include -+#include -+#include "kerncompat.h" -+#include "ctree.h" -+#include "disk-io.h" -+#include "print-tree.h" -+#include "transaction.h" -+#include "list.h" -+#include "version.h" -+#include "utils.h" -+ -+static void print_usage(void) -+{ -+ fprintf(stderr, "usage: btrfs-select-super -s number dev\n"); -+ fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION); -+ exit(1); -+} -+ -+int main(int ac, char **av) -+{ -+ struct btrfs_root *root; -+ int ret; -+ int num; -+ u64 bytenr = 0; -+ -+ while(1) { -+ int c; -+ c = getopt(ac, av, "s:"); -+ if (c < 0) -+ break; -+ switch(c) { -+ case 's': -+ num = atol(optarg); -+ bytenr = btrfs_sb_offset(num); -+ printf("using SB copy %d, bytenr %llu\n", num, -+ (unsigned long long)bytenr); -+ break; -+ default: -+ print_usage(); -+ } -+ } -+ ac = ac - optind; -+ -+ if (ac != 1) -+ print_usage(); -+ -+ if (bytenr == 0) { -+ fprintf(stderr, "Please select the super copy with -s\n"); -+ print_usage(); -+ } -+ -+ radix_tree_init(); -+ -+ if((ret = check_mounted(av[optind])) < 0) { -+ fprintf(stderr, "Could not check mount status: %s\n", strerror(ret)); -+ return ret; -+ } else if(ret) { -+ fprintf(stderr, "%s is currently mounted. Aborting.\n", av[optind]); -+ return -EBUSY; -+ } -+ -+ root = open_ctree(av[optind], bytenr, 1); -+ -+ if (root == NULL) -+ return 1; -+ -+ /* make the super writing code think we've read the first super */ -+ root->fs_info->super_bytenr = BTRFS_SUPER_INFO_OFFSET; -+ ret = write_all_supers(root); -+ -+ /* we don't close the ctree or anything, because we don't want a real -+ * transaction commit. We just want the super copy we pulled off the -+ * disk to overwrite all the other copies -+ */ -+ return ret; -+} -diff --git a/disk-io.c b/disk-io.c -index a6e1000..5bd9cfc 100644 ---- a/disk-io.c -+++ b/disk-io.c -@@ -828,7 +828,7 @@ int write_dev_supers(struct btrfs_root *root, struct btrfs_super_block *sb, - - if (root->fs_info->super_bytenr != BTRFS_SUPER_INFO_OFFSET) { - btrfs_set_super_bytenr(sb, root->fs_info->super_bytenr); -- -+printk("speiiiiiiiiiiiiiiiiiiiiiiiiiiiii\n"); - crc = ~(u32)0; - crc = btrfs_csum_data(NULL, (char *)sb + BTRFS_CSUM_SIZE, crc, - BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); -diff --git a/disk-io.h b/disk-io.h -index 49e5692..7ebec24 100644 ---- a/disk-io.h -+++ b/disk-io.h -@@ -47,6 +47,7 @@ struct btrfs_root *open_ctree(const char *filename, u64 sb_bytenr, int writes); - struct btrfs_root *open_ctree_fd(int fp, const char *path, u64 sb_bytenr, - int writes); - int close_ctree(struct btrfs_root *root); -+int write_all_supers(struct btrfs_root *root); - int write_ctree_super(struct btrfs_trans_handle *trans, - struct btrfs_root *root); - int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr); --- -1.7.2.3 - diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0002-Btrfs-progs-use-safe-string-manipulation-functions.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0002-Btrfs-progs-use-safe-string-manipulation-functions.patch deleted file mode 100644 index 67739be2f4..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0002-Btrfs-progs-use-safe-string-manipulation-functions.patch +++ /dev/null @@ -1,152 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From 2636bf1da17720fc99b14cf4db33f1d1a4c9e0ee Mon Sep 17 00:00:00 2001 -From: Eduardo Silva -Date: Mon, 7 Feb 2011 08:55:04 -0300 -Subject: [PATCH 02/15] Btrfs-progs use safe string manipulation functions - -Signed-off-by: Eduardo Silva -Signed-off-by: Chris Mason ---- - btrfs_cmds.c | 14 +++++++------- - btrfsctl.c | 2 +- - convert.c | 2 +- - utils.c | 9 +++++---- - 4 files changed, 14 insertions(+), 13 deletions(-) - -diff --git a/btrfs_cmds.c b/btrfs_cmds.c -index 8031c58..fffb423 100644 ---- a/btrfs_cmds.c -+++ b/btrfs_cmds.c -@@ -375,7 +375,7 @@ int do_clone(int argc, char **argv) - printf("Create a snapshot of '%s' in '%s/%s'\n", - subvol, dstdir, newname); - args.fd = fd; -- strcpy(args.name, newname); -+ strncpy(args.name, newname, BTRFS_PATH_NAME_MAX); - res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args); - - close(fd); -@@ -436,7 +436,7 @@ int do_delete_subvolume(int argc, char **argv) - } - - printf("Delete subvolume '%s/%s'\n", dname, vname); -- strcpy(args.name, vname); -+ strncpy(args.name, vname, BTRFS_PATH_NAME_MAX); - res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args); - - close(fd); -@@ -490,7 +490,7 @@ int do_create_subvol(int argc, char **argv) - } - - printf("Create subvolume '%s/%s'\n", dstdir, newname); -- strcpy(args.name, newname); -+ strncpy(args.name, newname, BTRFS_PATH_NAME_MAX); - res = ioctl(fddst, BTRFS_IOC_SUBVOL_CREATE, &args); - - close(fddst); -@@ -553,7 +553,7 @@ int do_scan(int argc, char **argv) - - printf("Scanning for Btrfs filesystems in '%s'\n", argv[i]); - -- strcpy(args.name, argv[i]); -+ strncpy(args.name, argv[i], BTRFS_PATH_NAME_MAX); - /* - * FIXME: which are the error code returned by this ioctl ? - * it seems that is impossible to understand if there no is -@@ -593,7 +593,7 @@ int do_resize(int argc, char **argv) - } - - printf("Resize '%s' of '%s'\n", path, amount); -- strcpy(args.name, amount); -+ strncpy(args.name, amount, BTRFS_PATH_NAME_MAX); - res = ioctl(fd, BTRFS_IOC_RESIZE, &args); - close(fd); - if( res < 0 ){ -@@ -736,7 +736,7 @@ int do_add_volume(int nargs, char **args) - } - close(devfd); - -- strcpy(ioctl_args.name, args[i]); -+ strncpy(ioctl_args.name, args[i], BTRFS_PATH_NAME_MAX); - res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args); - if(res<0){ - fprintf(stderr, "ERROR: error adding the device '%s'\n", args[i]); -@@ -792,7 +792,7 @@ int do_remove_volume(int nargs, char **args) - struct btrfs_ioctl_vol_args arg; - int res; - -- strcpy(arg.name, args[i]); -+ strncpy(arg.name, args[i], BTRFS_PATH_NAME_MAX); - res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg); - if(res<0){ - fprintf(stderr, "ERROR: error removing the device '%s'\n", args[i]); -diff --git a/btrfsctl.c b/btrfsctl.c -index 92bdf39..adfa519 100644 ---- a/btrfsctl.c -+++ b/btrfsctl.c -@@ -237,7 +237,7 @@ int main(int ac, char **av) - } - - if (name) -- strcpy(args.name, name); -+ strncpy(args.name, name, BTRFS_PATH_NAME_MAX + 1); - else - args.name[0] = '\0'; - -diff --git a/convert.c b/convert.c -index d037c98..fbcf4a3 100644 ---- a/convert.c -+++ b/convert.c -@@ -857,7 +857,7 @@ static int copy_single_xattr(struct btrfs_trans_handle *trans, - data = databuf; - datalen = bufsize; - } -- strcpy(namebuf, xattr_prefix_table[name_index]); -+ strncpy(namebuf, xattr_prefix_table[name_index], XATTR_NAME_MAX); - strncat(namebuf, EXT2_EXT_ATTR_NAME(entry), entry->e_name_len); - if (name_len + datalen > BTRFS_LEAF_DATA_SIZE(root) - - sizeof(struct btrfs_item) - sizeof(struct btrfs_dir_item)) { -diff --git a/utils.c b/utils.c -index fd894f3..96ef94d 100644 ---- a/utils.c -+++ b/utils.c -@@ -108,7 +108,7 @@ int make_btrfs(int fd, const char *device, const char *label, - btrfs_set_super_csum_type(&super, BTRFS_CSUM_TYPE_CRC32); - btrfs_set_super_chunk_root_generation(&super, 1); - if (label) -- strcpy(super.label, label); -+ strncpy(super.label, label, BTRFS_LABEL_SIZE - 1); - - buf = malloc(sizeof(*buf) + max(sectorsize, leafsize)); - -@@ -828,7 +828,7 @@ void btrfs_register_one_device(char *fname) - "skipping device registration\n"); - return; - } -- strcpy(args.name, fname); -+ strncpy(args.name, fname, BTRFS_PATH_NAME_MAX); - ret = ioctl(fd, BTRFS_IOC_SCAN_DEV, &args); - close(fd); - } -@@ -971,6 +971,7 @@ static char *size_strs[] = { "", "KB", "MB", "GB", "TB", - char *pretty_sizes(u64 size) - { - int num_divs = 0; -+ int pretty_len = 16; - u64 last_size = size; - u64 fract_size = size; - float fraction; -@@ -988,8 +989,8 @@ char *pretty_sizes(u64 size) - return NULL; - - fraction = (float)fract_size / 1024; -- pretty = malloc(16); -- sprintf(pretty, "%.2f%s", fraction, size_strs[num_divs-1]); -+ pretty = malloc(pretty_len); -+ snprintf(pretty, pretty_len, "%.2f%s", fraction, size_strs[num_divs-1]); - return pretty; - } - --- -1.7.2.3 - diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0003-Btrfs-progs-utils-Informative-errors.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0003-Btrfs-progs-utils-Informative-errors.patch deleted file mode 100644 index afc810573f..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0003-Btrfs-progs-utils-Informative-errors.patch +++ /dev/null @@ -1,37 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From ac1a80f52434d05230f9933d8f68e28cc09e10b0 Mon Sep 17 00:00:00 2001 -From: Goldwyn Rodrigues -Date: Mon, 7 Feb 2011 07:34:36 +0000 -Subject: [PATCH 03/15] Btrfs-progs utils Informative errors - -Signed-off-by: Chris Mason ---- - utils.c | 5 +++-- - 1 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/utils.c b/utils.c -index 96ef94d..d8c3dcc 100644 ---- a/utils.c -+++ b/utils.c -@@ -867,7 +867,7 @@ again: - } - dirp = opendir(dirname); - if (!dirp) { -- fprintf(stderr, "Unable to open /sys/block for scanning\n"); -+ fprintf(stderr, "Unable to open %s for scanning\n", dirname); - return -ENOENT; - } - while(1) { -@@ -902,7 +902,8 @@ again: - } - fd = open(fullpath, O_RDONLY); - if (fd < 0) { -- fprintf(stderr, "failed to read %s\n", fullpath); -+ fprintf(stderr, "failed to read %s: %s\n", fullpath, -+ strerror(errno)); - continue; - } - ret = btrfs_scan_one_device(fd, fullpath, &tmp_devices, --- -1.7.2.3 - diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0004-update-man-page-to-new-defragment-command-interface.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0004-update-man-page-to-new-defragment-command-interface.patch deleted file mode 100644 index 4080a75d75..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0004-update-man-page-to-new-defragment-command-interface.patch +++ /dev/null @@ -1,99 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From 0a63a11c3d3bbb7e061daad28435b5eef91a947d Mon Sep 17 00:00:00 2001 -From: Hubert Kario -Date: Sun, 23 Jan 2011 15:31:07 +0000 -Subject: [PATCH 04/15] update man page to new defragment command interface - -Update - - btrfs filesystem defragment - -command explanation. Add explanation of advanced parameters and notes -about general usage. - -Add few notes about the - - btrfs --help - -usage, fix related grammar. - -Signed-off-by: Hubert Kario -Signed-off-by: Chris Mason ---- - man/btrfs.8.in | 33 ++++++++++++++++++++++++++------- - 1 files changed, 26 insertions(+), 7 deletions(-) - -diff --git a/man/btrfs.8.in b/man/btrfs.8.in -index 26ef982..cba2de1 100644 ---- a/man/btrfs.8.in -+++ b/man/btrfs.8.in -@@ -15,7 +15,7 @@ btrfs \- control a btrfs filesystem - .PP - \fBbtrfs\fP \fBsubvolume set-default\fP\fI \fP - .PP --\fBbtrfs\fP \fBfilesystem defrag\fP\fI | [|...]\fP -+\fBbtrfs\fP \fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] | [|...]\fP - .PP - \fBbtrfs\fP \fBfilesystem sync\fP\fI \fP - .PP -@@ -34,6 +34,8 @@ btrfs \- control a btrfs filesystem - .PP - \fBbtrfs\fP \fBhelp|\-\-help|\-h \fP\fI\fP - .PP -+\fBbtrfs\fP \fB \-\-help \fP\fI\fP -+.PP - .SH DESCRIPTION - .B btrfs - is used to control the filesystem and the files and directories stored. It is -@@ -60,12 +62,12 @@ returns an error. - - If a command is terminated by - .I --help --, the relevant help is showed. If the passed command matches more commands, --the help of all the matched commands are showed. For example -+, the detailed help is showed. If the passed command matches more commands, -+detailed help of all the matched commands is showed. For example - .I btrfs dev --help - shows the help of all - .I device* --command. -+commands. - - .SH COMMANDS - .TP -@@ -98,12 +100,29 @@ mount time via the \fIsubvol=\fR option. - - \fBsubvolume set-default\fR\fI \fR - Set the subvolume of the filesystem \fI\fR which is mounted as --\fIdefault\fR. The subvolume is identified by \fB\fR, which -+\fIdefault\fR. The subvolume is identified by \fI\fR, which - is returned by the \fBsubvolume list\fR command. - .TP - --\fBfilesystem defragment\fP\fI | [|...]\fR --Defragment files and/or directories. -+\fBfilesystem defragment\fP\fI [-vcf] [-s start] [-l len] [-t size] | [|...]\fR -+Defragment file data and/or directory metadata. To defragment all files in a -+directory you have to specify each one on its own or use your shell wildcards. -+ -+\fB-v\fP be verbose -+ -+\fB-c\fP compress file contents while defragmenting -+ -+\fB-f\fP flush filesystem after defragmenting -+ -+\fB-s start\fP defragment only from byte \fIstart\fR onward -+ -+\fB-l len\fP defragment only up to \fIlen\fR bytes -+ -+\fB-t size\fP defragment only files at least \fIsize\fR bytes big -+ -+NOTE: defragmenting with kernels up to 2.6.37 will unlink COW-ed copies of data, don't -+use it if you use snapshots, have de-duplicated your data or made copies with -+\fBcp --reflink\fP. - .TP - - \fBdevice scan\fR \fI[ [..]]\fR --- -1.7.2.3 - diff --git a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch b/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch deleted file mode 100644 index e7e3fae332..0000000000 --- a/meta/recipes-devtools/btrfs-tools/btrfs-tools/upstream-tmp/0005-Improve-error-handling-in-the-btrfs-command.patch +++ /dev/null @@ -1,510 +0,0 @@ -Upstream-Status: Inappropriate [Backport] -From b3007332100e01ca84c161b6c75f0a414ab4611b Mon Sep 17 00:00:00 2001 -From: Goffredo Baroncelli -Date: Mon, 20 Dec 2010 20:06:19 +0000 -Subject: [PATCH 05/15] Improve error handling in the btrfs command - -Hi Chris, - -below is enclosed a trivial patch, which has the aim to improve the error -reporting of the "btrfs" command. - -You can pull from - - http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git - -branch - - strerror - -I changed every printf("some-error") to something like: - - e = errno; - fprintf(stderr, "ERROR: .... - %s", strerror(e)); - -so: - -1) all the error are reported to standard error -2) At the end of the message is printed the error as returned by the system. - -The change is quite simple, I replaced every printf("some-error") to the line -above. I don't touched anything other. -I also integrated a missing "printf" on the basis of the Ben patch. - -This patch leads the btrfs command to be more "user friendly" :-) - -Regards -G.Baroncelli - - btrfs-list.c | 40 ++++++++++++++++++++++-------- - btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- - utils.c | 6 ++++ - 3 files changed, 89 insertions(+), 34 deletions(-) - -Signed-off-by: Chris Mason ---- - btrfs-list.c | 40 ++++++++++++++++++++++-------- - btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- - utils.c | 6 ++++ - 3 files changed, 89 insertions(+), 34 deletions(-) - -diff --git a/btrfs-list.c b/btrfs-list.c -index 93766a8..abcc2f4 100644 ---- a/btrfs-list.c -+++ b/btrfs-list.c -@@ -265,7 +265,7 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri) - static int lookup_ino_path(int fd, struct root_info *ri) - { - struct btrfs_ioctl_ino_lookup_args args; -- int ret; -+ int ret, e; - - if (ri->path) - return 0; -@@ -275,9 +275,11 @@ static int lookup_ino_path(int fd, struct root_info *ri) - args.objectid = ri->dir_id; - - ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); -+ e = errno; - if (ret) { -- fprintf(stderr, "ERROR: Failed to lookup path for root %llu\n", -- (unsigned long long)ri->ref_tree); -+ fprintf(stderr, "ERROR: Failed to lookup path for root %llu - %s\n", -+ (unsigned long long)ri->ref_tree, -+ strerror(e)); - return ret; - } - -@@ -320,15 +322,18 @@ static u64 find_root_gen(int fd) - unsigned long off = 0; - u64 max_found = 0; - int i; -+ int e; - - memset(&ino_args, 0, sizeof(ino_args)); - ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID; - - /* this ioctl fills in ino_args->treeid */ - ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args); -+ e = errno; - if (ret) { -- fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n", -- (unsigned long long)BTRFS_FIRST_FREE_OBJECTID); -+ fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", -+ (unsigned long long)BTRFS_FIRST_FREE_OBJECTID, -+ strerror(e)); - return 0; - } - -@@ -351,8 +356,10 @@ static u64 find_root_gen(int fd) - - while (1) { - ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); -+ e = errno; - if (ret < 0) { -- fprintf(stderr, "ERROR: can't perform the search\n"); -+ fprintf(stderr, "ERROR: can't perform the search - %s\n", -+ strerror(e)); - return 0; - } - /* the ioctl returns the number of item it found in nr_items */ -@@ -407,14 +414,16 @@ static char *__ino_resolve(int fd, u64 dirid) - struct btrfs_ioctl_ino_lookup_args args; - int ret; - char *full; -+ int e; - - memset(&args, 0, sizeof(args)); - args.objectid = dirid; - - ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); -+ e = errno; - if (ret) { -- fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu\n", -- (unsigned long long)dirid); -+ fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", -+ (unsigned long long)dirid, strerror(e) ); - return ERR_PTR(ret); - } - -@@ -472,6 +481,7 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) - struct btrfs_ioctl_search_header *sh; - unsigned long off = 0; - int namelen; -+ int e; - - memset(&args, 0, sizeof(args)); - -@@ -490,8 +500,10 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) - sk->nr_items = 1; - - ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); -+ e = errno; - if (ret < 0) { -- fprintf(stderr, "ERROR: can't perform the search\n"); -+ fprintf(stderr, "ERROR: can't perform the search - %s\n", -+ strerror(e)); - return NULL; - } - /* the ioctl returns the number of item it found in nr_items */ -@@ -550,6 +562,7 @@ int list_subvols(int fd) - char *name; - u64 dir_id; - int i; -+ int e; - - root_lookup_init(&root_lookup); - -@@ -578,8 +591,10 @@ int list_subvols(int fd) - - while(1) { - ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); -+ e = errno; - if (ret < 0) { -- fprintf(stderr, "ERROR: can't perform the search\n"); -+ fprintf(stderr, "ERROR: can't perform the search - %s\n", -+ strerror(e)); - return ret; - } - /* the ioctl returns the number of item it found in nr_items */ -@@ -747,6 +762,7 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen) - u64 found_gen; - u64 max_found = 0; - int i; -+ int e; - u64 cache_dirid = 0; - u64 cache_ino = 0; - char *cache_dir_name = NULL; -@@ -773,8 +789,10 @@ int find_updated_files(int fd, u64 root_id, u64 oldest_gen) - max_found = find_root_gen(fd); - while(1) { - ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); -+ e = errno; - if (ret < 0) { -- fprintf(stderr, "ERROR: can't perform the search\n"); -+ fprintf(stderr, "ERROR: can't perform the search- %s\n", -+ strerror(e)); - return ret; - } - /* the ioctl returns the number of item it found in nr_items */ -diff --git a/btrfs_cmds.c b/btrfs_cmds.c -index fffb423..775bfe1 100644 ---- a/btrfs_cmds.c -+++ b/btrfs_cmds.c -@@ -156,6 +156,7 @@ int do_defrag(int ac, char **av) - int verbose = 0; - int fancy_ioctl = 0; - struct btrfs_ioctl_defrag_range_args range; -+ int e=0; - - optind = 1; - while(1) { -@@ -219,19 +220,21 @@ int do_defrag(int ac, char **av) - } - if (!fancy_ioctl) { - ret = ioctl(fd, BTRFS_IOC_DEFRAG, NULL); -+ e=errno; - } else { - ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE, &range); - if (ret && errno == ENOTTY) { -- fprintf(stderr, "defrag range ioctl not " -+ fprintf(stderr, "ERROR: defrag range ioctl not " - "supported in this kernel, please try " - "without any options.\n"); - errors++; -+ close(fd); - break; - } - } - if (ret) { -- fprintf(stderr, "ioctl failed on %s ret %d errno %d\n", -- av[i], ret, errno); -+ fprintf(stderr, "ERROR: defrag failed on %s - %s\n", -+ av[i], strerror(e)); - errors++; - } - close(fd); -@@ -310,7 +313,7 @@ int do_subvol_list(int argc, char **argv) - int do_clone(int argc, char **argv) - { - char *subvol, *dst; -- int res, fd, fddst, len; -+ int res, fd, fddst, len, e; - char *newname; - char *dstdir; - -@@ -377,12 +380,14 @@ int do_clone(int argc, char **argv) - args.fd = fd; - strncpy(args.name, newname, BTRFS_PATH_NAME_MAX); - res = ioctl(fddst, BTRFS_IOC_SNAP_CREATE, &args); -+ e = errno; - - close(fd); - close(fddst); - - if(res < 0 ){ -- fprintf( stderr, "ERROR: cannot snapshot '%s'\n",subvol); -