Hello community,

here is the log from the commit of package btrfsprogs for openSUSE:Factory 
checked in at 2014-11-11 09:59:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/btrfsprogs (Old)
 and      /work/SRC/openSUSE:Factory/.btrfsprogs.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "btrfsprogs"

Changes:
--------
--- /work/SRC/openSUSE:Factory/btrfsprogs/btrfsprogs.changes    2014-10-06 
22:04:29.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.btrfsprogs.new/btrfsprogs.changes       
2014-11-11 09:59:19.000000000 +0100
@@ -1,0 +2,45 @@
+Mon Nov  3 00:00:00 CET 2014 - [email protected]
+
+- version 3.17
+  - check: --init-csum-tree acutally does something useful, rebuilds the whole
+    csum tree
+  - /dev scanning for btrfs devices is gone
+  - /proc/partitions scanning is gone, blkid is used exclusively
+  - new subcommand subvolume sync
+  - filesystem df: new options to set unit format
+  - convert: allow to copy label from the origin, or specify a new one
+- Modified patches:
+  * 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch
+  * 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch
+  * 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch
+  * 0014-btrfs-progs-Add-btrfs-device-disk-usage-command.patch
+  * 0015-btrfs-progs-cleanup-dead-return-after-usage-for-fi-d.patch
+  * 0016-btrfs-progs-Fix-memleak-in-get_raid56_used.patch
+  * 0017-Btrfs-progs-fi-usage-free-memory-if-realloc-fails.patch
+  * 0019-btrfs-progs-add-original-df-and-rename-disk_usage-to.patch
+  * 0020-btrfs-progs-move-device-usage-to-cmds-device-more-cl.patch
+  * 0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch
+  * 0022-btrfs-progs-zero-out-structures-before-calling-ioctl.patch
+  * 0024-btrfs-progs-Print-more-info-about-device-sizes.patch
+  * 0025-btrfs-progs-compare-unallocated-space-against-the-co.patch
+  * 0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch
+  * 0027-btrfs-progs-cleanup-filesystem-device-usage-code.patch
+  * 0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch
+  * 0030-btrfs-progs-clean-up-return-codes-and-paths.patch
+  * 0031-btrfs-progs-move-global-reserve-to-overall-summary.patch
+- Added patches:
+  * 0010-btrfs-progs-move-group-type-and-profile-pretty-print.patch
+  * 0028-btrfs-progs-rework-calculations-of-fi-usage.patch
+  * 0042-btrfs-progs-fix-linking-with-libbtrfs.patch
+  * 0043-btrfs-progs-libbtrfs-make-exported-headers-compatibl.patch
+- Removed patches:
+  * 0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch
+  * 0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch
+  * 0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch
+  * 0018-btrfs-progs-read-global-reserve-size-from-space-info.patch
+  * 0023-btrfs-progs-print-B-for-bytes.patch
+  * 0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch
+  * 0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch
+  * 0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch
+
+-------------------------------------------------------------------

Old:
----
  0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch
  0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch
  0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch
  0018-btrfs-progs-read-global-reserve-size-from-space-info.patch
  0023-btrfs-progs-print-B-for-bytes.patch
  0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch
  0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch
  0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch
  btrfs-progs-v3.16.2.tar.gz

New:
----
  0010-btrfs-progs-move-group-type-and-profile-pretty-print.patch
  0028-btrfs-progs-rework-calculations-of-fi-usage.patch
  0042-btrfs-progs-fix-linking-with-libbtrfs.patch
  0043-btrfs-progs-libbtrfs-make-exported-headers-compatibl.patch
  btrfs-progs-v3.17.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ btrfsprogs.spec ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -16,9 +16,9 @@
 #
 
 
-%define tar_version v3.16.2
+%define tar_version v3.17
 Name:           btrfsprogs
-Version:        3.16.2
+Version:        3.17
 Release:        0
 Summary:        Utilities for the Btrfs filesystem
 License:        GPL-2.0
@@ -30,9 +30,7 @@
 Source1:        boot-btrfs.sh
 Source4:        setup-btrfs.sh
 
-Patch6:         0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch
-Patch7:         0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch
-Patch8:         0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch
+Patch10:        0010-btrfs-progs-move-group-type-and-profile-pretty-print.patch
 Patch11:        0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch
 Patch12:        0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch
 Patch13:        0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch
@@ -40,27 +38,25 @@
 Patch15:        0015-btrfs-progs-cleanup-dead-return-after-usage-for-fi-d.patch
 Patch16:        0016-btrfs-progs-Fix-memleak-in-get_raid56_used.patch
 Patch17:        0017-Btrfs-progs-fi-usage-free-memory-if-realloc-fails.patch
-Patch18:        0018-btrfs-progs-read-global-reserve-size-from-space-info.patch
 Patch19:        0019-btrfs-progs-add-original-df-and-rename-disk_usage-to.patch
 Patch20:        0020-btrfs-progs-move-device-usage-to-cmds-device-more-cl.patch
 Patch21:        0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch
 Patch22:        0022-btrfs-progs-zero-out-structures-before-calling-ioctl.patch
-Patch23:        0023-btrfs-progs-print-B-for-bytes.patch
 Patch24:        0024-btrfs-progs-Print-more-info-about-device-sizes.patch
 Patch25:        0025-btrfs-progs-compare-unallocated-space-against-the-co.patch
 Patch26:        0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch
 Patch27:        0027-btrfs-progs-cleanup-filesystem-device-usage-code.patch
-Patch28:        0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch
+Patch28:        0028-btrfs-progs-rework-calculations-of-fi-usage.patch
 Patch29:        0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch
 Patch30:        0030-btrfs-progs-clean-up-return-codes-and-paths.patch
 Patch31:        0031-btrfs-progs-move-global-reserve-to-overall-summary.patch
+Patch42:        0042-btrfs-progs-fix-linking-with-libbtrfs.patch
+Patch43:        0043-btrfs-progs-libbtrfs-make-exported-headers-compatibl.patch
 
 Patch163:       0163-btrfs-progs-fsck-fix-segfault.patch
-Patch164:       0164-btrfs-progs-convert-set-label-or-copy-from-origin.patch
 Patch167:       0167-Btrfs-progs-make-find_and_setup_root-return-an-error.patch
 Patch168:       0168-Btrfs-progs-don-t-bug-out-if-we-can-t-find-the-last-.patch
 Patch169:       0169-btrfs-progs-Check-metadata-mirrors-in-find-root.patch
-Patch171:       0171-btrfs-progs-make-free-space-checker-work-on-non-4k-s.patch
 
 Patch1000:      local-version-override.patch
 
@@ -100,9 +96,7 @@
 
 %prep
 %setup -q -n btrfs-progs-%{tar_version}
-%patch6 -p1
-%patch7 -p1
-%patch8 -p1
+%patch10 -p1
 %patch11 -p1
 %patch12 -p1
 %patch13 -p1
@@ -110,26 +104,24 @@
 %patch15 -p1
 %patch16 -p1
 %patch17 -p1
-%patch18 -p1
 %patch19 -p1
 %patch20 -p1
 %patch21 -p1
 %patch22 -p1
-%patch23 -p1
 %patch24 -p1
 %patch25 -p1
 %patch26 -p1
 %patch27 -p1
-%patch28 -p1
 %patch29 -p1
 %patch30 -p1
 %patch31 -p1
+%patch28 -p1
+%patch42 -p1
+%patch43 -p1
 %patch163 -p1
-%patch164 -p1
 %patch167 -p1
 %patch168 -p1
 %patch169 -p1
-%patch171 -p1
 %patch1000 -p1
 
 %build

++++++ 0010-btrfs-progs-move-group-type-and-profile-pretty-print.patch ++++++
>From 86afea330be6179ac88e0fcaf14924e03257b445 Mon Sep 17 00:00:00 2001
From: David Sterba <[email protected]>
Date: Thu, 23 Oct 2014 19:05:31 +0200
Subject: [PATCH 01/42] btrfs-progs: move group type and profile pretty
 printers to utils

Move and add the btrfs_ prefix.

Signed-off-by: David Sterba <[email protected]>
---
 cmds-filesystem.c | 47 ++---------------------------------------------
 utils.c           | 44 ++++++++++++++++++++++++++++++++++++++++++++
 utils.h           |  2 ++
 3 files changed, 48 insertions(+), 45 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index bb5881edef2d..ffa939c5b89a 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -127,49 +127,6 @@ static const char * const cmd_df_usage[] = {
        NULL
 };
 
-static char *group_type_str(u64 flag)
-{
-       u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
-               BTRFS_SPACE_INFO_GLOBAL_RSV;
-
-       switch (flag & mask) {
-       case BTRFS_BLOCK_GROUP_DATA:
-               return "Data";
-       case BTRFS_BLOCK_GROUP_SYSTEM:
-               return "System";
-       case BTRFS_BLOCK_GROUP_METADATA:
-               return "Metadata";
-       case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
-               return "Data+Metadata";
-       case BTRFS_SPACE_INFO_GLOBAL_RSV:
-               return "GlobalReserve";
-       default:
-               return "unknown";
-       }
-}
-
-static char *group_profile_str(u64 flag)
-{
-       switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
-       case 0:
-               return "single";
-       case BTRFS_BLOCK_GROUP_RAID0:
-               return "RAID0";
-       case BTRFS_BLOCK_GROUP_RAID1:
-               return "RAID1";
-       case BTRFS_BLOCK_GROUP_RAID5:
-               return "RAID5";
-       case BTRFS_BLOCK_GROUP_RAID6:
-               return "RAID6";
-       case BTRFS_BLOCK_GROUP_DUP:
-               return "DUP";
-       case BTRFS_BLOCK_GROUP_RAID10:
-               return "RAID10";
-       default:
-               return "unknown";
-       }
-}
-
 static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
 {
        u64 count = 0;
@@ -225,8 +182,8 @@ static void print_df(struct btrfs_ioctl_space_args *sargs, 
unsigned unit_mode)
 
        for (i = 0; i < sargs->total_spaces; i++, sp++) {
                printf("%s, %s: total=%s, used=%s\n",
-                       group_type_str(sp->flags),
-                       group_profile_str(sp->flags),
+                       btrfs_group_type_str(sp->flags),
+                       btrfs_group_profile_str(sp->flags),
                        pretty_size_mode(sp->total_bytes, unit_mode),
                        pretty_size_mode(sp->used_bytes, unit_mode));
        }
diff --git a/utils.c b/utils.c
index f10c178bf36e..43b693c94039 100644
--- a/utils.c
+++ b/utils.c
@@ -2431,3 +2431,47 @@ int find_next_key(struct btrfs_path *path, struct 
btrfs_key *key)
        }
        return 1;
 }
+
+char* btrfs_group_type_str(u64 flag)
+{
+       u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
+               BTRFS_SPACE_INFO_GLOBAL_RSV;
+
+       switch (flag & mask) {
+       case BTRFS_BLOCK_GROUP_DATA:
+               return "Data";
+       case BTRFS_BLOCK_GROUP_SYSTEM:
+               return "System";
+       case BTRFS_BLOCK_GROUP_METADATA:
+               return "Metadata";
+       case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
+               return "Data+Metadata";
+       case BTRFS_SPACE_INFO_GLOBAL_RSV:
+               return "GlobalReserve";
+       default:
+               return "unknown";
+       }
+}
+
+char* btrfs_group_profile_str(u64 flag)
+{
+       switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
+       case 0:
+               return "single";
+       case BTRFS_BLOCK_GROUP_RAID0:
+               return "RAID0";
+       case BTRFS_BLOCK_GROUP_RAID1:
+               return "RAID1";
+       case BTRFS_BLOCK_GROUP_RAID5:
+               return "RAID5";
+       case BTRFS_BLOCK_GROUP_RAID6:
+               return "RAID6";
+       case BTRFS_BLOCK_GROUP_DUP:
+               return "DUP";
+       case BTRFS_BLOCK_GROUP_RAID10:
+               return "RAID10";
+       default:
+               return "unknown";
+       }
+}
+
diff --git a/utils.h b/utils.h
index 7accbd20382c..0d202f6344c4 100644
--- a/utils.h
+++ b/utils.h
@@ -159,5 +159,7 @@ static inline u64 btrfs_min_dev_size(u32 leafsize)
 }
 
 int find_next_key(struct btrfs_path *path, struct btrfs_key *key);
+char* btrfs_group_type_str(u64 flag);
+char* btrfs_group_profile_str(u64 flag);
 
 #endif
-- 
2.1.1

++++++ 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,31 +1,32 @@
-From 04a9855f53cb7e4ad874cec28acfa537f00a28ba Mon Sep 17 00:00:00 2001
+From 8296d5dae853ada256834975148678125e51af6e Mon Sep 17 00:00:00 2001
 From: Goffredo Baroncelli <[email protected]>
 Date: Thu, 13 Feb 2014 20:19:01 +0100
-Subject: [PATCH 22/42] btrfs-progs: Enhance the command btrfs filesystem df
+Subject: [PATCH 02/42] btrfs-progs: Enhance the command btrfs filesystem df
 
 Enhance the command "btrfs filesystem df" to show space usage information
 for a mount point(s). It shows also an estimation of the space available,
 on the basis of the current one used.
 
 Signed-off-by: Goffredo Baroncelli <[email protected]>
+[code moved under #if 0 instead of deletion]
 Signed-off-by: David Sterba <[email protected]>
 ---
  Makefile             |   2 +-
  cmds-fi-disk_usage.c | 516 +++++++++++++++++++++++++++++++++++++++++++++++++++
  cmds-fi-disk_usage.h |  25 +++
- cmds-filesystem.c    |  92 +--------
+ cmds-filesystem.c    |   7 +-
  ctree.h              |   5 +-
- utils.c              |  12 ++
+ utils.c              |  11 ++
  utils.h              |   1 +
- 7 files changed, 560 insertions(+), 93 deletions(-)
+ 7 files changed, 563 insertions(+), 4 deletions(-)
  create mode 100644 cmds-fi-disk_usage.c
  create mode 100644 cmds-fi-disk_usage.h
 
-Index: btrfs-progs-v3.16/Makefile
-===================================================================
---- btrfs-progs-v3.16.orig/Makefile
-+++ btrfs-progs-v3.16/Makefile
-@@ -15,7 +15,7 @@ cmds_objects = cmds-subvolume.o cmds-fil
+diff --git a/Makefile b/Makefile
+index 9c69adae9050..a6c1ccede7c4 100644
+--- a/Makefile
++++ b/Makefile
+@@ -15,7 +15,7 @@ cmds_objects = cmds-subvolume.o cmds-filesystem.o 
cmds-device.o cmds-scrub.o \
               cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
               cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
               cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
@@ -34,10 +35,11 @@
  libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
                   uuid-tree.o utils-lib.o
  libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
-Index: btrfs-progs-v3.16/cmds-fi-disk_usage.c
-===================================================================
+diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
+new file mode 100644
+index 000000000000..7f4415666bd8
 --- /dev/null
-+++ btrfs-progs-v3.16/cmds-fi-disk_usage.c
++++ b/cmds-fi-disk_usage.c
 @@ -0,0 +1,516 @@
 +/*
 + * This program is free software; you can redistribute it and/or
@@ -94,7 +96,7 @@
 +      static char buf[30];
 +
 +      if (mode & DF_HUMAN_UNIT)
-+              (void)pretty_size_snprintf(size, buf, sizeof(buf));
++              (void)pretty_size_snprintf(size, buf, sizeof(buf), 
UNITS_DEFAULT);
 +      else
 +              sprintf(buf, "%llu", size);
 +
@@ -555,10 +557,11 @@
 +      return 0;
 +}
 +
-Index: btrfs-progs-v3.16/cmds-fi-disk_usage.h
-===================================================================
+diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
+new file mode 100644
+index 000000000000..9f68bb342d52
 --- /dev/null
-+++ btrfs-progs-v3.16/cmds-fi-disk_usage.h
++++ b/cmds-fi-disk_usage.h
 @@ -0,0 +1,25 @@
 +/*
 + * Copyright (C) 2007 Oracle.  All rights reserved.
@@ -585,10 +588,10 @@
 +int cmd_filesystem_df(int argc, char **argv);
 +
 +#endif
-Index: btrfs-progs-v3.16/cmds-filesystem.c
-===================================================================
---- btrfs-progs-v3.16.orig/cmds-filesystem.c
-+++ btrfs-progs-v3.16/cmds-filesystem.c
+diff --git a/cmds-filesystem.c b/cmds-filesystem.c
+index ffa939c5b89a..91e4e2e5a881 100644
+--- a/cmds-filesystem.c
++++ b/cmds-filesystem.c
 @@ -36,6 +36,7 @@
  #include "volumes.h"
  #include "version.h"
@@ -597,115 +600,39 @@
  #include "list_sort.h"
  #include "disk-io.h"
  
-@@ -112,55 +113,6 @@ static const char * const filesystem_cmd_group_usage[] = {
+@@ -112,6 +113,7 @@ static const char * const filesystem_cmd_group_usage[] = {
        NULL
  };
  
--static const char * const cmd_df_usage[] = {
--      "btrfs filesystem df <path>",
--      "Show space usage information for a mount point",
--      NULL
--};
--
--static char *group_type_str(u64 flag)
--{
--      u64 mask = BTRFS_BLOCK_GROUP_TYPE_MASK |
--              BTRFS_SPACE_INFO_GLOBAL_RSV;
--
--      switch (flag & mask) {
--      case BTRFS_BLOCK_GROUP_DATA:
--              return "Data";
--      case BTRFS_BLOCK_GROUP_SYSTEM:
--              return "System";
--      case BTRFS_BLOCK_GROUP_METADATA:
--              return "Metadata";
--      case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
--              return "Data+Metadata";
--      case BTRFS_SPACE_INFO_GLOBAL_RSV:
--              return "GlobalReserve";
--      default:
--              return "unknown";
--      }
--}
--
--static char *group_profile_str(u64 flag)
--{
--      switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
--      case 0:
--              return "single";
--      case BTRFS_BLOCK_GROUP_RAID0:
--              return "RAID0";
--      case BTRFS_BLOCK_GROUP_RAID1:
--              return "RAID1";
--      case BTRFS_BLOCK_GROUP_RAID5:
--              return "RAID5";
--      case BTRFS_BLOCK_GROUP_RAID6:
--              return "RAID6";
--      case BTRFS_BLOCK_GROUP_DUP:
--              return "DUP";
--      case BTRFS_BLOCK_GROUP_RAID10:
--              return "RAID10";
--      default:
--              return "unknown";
--      }
--}
--
++#if 0
+ static const char * const cmd_df_usage[] = {
+        "btrfs filesystem df [options] <path>",
+        "Show space usage information for a mount point",
+@@ -126,6 +128,7 @@ static const char * const cmd_df_usage[] = {
+       "-t|--tbytes        show sizes in TiB, or tB with --si",
+        NULL
+ };
++#endif
+ 
  static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
  {
-       u64 count = 0;
-@@ -204,51 +161,6 @@ static int get_df(int fd, struct btrfs_i
+@@ -175,6 +178,7 @@ static int get_df(int fd, struct btrfs_ioctl_space_args 
**sargs_ret)
        return 0;
  }
  
--static void print_df(struct btrfs_ioctl_space_args *sargs)
--{
--      u64 i;
--      struct btrfs_ioctl_space_info *sp = sargs->spaces;
--
--      for (i = 0; i < sargs->total_spaces; i++, sp++) {
--              printf("%s, %s: total=%s, used=%s\n",
--                      group_type_str(sp->flags),
--                      group_profile_str(sp->flags),
--                      pretty_size(sp->total_bytes),
--                      pretty_size(sp->used_bytes));
--      }
--}
--
--static int cmd_df(int argc, char **argv)
--{
--      struct btrfs_ioctl_space_args *sargs = NULL;
--      int ret;
--      int fd;
--      char *path;
--      DIR  *dirstream = NULL;
--
--      if (check_argc_exact(argc, 2))
--              usage(cmd_df_usage);
--
--      path = argv[1];
--
--      fd = open_file_or_dir(path, &dirstream);
--      if (fd < 0) {
--              fprintf(stderr, "ERROR: can't access '%s'\n", path);
--              return 1;
--      }
--      ret = get_df(fd, &sargs);
--
--      if (ret == 0) {
--              print_df(sargs);
--              free(sargs);
--      } else {
--              fprintf(stderr, "ERROR: get_df failed %s\n", strerror(-ret));
--      }
--
--      close_file_or_dir(fd, dirstream);
--      return !!ret;
--}
--
++#if 0
+ static void print_df(struct btrfs_ioctl_space_args *sargs, unsigned unit_mode)
+ {
+       u64 i;
+@@ -269,6 +273,7 @@ static int cmd_df(int argc, char **argv)
+       close_file_or_dir(fd, dirstream);
+       return !!ret;
+ }
++#endif
+ 
  static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
                                        char *search)
- {
-@@ -999,7 +911,7 @@ static int cmd_label(int argc, char **ar
+@@ -1263,7 +1268,7 @@ static int cmd_label(int argc, char **argv)
  
  const struct cmd_group filesystem_cmd_group = {
        filesystem_cmd_group_usage, NULL, {
@@ -714,11 +641,11 @@
                { "show", cmd_show, cmd_show_usage, NULL, 0 },
                { "sync", cmd_sync, cmd_sync_usage, NULL, 0 },
                { "defragment", cmd_defrag, cmd_defrag_usage, NULL, 0 },
-Index: btrfs-progs-v3.16/ctree.h
-===================================================================
---- btrfs-progs-v3.16.orig/ctree.h
-+++ btrfs-progs-v3.16/ctree.h
-@@ -845,9 +845,10 @@ struct btrfs_csum_item {
+diff --git a/ctree.h b/ctree.h
+index 89036defc396..5a60bd268871 100644
+--- a/ctree.h
++++ b/ctree.h
+@@ -842,9 +842,10 @@ struct btrfs_csum_item {
  #define BTRFS_BLOCK_GROUP_RAID1               (1ULL << 4)
  #define BTRFS_BLOCK_GROUP_DUP         (1ULL << 5)
  #define BTRFS_BLOCK_GROUP_RAID10      (1ULL << 6)
@@ -731,10 +658,10 @@
  
  #define BTRFS_BLOCK_GROUP_TYPE_MASK   (BTRFS_BLOCK_GROUP_DATA |    \
                                         BTRFS_BLOCK_GROUP_SYSTEM |  \
-Index: btrfs-progs-v3.16/utils.c
-===================================================================
---- btrfs-progs-v3.16.orig/utils.c
-+++ btrfs-progs-v3.16/utils.c
+diff --git a/utils.c b/utils.c
+index 43b693c94039..cf0559d9c9dd 100644
+--- a/utils.c
++++ b/utils.c
 @@ -38,6 +38,8 @@
  #include <linux/kdev_t.h>
  #include <limits.h>
@@ -744,11 +671,10 @@
  #include "kerncompat.h"
  #include "radix-tree.h"
  #include "ctree.h"
-@@ -2439,3 +2441,13 @@ int test_isdir(const char *path)
- 
-       return S_ISDIR(st.st_mode);
+@@ -2475,3 +2477,12 @@ char* btrfs_group_profile_str(u64 flag)
+       }
  }
-+
+ 
 +u64 disk_size(char *path)
 +{
 +      struct statfs sfs;
@@ -759,10 +685,10 @@
 +              return sfs.f_bsize * sfs.f_blocks;
 +}
 diff --git a/utils.h b/utils.h
-index fd25126dac81..c683818e003f 100644
+index 0d202f6344c4..2976e11d7a93 100644
 --- a/utils.h
 +++ b/utils.h
-@@ -114,6 +114,7 @@ int find_mount_root(const char *path, char **mount_root);
+@@ -133,6 +133,7 @@ int find_mount_root(const char *path, char **mount_root);
  int get_device_info(int fd, u64 devid,
                struct btrfs_ioctl_dev_info_args *di_args);
  int test_uuid_unique(char *fs_uuid);

++++++ 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From a79f61440afaa0b77dc67c896fa3367a171c2306 Mon Sep 17 00:00:00 2001
+From a1faabe2147d3ba59b16ac16dc0862166e2dee15 Mon Sep 17 00:00:00 2001
 From: Goffredo Baroncelli <[email protected]>
 Date: Thu, 13 Feb 2014 20:19:21 +0100
-Subject: [PATCH 23/42] btrfs-progs: Add helpers functions to handle the
+Subject: [PATCH 03/42] btrfs-progs: Add helpers functions to handle the
  printing of data in tabular format
 
 This patch adds some functions to manage the printing of the data in
@@ -33,22 +33,22 @@
 Signed-off-by: David Sterba <[email protected]>
 ---
  Makefile       |   2 +-
- string_table.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- string_table.h |  36 +++++++++++++
+ string-table.c | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ string-table.h |  36 +++++++++++++
  3 files changed, 193 insertions(+), 1 deletion(-)
- create mode 100644 string_table.c
- create mode 100644 string_table.h
+ create mode 100644 string-table.c
+ create mode 100644 string-table.h
 
-Index: btrfs-progs-v3.16/Makefile
-===================================================================
---- btrfs-progs-v3.16.orig/Makefile
-+++ btrfs-progs-v3.16/Makefile
-@@ -10,7 +10,7 @@ objects = ctree.o disk-io.o radix-tree.o
+diff --git a/Makefile b/Makefile
+index a6c1ccede7c4..7f76447e3c55 100644
+--- a/Makefile
++++ b/Makefile
+@@ -10,7 +10,7 @@ objects = 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 \
          extent-cache.o extent_io.o volumes.o utils.o repair.o \
          qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
--        ulist.o qgroup-verify.o
-+        ulist.o qgroup-verify.o string-table.o
+-        ulist.o qgroup-verify.o backref.o rbtree-utils.o
++        ulist.o qgroup-verify.o backref.o rbtree-utils.o string-table.o
  cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
               cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
               cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
@@ -256,3 +256,6 @@
 +void table_free(struct string_table *);
 +
 +#endif
+-- 
+2.1.1
+

++++++ 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From bb2b9f64b992f166533cc0d06aeec9518795d24a Mon Sep 17 00:00:00 2001
+From fa083296aa7ff515a46ca05e6dbddb38e8c0745f Mon Sep 17 00:00:00 2001
 From: Goffredo Baroncelli <[email protected]>
 Date: Thu, 13 Feb 2014 20:19:50 +0100
-Subject: [PATCH 24/42] btrfs-progs: Add command btrfs filesystem disk-usage
+Subject: [PATCH 04/42] btrfs-progs: Add command btrfs filesystem disk-usage
 
 Signed-off-by: Goffredo Baroncelli <[email protected]>
 Signed-off-by: David Sterba <[email protected]>
@@ -9,14 +9,14 @@
  cmds-fi-disk_usage.c | 428 +++++++++++++++++++++++++++++++++++++++++++++++++++
  cmds-fi-disk_usage.h |   3 +
  cmds-filesystem.c    |   3 +
- utils.c              |  60 ++++++++
+ utils.c              |  16 ++
  utils.h              |   5 +
- 5 files changed, 499 insertions(+)
+ 5 files changed, 455 insertions(+)
 
-Index: btrfs-progs-v3.16/cmds-fi-disk_usage.c
-===================================================================
---- btrfs-progs-v3.16.orig/cmds-fi-disk_usage.c
-+++ btrfs-progs-v3.16/cmds-fi-disk_usage.c
+diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
+index 7f4415666bd8..25cd4ede97ab 100644
+--- a/cmds-fi-disk_usage.c
++++ b/cmds-fi-disk_usage.c
 @@ -20,10 +20,12 @@
  #include <unistd.h>
  #include <sys/ioctl.h>
@@ -44,7 +44,7 @@
  /*
   * Pretty print the size
   * PAY ATTENTION: it return a statically buffer
-@@ -514,3 +523,422 @@ int cmd_filesystem_df(int argc, char **a
+@@ -514,3 +523,422 @@ int cmd_filesystem_df(int argc, char **argv)
        return 0;
  }
  
@@ -167,7 +167,7 @@
 +              const char *description;
 +
 +              u64 flags = sargs->spaces[i].flags;
-+              description = group_type_str(flags);
++              description = btrfs_group_type_str(flags);
 +
 +              table_printf(matrix, 1+i, 0, "<%s", description);
 +      }
@@ -176,7 +176,7 @@
 +              const char *r_mode;
 +
 +              u64 flags = sargs->spaces[i].flags;
-+              r_mode = group_profile_str(flags);
++              r_mode = btrfs_group_profile_str(flags);
 +
 +              table_printf(matrix, 1+i, 1, "<%s", r_mode);
 +      }
@@ -338,8 +338,8 @@
 +              const char *r_mode;
 +
 +              u64 flags = sargs->spaces[i].flags;
-+              description= group_type_str(flags);
-+              r_mode = group_profile_str(flags);
++              description = btrfs_group_type_str(flags);
++              r_mode = btrfs_group_profile_str(flags);
 +
 +              printf("%s,%s: Size:%s, ",
 +                      description,
@@ -467,10 +467,10 @@
 +
 +      return 0;
 +}
-Index: btrfs-progs-v3.16/cmds-fi-disk_usage.h
-===================================================================
---- btrfs-progs-v3.16.orig/cmds-fi-disk_usage.h
-+++ btrfs-progs-v3.16/cmds-fi-disk_usage.h
+diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
+index 9f68bb342d52..c7459b1521e4 100644
+--- a/cmds-fi-disk_usage.h
++++ b/cmds-fi-disk_usage.h
 @@ -22,4 +22,7 @@
  extern const char * const cmd_filesystem_df_usage[];
  int cmd_filesystem_df(int argc, char **argv);
@@ -479,11 +479,11 @@
 +int cmd_filesystem_disk_usage(int argc, char **argv);
 +
  #endif
-Index: btrfs-progs-v3.16/cmds-filesystem.c
-===================================================================
---- btrfs-progs-v3.16.orig/cmds-filesystem.c
-+++ btrfs-progs-v3.16/cmds-filesystem.c
-@@ -918,6 +918,9 @@ const struct cmd_group filesystem_cmd_gr
+diff --git a/cmds-filesystem.c b/cmds-filesystem.c
+index 91e4e2e5a881..43d5c31dcbb0 100644
+--- a/cmds-filesystem.c
++++ b/cmds-filesystem.c
+@@ -1275,6 +1275,9 @@ const struct cmd_group filesystem_cmd_group = {
                { "balance", cmd_balance, NULL, &balance_cmd_group, 1 },
                { "resize", cmd_resize, cmd_resize_usage, NULL, 0 },
                { "label", cmd_label, cmd_label_usage, NULL, 0 },
@@ -493,11 +493,11 @@
                NULL_CMD_STRUCT
        }
  };
-Index: btrfs-progs-v3.16/utils.c
-===================================================================
---- btrfs-progs-v3.16.orig/utils.c
-+++ btrfs-progs-v3.16/utils.c
-@@ -2448,3 +2448,63 @@ u64 disk_size(char *path)
+diff --git a/utils.c b/utils.c
+index cf0559d9c9dd..643f000a5bd0 100644
+--- a/utils.c
++++ b/utils.c
+@@ -2486,3 +2486,19 @@ u64 disk_size(char *path)
        else
                return sfs.f_bsize * sfs.f_blocks;
  }
@@ -517,55 +517,11 @@
 +
 +      return result;
 +}
-+
-+/*
-+ *  Convert a chunk type to a chunk description
-+ */
-+const char *group_type_str(u64 flag)
-+{
-+      switch (flag & BTRFS_BLOCK_GROUP_TYPE_MASK) {
-+      case BTRFS_BLOCK_GROUP_DATA:
-+              return "Data";
-+      case BTRFS_BLOCK_GROUP_SYSTEM:
-+              return "System";
-+      case BTRFS_BLOCK_GROUP_METADATA:
-+              return "Metadata";
-+      case BTRFS_BLOCK_GROUP_DATA|BTRFS_BLOCK_GROUP_METADATA:
-+              return "Data+Metadata";
-+      default:
-+              return "unknown";
-+      }
-+}
-+
-+/*
-+ *  Convert a chunk type to a chunk profile description
-+ */
-+const char *group_profile_str(u64 flag)
-+{
-+      switch (flag & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
-+      case 0:
-+              return "single";
-+      case BTRFS_BLOCK_GROUP_RAID0:
-+              return "RAID0";
-+      case BTRFS_BLOCK_GROUP_RAID1:
-+              return "RAID1";
-+      case BTRFS_BLOCK_GROUP_RAID5:
-+              return "RAID5";
-+      case BTRFS_BLOCK_GROUP_RAID6:
-+              return "RAID6";
-+      case BTRFS_BLOCK_GROUP_DUP:
-+              return "DUP";
-+      case BTRFS_BLOCK_GROUP_RAID10:
-+              return "RAID10";
-+      default:
-+              return "unknown";
-+      }
-+}
 diff --git a/utils.h b/utils.h
-index c683818e003f..5c364b61dffa 100644
+index 2976e11d7a93..77455ef4d20e 100644
 --- a/utils.h
 +++ b/utils.h
-@@ -115,6 +115,11 @@ int get_device_info(int fd, u64 devid,
+@@ -134,6 +134,11 @@ int get_device_info(int fd, u64 devid,
                struct btrfs_ioctl_dev_info_args *di_args);
  int test_uuid_unique(char *fs_uuid);
  u64 disk_size(char *path);

++++++ 0014-btrfs-progs-Add-btrfs-device-disk-usage-command.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From b8eb50e005cc92d870faf6bfe285950c4ac66e09 Mon Sep 17 00:00:00 2001
+From 89a6910a4505829a88bca362541fa75e3ab829e3 Mon Sep 17 00:00:00 2001
 From: Goffredo Baroncelli <[email protected]>
 Date: Thu, 13 Feb 2014 20:20:12 +0100
-Subject: [PATCH 25/42] btrfs-progs: Add btrfs device disk-usage command
+Subject: [PATCH 05/42] btrfs-progs: Add btrfs device disk-usage command
 
 Signed-off-by: Goffredo Baroncelli <[email protected]>
 Signed-off-by: David Sterba <[email protected]>
@@ -12,7 +12,7 @@
  3 files changed, 142 insertions(+)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index 29da661e2a0d..f2e08ba55ba6 100644
+index 62f0b85b4d0c..037332d87498 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
 @@ -28,6 +28,7 @@
@@ -23,7 +23,7 @@
  
  #include "commands.h"
  
-@@ -435,6 +436,8 @@ const struct cmd_group device_cmd_group = {
+@@ -468,6 +469,8 @@ const struct cmd_group device_cmd_group = {
                { "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 },
                { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 },
                { "stats", cmd_dev_stats, cmd_dev_stats_usage, NULL, 0 },
@@ -33,7 +33,7 @@
        }
  };
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 16b3ab250956..e4eb72be0a88 100644
+index 25cd4ede97ab..5274a73240cf 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -942,3 +942,139 @@ int cmd_filesystem_disk_usage(int argc, char **argv)
@@ -62,8 +62,8 @@
 +
 +              flags = chunks_info_ptr[i].type;
 +
-+              description = group_type_str(flags);
-+              r_mode = group_profile_str(flags);
++              description = btrfs_group_type_str(flags);
++              r_mode = btrfs_group_profile_str(flags);
 +              size = calc_chunk_size(chunks_info_ptr+i);
 +              printf("   %s,%s:%*s%10s\n",
 +                      description,
@@ -189,5 +189,5 @@
 +
  #endif
 -- 
-1.9.0
+2.1.1
 

++++++ 0015-btrfs-progs-cleanup-dead-return-after-usage-for-fi-d.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From a604369c26e4e816579c59d7a595279b1b720cbc Mon Sep 17 00:00:00 2001
+From 00f8e6d5c8262a3f3738784e21cf1aca08224efb Mon Sep 17 00:00:00 2001
 From: Gui Hecheng <[email protected]>
 Date: Thu, 6 Mar 2014 11:36:46 +0800
-Subject: [PATCH 26/42] btrfs-progs: cleanup dead return after usage() for
+Subject: [PATCH 06/42] btrfs-progs: cleanup dead return after usage() for
  fi-disk_usage
 
 The usage() calls exit() internally, so remove the return after it.
@@ -13,7 +13,7 @@
  1 file changed, 3 insertions(+), 9 deletions(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index e4eb72be0a88..a3b06bebba72 100644
+index 5274a73240cf..edada5bbcf6b 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -494,10 +494,8 @@ int cmd_filesystem_df(int argc, char **argv)
@@ -53,5 +53,5 @@
        for (i = optind; i < argc ; i++) {
                int r, fd;
 -- 
-1.9.0
+2.1.1
 

++++++ 0016-btrfs-progs-Fix-memleak-in-get_raid56_used.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From ef568dad3da6887e656be617a178cbb69b36cdf3 Mon Sep 17 00:00:00 2001
+From bf9a3acde396575b141d9ac549aaf83466c0ab91 Mon Sep 17 00:00:00 2001
 From: Qu Wenruo <[email protected]>
 Date: Wed, 19 Mar 2014 06:10:02 +0000
-Subject: [PATCH 27/42] btrfs-progs: Fix memleak in get_raid56_used()
+Subject: [PATCH 07/42] btrfs-progs: Fix memleak in get_raid56_used()
 
 Fix memleak in get_raid56_used().
 
@@ -12,7 +12,7 @@
  1 file changed, 1 insertion(+)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index a3b06bebba72..2bd591db0f8a 100644
+index edada5bbcf6b..736294eea3da 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -352,6 +352,7 @@ static int get_raid56_used(int fd, u64 *raid5_used, u64 
*raid6_used)
@@ -24,5 +24,5 @@
        return 0;
  
 -- 
-1.9.0
+2.1.1
 

++++++ 0017-Btrfs-progs-fi-usage-free-memory-if-realloc-fails.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From b43d0660526d1a3e81f34fd499eb1dd038b00e08 Mon Sep 17 00:00:00 2001
+From 9102adcbc8521dfee5da2fd86b6f8333ee89f3d8 Mon Sep 17 00:00:00 2001
 From: Rakesh Pandit <[email protected]>
 Date: Sat, 19 Apr 2014 14:12:03 +0300
-Subject: [PATCH 28/42] Btrfs-progs: fi usage: free memory if realloc fails
+Subject: [PATCH 08/42] Btrfs-progs: fi usage: free memory if realloc fails
 
 Lets not assign *info_ptr to 0 before calling free on it and lose
 track of already allocated memory if realloc fails in
@@ -14,7 +14,7 @@
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 2bd591db0f8a..cd71c8da3cf4 100644
+index 736294eea3da..9fd59bc1b5ae 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -104,6 +104,7 @@ static int add_info_to_list(struct chunk_info **info_ptr,
@@ -34,5 +34,5 @@
                        }
  
 -- 
-1.9.0
+2.1.1
 

++++++ 0019-btrfs-progs-add-original-df-and-rename-disk_usage-to.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From 90cbd00127631b5f8964d5518d6b22bfe994a686 Mon Sep 17 00:00:00 2001
+From 9a0ccdc7cc51262e98fa9345393aa45fd9bba9cb Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Wed, 23 Apr 2014 18:47:52 +0200
-Subject: [PATCH 30/42] btrfs-progs: add original 'df' and rename 'disk_usage'
+Subject: [PATCH 09/42] btrfs-progs: add original 'df' and rename 'disk_usage'
  to 'usage'
 
 Add back the original output of the 'btrfs fi df' command for backward
@@ -13,11 +13,11 @@
 ---
  cmds-fi-disk_usage.c | 85 ++++++++++------------------------------------------
  cmds-fi-disk_usage.h |  7 ++---
- cmds-filesystem.c    | 55 ++++++++++++++++++++++++++++++++--
- 3 files changed, 71 insertions(+), 76 deletions(-)
+ cmds-filesystem.c    | 16 ++++------
+ 3 files changed, 24 insertions(+), 84 deletions(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index cd71c8da3cf4..efc640d13148 100644
+index 9fd59bc1b5ae..683d6fb36de4 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -328,6 +328,8 @@ static struct btrfs_ioctl_space_args *load_space_info(int 
fd, char *path)
@@ -205,75 +205,68 @@
  extern const char * const cmd_device_disk_usage_usage[];
  int cmd_device_disk_usage(int argc, char **argv);
 diff --git a/cmds-filesystem.c b/cmds-filesystem.c
-index 214a0cda518c..9340cb61cabe 100644
+index 43d5c31dcbb0..6626c7c9eaa2 100644
 --- a/cmds-filesystem.c
 +++ b/cmds-filesystem.c
-@@ -113,6 +113,26 @@ static const char * const filesystem_cmd_group_usage[] = {
+@@ -113,8 +113,7 @@ static const char * const filesystem_cmd_group_usage[] = {
        NULL
  };
  
+-#if 0
+-static const char * const cmd_df_usage[] = {
 +static const char * const cmd_filesystem_df_usage[] = {
-+       "btrfs filesystem df <path>",
-+       "Show space usage information for a mount point",
-+       NULL
-+};
-+
-+static void print_df(struct btrfs_ioctl_space_args *sargs)
-+{
-+       u64 i;
-+       struct btrfs_ioctl_space_info *sp = sargs->spaces;
-+
-+       for (i = 0; i < sargs->total_spaces; i++, sp++) {
-+               printf("%s, %s: total=%s, used=%s\n",
-+                       group_type_str(sp->flags),
-+                       group_profile_str(sp->flags),
-+                       pretty_size(sp->total_bytes),
-+                       pretty_size(sp->used_bytes));
-+       }
-+}
-+
+        "btrfs filesystem df [options] <path>",
+        "Show space usage information for a mount point",
+       "-b|--raw           raw numbers in bytes",
+@@ -128,7 +127,6 @@ static const char * const cmd_df_usage[] = {
+       "-t|--tbytes        show sizes in TiB, or tB with --si",
+        NULL
+ };
+-#endif
+ 
  static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
  {
-       u64 count = 0;
-@@ -161,6 +181,37 @@ static int get_df(int fd, struct btrfs_ioctl_space_args 
**sargs_ret)
+@@ -178,7 +176,6 @@ static int get_df(int fd, struct btrfs_ioctl_space_args 
**sargs_ret)
        return 0;
  }
  
+-#if 0
+ static void print_df(struct btrfs_ioctl_space_args *sargs, unsigned unit_mode)
+ {
+       u64 i;
+@@ -193,7 +190,7 @@ static void print_df(struct btrfs_ioctl_space_args *sargs, 
unsigned unit_mode)
+       }
+ }
+ 
+-static int cmd_df(int argc, char **argv)
 +static int cmd_filesystem_df(int argc, char **argv)
-+{
-+       struct btrfs_ioctl_space_args *sargs = NULL;
-+       int ret;
-+       int fd;
-+       char *path;
-+       DIR *dirstream = NULL;
-+
-+       if (check_argc_exact(argc, 2))
-+               usage(cmd_filesystem_df_usage);
-+
-+       path = argv[1];
-+
-+       fd = open_file_or_dir(path, &dirstream);
-+       if (fd < 0) {
-+               fprintf(stderr, "ERROR: can't access '%s'\n", path);
-+               return 1;
-+       }
-+       ret = get_df(fd, &sargs);
-+
-+       if (!ret && sargs) {
-+               print_df(sargs);
-+               free(sargs);
-+       } else {
-+               fprintf(stderr, "ERROR: get_df failed %s\n", strerror(-ret));
-+       }
-+
-+       close_file_or_dir(fd, dirstream);
-+       return !!ret;
-+}
-+
+ {
+       struct btrfs_ioctl_space_args *sargs = NULL;
+       int ret;
+@@ -247,12 +244,12 @@ static int cmd_df(int argc, char **argv)
+                       units_set_mode(&unit_mode, UNITS_BINARY);
+                       break;
+               default:
+-                      usage(cmd_df_usage);
++                      usage(cmd_filesystem_df_usage);
+               }
+       }
+ 
+       if (check_argc_max(argc, optind + 1))
+-              usage(cmd_df_usage);
++              usage(cmd_filesystem_df_usage);
+ 
+       path = argv[optind];
+ 
+@@ -273,7 +270,6 @@ static int cmd_df(int argc, char **argv)
+       close_file_or_dir(fd, dirstream);
+       return !!ret;
+ }
+-#endif
+ 
  static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
                                        char *search)
- {
-@@ -918,8 +969,8 @@ const struct cmd_group filesystem_cmd_group = {
+@@ -1275,8 +1271,8 @@ const struct cmd_group filesystem_cmd_group = {
                { "balance", cmd_balance, NULL, &balance_cmd_group, 1 },
                { "resize", cmd_resize, cmd_resize_usage, NULL, 0 },
                { "label", cmd_label, cmd_label_usage, NULL, 0 },
@@ -285,5 +278,5 @@
                NULL_CMD_STRUCT
        }
 -- 
-1.9.0
+2.1.1
 

++++++ 0020-btrfs-progs-move-device-usage-to-cmds-device-more-cl.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From 14462c746c40b97dd8efe0bea18cbc6372431a39 Mon Sep 17 00:00:00 2001
+From b90d57cf167b689fd1e191b80649bfcba42865b7 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Wed, 23 Apr 2014 19:00:22 +0200
-Subject: [PATCH 31/42] btrfs-progs: move device usage to cmds-device, more
+Subject: [PATCH 10/42] btrfs-progs: move device usage to cmds-device, more
  cleanups
 
 Move the command definitions where they belong, keep common 'usage'
@@ -19,10 +19,10 @@
  3 files changed, 188 insertions(+), 219 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index f2e08ba55ba6..c20b26e9be90 100644
+index 037332d87498..96e6309c0185 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -429,6 +429,98 @@ out:
+@@ -462,6 +462,98 @@ out:
        return err;
  }
  
@@ -121,7 +121,7 @@
  const struct cmd_group device_cmd_group = {
        device_cmd_group_usage, NULL, {
                { "add", cmd_add_dev, cmd_add_dev_usage, NULL, 0 },
-@@ -436,8 +528,8 @@ const struct cmd_group device_cmd_group = {
+@@ -469,8 +561,8 @@ const struct cmd_group device_cmd_group = {
                { "scan", cmd_scan_dev, cmd_scan_dev_usage, NULL, 0 },
                { "ready", cmd_ready_dev, cmd_ready_dev_usage, NULL, 0 },
                { "stats", cmd_dev_stats, cmd_dev_stats_usage, NULL, 0 },
@@ -133,7 +133,7 @@
        }
  };
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index efc640d13148..023659daac0e 100644
+index 683d6fb36de4..f432fa57fb91 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -26,38 +26,16 @@
@@ -708,5 +708,5 @@
  
  #endif
 -- 
-1.9.0
+2.1.1
 

++++++ 0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From a6979c52fbff0e0961a0a0546c45bca11f6a0658 Mon Sep 17 00:00:00 2001
+From 10fd49e8ced9a8fe34a409ab76c69488b9aef704 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Thu, 24 Apr 2014 15:21:16 +0200
-Subject: [PATCH 32/42] btrfs-progs: check if we can't get info from ioctls due
+Subject: [PATCH 11/42] btrfs-progs: check if we can't get info from ioctls due
  to permissions
 
 The TREE_SEARCH ioctl is root-only, FS_INFO will be available for
@@ -13,7 +13,7 @@
  1 file changed, 10 insertions(+)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 023659daac0e..3fa2af004dc4 100644
+index f432fa57fb91..8bc4f58fee0b 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -172,6 +172,12 @@ int load_chunk_info(int fd, struct chunk_info **info_ptr, 
int *info_count)
@@ -41,5 +41,5 @@
                fprintf(stderr, "ERROR: cannot get filesystem info\n");
                return -1;
 -- 
-1.9.0
+2.1.1
 

++++++ 0022-btrfs-progs-zero-out-structures-before-calling-ioctl.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From 70b51a393b7d9ee6d20b16be0c925c58ea88f3c5 Mon Sep 17 00:00:00 2001
+From 5a44a4939129de6edb249c03133e5db347739643 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Thu, 24 Apr 2014 18:37:50 +0200
-Subject: [PATCH 33/42] btrfs-progs: zero out structures before calling ioctl
+Subject: [PATCH 12/42] btrfs-progs: zero out structures before calling ioctl
 
 Signed-off-by: David Sterba <[email protected]>
 ---
@@ -9,7 +9,7 @@
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 3fa2af004dc4..8c0462230510 100644
+index 8bc4f58fee0b..f984be838e3b 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -248,7 +248,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int 
fd, char *path)
@@ -40,5 +40,5 @@
  
                if (ret == -ENODEV)
 -- 
-1.9.0
+2.1.1
 

++++++ 0024-btrfs-progs-Print-more-info-about-device-sizes.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From c856f30b979c71ab5cda62753993e725dae922e6 Mon Sep 17 00:00:00 2001
+From 685cfb2cb0a7b402c9074e08d2803e275c6f78eb Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Thu, 24 Apr 2014 18:32:27 +0200
-Subject: [PATCH 35/42] btrfs-progs: Print more info about device sizes
+Subject: [PATCH 13/42] btrfs-progs: Print more info about device sizes
 
 The entire device size may not be available to the filesystem, eg. if
 it's modified via resize. Print this information if it can be obtained
@@ -22,15 +22,15 @@
 Signed-off-by: David Sterba <[email protected]>
 ---
  cmds-device.c        |  6 +++---
- cmds-fi-disk_usage.c | 13 ++++++++++++-
+ cmds-fi-disk_usage.c | 12 +++++++++++-
  cmds-fi-disk_usage.h |  6 +++++-
- 3 files changed, 20 insertions(+), 5 deletions(-)
+ 3 files changed, 19 insertions(+), 5 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index c20b26e9be90..154188643c8f 100644
+index 96e6309c0185..f9a23ac644c0 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -453,9 +453,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
+@@ -486,9 +486,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
        }
  
        for (i = 0; i < device_info_count; i++) {
@@ -44,7 +44,7 @@
                                device_info_ptr[i].size,
                                info_ptr, info_count,
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 8c0462230510..63ed9ba089d5 100644
+index f984be838e3b..83a3c6d52cc5 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -499,7 +499,8 @@ int load_device_info(int fd, struct device_info 
**device_info_ptr,
@@ -53,7 +53,7 @@
                strcpy(info[ndevs].path, (char *)dev_info.path);
 -              info[ndevs].size = get_partition_size((char *)dev_info.path);
 +              info[ndevs].device_size = get_partition_size((char 
*)dev_info.path);
-+              info[ndevs].size = dev_info.total_size;
++              info[ndevs].size = dev_info.total_bytes;
                ++ndevs;
        }
  
@@ -96,5 +96,5 @@
  
  #endif
 -- 
-1.9.0
+2.1.1
 

++++++ 0025-btrfs-progs-compare-unallocated-space-against-the-co.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From a2b5656ac87bd741153b97ac1e7bcf40ecc4f16c Mon Sep 17 00:00:00 2001
+From f775e02b0210e5128f980a19a5490c58d80bfc27 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Thu, 24 Apr 2014 18:57:12 +0200
-Subject: [PATCH 36/42] btrfs-progs: compare unallocated space against the
+Subject: [PATCH 14/42] btrfs-progs: compare unallocated space against the
  correct value
 
 The device may not be fully occupied by the filesystem, the value of
@@ -11,15 +11,15 @@
 Signed-off-by: David Sterba <[email protected]>
 ---
  cmds-device.c        | 6 ++----
- cmds-fi-disk_usage.c | 9 ++++-----
+ cmds-fi-disk_usage.c | 6 +++---
  cmds-fi-disk_usage.h | 2 +-
- 3 files changed, 7 insertions(+), 10 deletions(-)
+ 3 files changed, 6 insertions(+), 8 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index 154188643c8f..3e851badc116 100644
+index f9a23ac644c0..1de7f007ed43 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -456,10 +456,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
+@@ -489,10 +489,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
                printf("%s, ID: %llu\n", device_info_ptr[i].path,
                                device_info_ptr[i].devid);
                print_device_sizes(fd, &device_info_ptr[i], mode);
@@ -33,18 +33,9 @@
        }
  
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 63ed9ba089d5..0e93dc836f16 100644
+index 83a3c6d52cc5..0ee6e6bb5dc4 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
-@@ -500,7 +500,7 @@ int load_device_info(int fd, struct device_info 
**device_info_ptr,
-               info[ndevs].devid = dev_info.devid;
-               strcpy(info[ndevs].path, (char *)dev_info.path);
-               info[ndevs].device_size = get_partition_size((char 
*)dev_info.path);
--              info[ndevs].size = dev_info.total_size;
-+              info[ndevs].size = dev_info.total_bytes;
-               ++ndevs;
-       }
- 
 @@ -847,7 +847,7 @@ int cmd_filesystem_usage(int argc, char **argv)
        return 0;
  }
@@ -86,5 +77,5 @@
                int chunks_info_count, int mode);
  void print_device_sizes(int fd, struct device_info *devinfo, int mode);
 -- 
-1.9.0
+2.1.1
 

++++++ 0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From d8ca04ddc42461c462e3b52031e1134f01c71663 Mon Sep 17 00:00:00 2001
+From d8f3097050e2b7545aed2119e39e9763f21923a3 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Fri, 25 Apr 2014 17:24:40 +0200
-Subject: [PATCH 37/42] btrfs-progs: add section of overall filesystem usage
+Subject: [PATCH 15/42] btrfs-progs: add section of overall filesystem usage
 
 The 'fi usage' lacks an overall report, this used to be in the enhanced
 df command. Add it back.
@@ -22,7 +22,7 @@
  1 file changed, 13 insertions(+), 12 deletions(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 0e93dc836f16..e17f04e31d35 100644
+index 0ee6e6bb5dc4..92402bea314c 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -302,8 +302,6 @@ static struct btrfs_ioctl_space_args *load_space_info(int 
fd, char *path)
@@ -103,5 +103,5 @@
                close_file_or_dir(fd, dirstream);
  
 -- 
-1.9.0
+2.1.1
 

++++++ 0027-btrfs-progs-cleanup-filesystem-device-usage-code.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From e81d2614ff21e3e9e723cc645cc73646a42d06e8 Mon Sep 17 00:00:00 2001
+From 5f40eaf09d3c21a6422bc03639a46f4a4087f867 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Fri, 25 Apr 2014 19:39:11 +0200
-Subject: [PATCH 38/42] btrfs-progs: cleanup filesystem/device usage code
+Subject: [PATCH 16/42] btrfs-progs: cleanup filesystem/device usage code
 
 The main point of this is to load the device and chunk infos at one
 place and pass down to the printers. The EPERM is handled separately, in
@@ -22,10 +22,10 @@
  3 files changed, 105 insertions(+), 94 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index 3e851badc116..bf5898f6da68 100644
+index 1de7f007ed43..9ab60bcafedc 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -441,31 +441,29 @@ static int _cmd_device_usage(int fd, char *path, int 
mode)
+@@ -474,31 +474,29 @@ static int _cmd_device_usage(int fd, char *path, int 
mode)
  {
        int i;
        int ret = 0;
@@ -71,7 +71,7 @@
  
        return ret;
  }
-@@ -507,6 +505,7 @@ int cmd_device_usage(int argc, char **argv)
+@@ -540,6 +538,7 @@ int cmd_device_usage(int argc, char **argv)
                                argv[1]);
                        return 12;
                }
@@ -80,7 +80,7 @@
                close_file_or_dir(fd, dirstream);
  
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index e17f04e31d35..9d1c4085b4ea 100644
+index 92402bea314c..3be0e6173eec 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -141,7 +141,7 @@ static int cmp_chunk_info(const void *a, const void *b)
@@ -368,5 +368,5 @@
  void print_device_chunks(int fd, struct device_info *devinfo,
                struct chunk_info *chunks_info_ptr,
 -- 
-1.9.0
+2.1.1
 

++++++ 0028-btrfs-progs-rework-calculations-of-fi-usage.patch ++++++
>From 5a16b93f94cfdb7b2028bc9498dd33131254e164 Mon Sep 17 00:00:00 2001
From: David Sterba <[email protected]>
Date: Thu, 26 Jun 2014 15:42:24 +0200
Subject: [PATCH 25/42] btrfs-progs: rework calculations of fi usage

This patch reworks the basic calculations of 'fi usage'. It does not address
all problems but should make the code more prepared to do so.

The original code tries to estimate the free space that could lead to negative
numbers for some raid profiles:

Data, RAID1: total=147.00GiB, used=141.92GiB
System, RAID1: total=32.00MiB, used=36.00KiB
Metadata, RAID1: total=2.00GiB, used=1.17GiB
GlobalReserve, single: total=404.00MiB, used=0.00B

Overall:
    Device size:                 279.46GiB
    Device allocated:            298.06GiB
    Device unallocated:           16.00EiB
    Used:                        286.18GiB
    Free (estimated):              8.00EiB      (min: 8.00EiB)
    Data ratio:                       2.00
    Metadata ratio:                   2.00
    Global reserve:              404.00MiB      (used: 0.00B)

Eg. "Device size" - "Device allocated" = negative number or a very large
positive, hence the EiB values.

There are logical and raw numbers multiplied by ratios mixed together,
so the new code makes it explicit which kind is being used. The data and
metadata ratios are calculated separately.

Output after this patch will look like:

Overall:
    Device size:                 558.92GiB
    Device allocated:            298.06GiB
    Device unallocated:          260.86GiB
    Used:                        286.18GiB
    Free (estimated):            135.51GiB      (min: 135.51GiB)
    Data ratio:                       2.00
    Metadata ratio:                   2.00
    Global reserve:              404.00MiB      (used: 0.00B)

Data,RAID1: Size:147.00GiB, Used:141.92GiB
   /dev/sdc      147.00GiB
   /dev/sdd      147.00GiB

Metadata,RAID1: Size:2.00GiB, Used:1.17GiB
   /dev/sdc        2.00GiB
   /dev/sdd        2.00GiB

System,RAID1: Size:32.00MiB, Used:36.00KiB
   /dev/sdc       32.00MiB
   /dev/sdd       32.00MiB

Unallocated:
   /dev/sdc      130.43GiB
   /dev/sdd      130.43GiB

Changes:
* Device size is now the raw size, same for the following three
* Free is the logical size
* Max/min were reduced to just min

Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc        280G  144G  141G  51% /mnt/sdc

The difference between Avail and Free is there because userspace tool does a
different guesswork than kernel.

Issues not addressed by this patch:
* RAID56 profiles are not handled
* mixed profiles are not handled

Signed-off-by: David Sterba <[email protected]>
---
 cmds-fi-disk_usage.c | 151 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 103 insertions(+), 48 deletions(-)

diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index d95024faf061..6a33b5d1da51 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -306,6 +306,7 @@ static void get_raid56_used(int fd, struct chunk_info 
*chunks, int chunkcount,
        }
 }
 
+#define        MIN_UNALOCATED_THRESH   (16 * 1024 * 1024)
 static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
                int chunkcount, struct device_info *devinfo, int devcount,
                char *path, int mode)
@@ -313,16 +314,33 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
        struct btrfs_ioctl_space_args *sargs = 0;
        int i;
        int ret = 0;
-       int e, width;
-       u64 total_disk;         /* filesystem size == sum of
-                                  device sizes */
-       u64 total_chunks;       /* sum of chunks sizes on disk(s) */
-       u64 total_used;         /* logical space used */
-       u64 total_free;         /* logical space un-used */
-       double K;
-       u64 raid5_used, raid6_used;
-       u64 global_reserve;
-       u64 global_reserve_used;
+       int width = 10;         /* default 10 for human units */
+       /*
+        * r_* prefix is for raw data
+        * l_* is for logical
+        */
+       u64 r_total_size = 0;   /* filesystem size, sum of device sizes */
+       u64 r_total_chunks = 0; /* sum of chunks sizes on disk(s) */
+       u64 r_total_used = 0;
+       u64 r_total_unused = 0;
+       u64 r_data_used = 0;
+       u64 r_data_chunks = 0;
+       u64 l_data_chunks = 0;
+       u64 r_metadata_used = 0;
+       u64 r_metadata_chunks = 0;
+       u64 l_metadata_chunks = 0;
+       u64 r_system_used = 0;
+       u64 r_system_chunks = 0;
+       double data_ratio;
+       double metadata_ratio;
+       /* logical */
+       u64 raid5_used = 0;
+       u64 raid6_used = 0;
+       u64 l_global_reserve = 0;
+       u64 l_global_reserve_used = 0;
+       u64 free_estimated = 0;
+       u64 free_min = 0;
+       int max_data_ratio = 1;
 
        sargs = load_space_info(fd, path);
        if (!sargs) {
@@ -330,27 +348,22 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
                goto exit;
        }
 
-       total_disk = disk_size(path);
-       e = errno;
-       if (total_disk == 0) {
+       r_total_size = 0;
+       for (i = 0; i < devcount; i++)
+               r_total_size += devinfo[i].device_size;
+
+       if (r_total_size == 0) {
                fprintf(stderr,
                        "ERROR: couldn't get space info on '%s' - %s\n",
-                       path, strerror(e));
+                       path, strerror(errno));
 
                ret = 1;
                goto exit;
        }
        get_raid56_used(fd, chunkinfo, chunkcount, &raid5_used, &raid6_used);
 
-       total_chunks = 0;
-       total_used = 0;
-       total_free = 0;
-       global_reserve = 0;
-       global_reserve_used = 0;
-
        for (i = 0; i < sargs->total_spaces; i++) {
-               float ratio = 1;
-               u64 allocated;
+               int ratio;
                u64 flags = sargs->spaces[i].flags;
 
                /*
@@ -372,52 +385,94 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
                else
                        ratio = 1;
 
+               if (!ratio)
+                       fprintf(stderr, "WARNING: RAID56 detected, not 
implemented\n");
+
+               if (ratio > max_data_ratio)
+                       max_data_ratio = ratio;
+
                if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV) {
-                       global_reserve = sargs->spaces[i].total_bytes;
-                       global_reserve_used = sargs->spaces[i].used_bytes;
+                       l_global_reserve = sargs->spaces[i].total_bytes;
+                       l_global_reserve_used = sargs->spaces[i].used_bytes;
+               }
+               if ((flags & (BTRFS_BLOCK_GROUP_DATA | 
BTRFS_BLOCK_GROUP_METADATA))
+                       == (BTRFS_BLOCK_GROUP_DATA | 
BTRFS_BLOCK_GROUP_METADATA)) {
+                       fprintf(stderr, "WARNING: MIXED blockgroups not 
handled\n");
                }
 
-               allocated = sargs->spaces[i].total_bytes * ratio;
+               if (flags & BTRFS_BLOCK_GROUP_DATA) {
+                       r_data_used += sargs->spaces[i].used_bytes * ratio;
+                       r_data_chunks += sargs->spaces[i].total_bytes * ratio;
+                       l_data_chunks += sargs->spaces[i].total_bytes;
+               }
+               if (flags & BTRFS_BLOCK_GROUP_METADATA) {
+                       r_metadata_used += sargs->spaces[i].used_bytes * ratio;
+                       r_metadata_chunks += sargs->spaces[i].total_bytes * 
ratio;
+                       l_metadata_chunks += sargs->spaces[i].total_bytes;
+               }
+               if (flags & BTRFS_BLOCK_GROUP_SYSTEM) {
+                       r_system_used += sargs->spaces[i].used_bytes * ratio;
+                       r_system_chunks += sargs->spaces[i].total_bytes * ratio;
+               }
+       }
 
-               total_chunks += allocated;
-               total_used += sargs->spaces[i].used_bytes;
-               total_free += (sargs->spaces[i].total_bytes -
-                                       sargs->spaces[i].used_bytes);
+       r_total_chunks = r_data_chunks + r_metadata_chunks + r_system_chunks;
+       r_total_used = r_data_used + r_metadata_used + r_system_used;
+       r_total_unused = r_total_size - r_total_chunks;
 
-       }
+       /* Raw / Logical = raid factor, >= 1 */
+       data_ratio = (double)r_data_chunks / l_data_chunks;
+       metadata_ratio = (double)r_metadata_chunks / l_metadata_chunks;
 
+#if 0
        /* add the raid5/6 allocated space */
        total_chunks += raid5_used + raid6_used;
+#endif
 
-       K = ((double)total_used + (double)total_free) / (double)total_chunks;
+       /*
+        * We're able to fill at least DATA for the unused space
+        *
+        * With mixed raid levels, this gives a rough estimate but more
+        * accurate than just counting the logical free space
+        * (l_data_chunks - l_data_used)
+        *
+        * In non-mixed case there's no difference.
+        */
+       free_estimated = (r_data_chunks - r_data_used) / data_ratio;
+       free_min = free_estimated;
+
+       /* Chop unallocatable space */
+       /* FIXME: must be applied per device */
+       if (r_total_unused >= MIN_UNALOCATED_THRESH) {
+               free_estimated += r_total_unused / data_ratio;
+               /* Match the calculation of 'df', use the highest raid ratio */
+               free_min += r_total_unused / max_data_ratio;
+       }
 
-       if (mode == UNITS_HUMAN)
-               width = 10;
-       else
+       if (mode != UNITS_HUMAN)
                width = 18;
 
        printf("Overall:\n");
 
        printf("    Device size:\t\t%*s\n", width,
-               pretty_size_mode(total_disk, mode));
+               pretty_size_mode(r_total_size, mode));
        printf("    Device allocated:\t\t%*s\n", width,
-               pretty_size_mode(total_chunks, mode));
+               pretty_size_mode(r_total_chunks, mode));
        printf("    Device unallocated:\t\t%*s\n", width,
-               pretty_size_mode(total_disk - total_chunks, mode));
+               pretty_size_mode(r_total_unused, mode));
        printf("    Used:\t\t\t%*s\n", width,
-               pretty_size_mode(total_used, mode));
-       printf("    Free (Estimated):\t\t%*s\t(",
+               pretty_size_mode(r_total_used, mode));
+       printf("    Free (estimated):\t\t%*s\t(",
                width,
-               pretty_size_mode((u64)(K * total_disk - total_used), mode));
-       printf("Max: %s, ",
-               pretty_size_mode(total_disk - total_chunks + total_free, mode));
-       printf("min: %s)\n",
-               pretty_size_mode((total_disk-total_chunks) / 2 + total_free, 
mode));
-       printf("    Data to device ratio:\t%*.0f %%\n",
-               width - 2, K * 100);
+               pretty_size_mode(free_estimated, mode));
+       printf("min: %s)\n", pretty_size_mode(free_min, mode));
+       printf("    Data ratio:\t\t\t%*.2f\n",
+               width, data_ratio);
+       printf("    Metadata ratio:\t\t%*.2f\n",
+               width, metadata_ratio);
        printf("    Global reserve:\t\t%*s\t(used: %s)\n", width,
-               pretty_size_mode(global_reserve, mode),
-               pretty_size_mode(global_reserve_used, mode));
+               pretty_size_mode(l_global_reserve, mode),
+               pretty_size_mode(l_global_reserve_used, mode));
 
 exit:
 
-- 
2.1.1

++++++ 0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,21 +1,21 @@
-From a1764abe279f04a664d2745d6d2ce49db722bce3 Mon Sep 17 00:00:00 2001
+From b6789cae1b21f0a8ceec5e60142bfac8a80c1278 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Mon, 28 Apr 2014 18:13:16 +0200
-Subject: [PATCH 40/42] btrfs-progs: replace df_pretty_sizes with
+Subject: [PATCH 17/42] btrfs-progs: replace df_pretty_sizes with
  pretty_size_mode
 
 Signed-off-by: David Sterba <[email protected]>
 ---
  cmds-device.c        |  8 +++----
- cmds-fi-disk_usage.c | 63 ++++++++++++++++++++++------------------------------
+ cmds-fi-disk_usage.c | 68 ++++++++++++++++++++--------------------------------
  cmds-fi-disk_usage.h |  3 ---
- 3 files changed, 30 insertions(+), 44 deletions(-)
+ 3 files changed, 30 insertions(+), 49 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index bf5898f6da68..eb6b79ca5127 100644
+index 9ab60bcafedc..e14eaf61296b 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -471,19 +471,19 @@ exit:
+@@ -504,19 +504,19 @@ exit:
  int cmd_device_usage(int argc, char **argv)
  {
  
@@ -38,7 +38,7 @@
                        break;
                default:
                        usage(cmd_device_usage_usage);
-@@ -506,7 +506,7 @@ int cmd_device_usage(int argc, char **argv)
+@@ -539,7 +539,7 @@ int cmd_device_usage(int argc, char **argv)
                        return 12;
                }
  
@@ -48,28 +48,33 @@
  
                if (r)
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 1e412c0b0e69..d1b8bbddc4d5 100644
+index 3be0e6173eec..579230a79d85 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
-@@ -32,17 +32,6 @@
+@@ -32,22 +32,6 @@
  #include "version.h"
  
  /*
 - * Pretty print the size
+- * PAY ATTENTION: it return a statically buffer
 - */
 -char *df_pretty_sizes(u64 size, int mode)
 -{
+-      static char buf[30];
+-
 -      if (mode & DF_HUMAN_UNIT)
--              return pretty_size_mode(size, UNITS_HUMAN);
+-              (void)pretty_size_snprintf(size, buf, sizeof(buf), 
UNITS_DEFAULT);
 -      else
--              return pretty_size_mode(size, UNITS_RAW);
+-              sprintf(buf, "%llu", size);
+-
+-      return buf;
 -}
 -
 -/*
   * Add the chunk info to the chunk_info list
   */
  static int add_info_to_list(struct chunk_info **info_ptr,
-@@ -389,7 +378,7 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
+@@ -394,7 +378,7 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
  
        K = ((double)total_used + (double)total_free) / (double)total_chunks;
  
@@ -78,7 +83,7 @@
                width = 10;
        else
                width = 18;
-@@ -397,22 +386,22 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
+@@ -402,22 +386,22 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
        printf("Overall:\n");
  
        printf("    Device size:\t\t%*s\n", width,
@@ -109,7 +114,7 @@
  
  exit:
  
-@@ -612,7 +601,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
+@@ -617,7 +601,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
  
                        if (size)
                                table_printf(matrix, col, i+3,
@@ -118,7 +123,7 @@
                        else
                                table_printf(matrix, col, i+3, ">-");
  
-@@ -624,7 +613,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
+@@ -629,7 +613,7 @@ static void _cmd_filesystem_usage_tabular(int mode,
                                - total_allocated;
  
                table_printf(matrix, sargs->total_spaces + 1, i + 3,
@@ -127,7 +132,7 @@
                total_unused += unused;
  
        }
-@@ -636,15 +625,15 @@ static void _cmd_filesystem_usage_tabular(int mode,
+@@ -641,15 +625,15 @@ static void _cmd_filesystem_usage_tabular(int mode,
        table_printf(matrix, 0, device_info_count + 4, "<Total");
        for (i = 0; i < sargs->total_spaces; i++)
                table_printf(matrix, 1 + i, device_info_count + 4, ">%s",
@@ -146,7 +151,7 @@
  
        table_dump(matrix);
        table_free(matrix);
-@@ -670,7 +659,7 @@ static void print_unused(struct chunk_info *info_ptr,
+@@ -675,7 +659,7 @@ static void print_unused(struct chunk_info *info_ptr,
  
                printf("   %s\t%10s\n",
                        device_info_ptr[i].path,
@@ -155,7 +160,7 @@
        }
  }
  
-@@ -704,7 +693,7 @@ static void print_chunk_device(u64 chunk_type,
+@@ -709,7 +693,7 @@ static void print_chunk_device(u64 chunk_type,
                if (total > 0)
                        printf("   %s\t%10s\n",
                                device_info_ptr[i].path,
@@ -164,7 +169,7 @@
        }
  }
  
-@@ -732,10 +721,10 @@ static void _cmd_filesystem_usage_linear(int mode,
+@@ -737,10 +721,10 @@ static void _cmd_filesystem_usage_linear(int mode,
                printf("%s,%s: Size:%s, ",
                        description,
                        r_mode,
@@ -177,7 +182,7 @@
                print_chunk_device(flags, info_ptr, info_count,
                                device_info_ptr, device_info_count, mode);
                printf("\n");
-@@ -787,7 +776,7 @@ const char * const cmd_filesystem_usage_usage[] = {
+@@ -792,7 +776,7 @@ const char * const cmd_filesystem_usage_usage[] = {
  
  int cmd_filesystem_usage(int argc, char **argv)
  {
@@ -186,7 +191,7 @@
        int     i, more_than_one = 0;
        int     tabular = 0;
  
-@@ -800,7 +789,7 @@ int cmd_filesystem_usage(int argc, char **argv)
+@@ -805,7 +789,7 @@ int cmd_filesystem_usage(int argc, char **argv)
  
                switch (c) {
                case 'b':
@@ -195,7 +200,7 @@
                        break;
                case 't':
                        tabular = 1;
-@@ -837,12 +826,12 @@ int cmd_filesystem_usage(int argc, char **argv)
+@@ -842,12 +826,12 @@ int cmd_filesystem_usage(int argc, char **argv)
                        goto cleanup;
  
                ret = print_filesystem_usage_overall(fd, chunkinfo, chunkcount,
@@ -210,7 +215,7 @@
  cleanup:
                close_file_or_dir(fd, dirstream);
                free(chunkinfo);
-@@ -881,22 +870,22 @@ void print_device_chunks(int fd, struct device_info 
*devinfo,
+@@ -886,22 +870,22 @@ void print_device_chunks(int fd, struct device_info 
*devinfo,
                        description,
                        r_mode,
                        (int)(20 - strlen(description) - strlen(r_mode)), "",
@@ -259,5 +264,5 @@
                struct chunk_info *chunks_info_ptr,
                int chunks_info_count, int mode);
 -- 
-1.9.0
+2.1.1
 

++++++ 0030-btrfs-progs-clean-up-return-codes-and-paths.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From 2c574dd5564fbe11a9e6e9c707fa907a7418c687 Mon Sep 17 00:00:00 2001
+From 3844fa84722d395a584ed8b331e89dc55361dd90 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Mon, 28 Apr 2014 18:55:05 +0200
-Subject: [PATCH 41/42] btrfs-progs: clean up return codes and paths
+Subject: [PATCH 18/42] btrfs-progs: clean up return codes and paths
 
 Use the common patterns with one return statement at the end, pass down error
 
@@ -12,10 +12,10 @@
  2 files changed, 34 insertions(+), 32 deletions(-)
 
 diff --git a/cmds-device.c b/cmds-device.c
-index eb6b79ca5127..6dd5b05c7651 100644
+index e14eaf61296b..a728f2102f5c 100644
 --- a/cmds-device.c
 +++ b/cmds-device.c
-@@ -448,10 +448,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
+@@ -481,10 +481,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
  
        ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount, &devinfo,
                        &devcount);
@@ -28,7 +28,7 @@
  
        for (i = 0; i < devcount; i++) {
                printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
-@@ -461,7 +459,7 @@ static int _cmd_device_usage(int fd, char *path, int mode)
+@@ -494,7 +492,7 @@ static int _cmd_device_usage(int fd, char *path, int mode)
                printf("\n");
        }
  
@@ -37,7 +37,7 @@
        free(devinfo);
        free(chunkinfo);
  
-@@ -472,6 +470,7 @@ int cmd_device_usage(int argc, char **argv)
+@@ -505,6 +503,7 @@ int cmd_device_usage(int argc, char **argv)
  {
  
        int mode = UNITS_HUMAN;
@@ -45,7 +45,7 @@
        int     i, more_than_one = 0;
  
        optind = 1;
-@@ -494,28 +493,28 @@ int cmd_device_usage(int argc, char **argv)
+@@ -527,28 +526,28 @@ int cmd_device_usage(int argc, char **argv)
                usage(cmd_device_usage_usage);
  
        for (i = optind; i < argc ; i++) {
@@ -84,7 +84,7 @@
  
  const struct cmd_group device_cmd_group = {
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index d1b8bbddc4d5..7c93247e4f54 100644
+index 579230a79d85..e088956f9409 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -68,7 +68,7 @@ static int add_info_to_list(struct chunk_info **info_ptr,
@@ -229,5 +229,5 @@
  
  void print_device_chunks(int fd, struct device_info *devinfo,
 -- 
-1.9.0
+2.1.1
 

++++++ 0031-btrfs-progs-move-global-reserve-to-overall-summary.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:22.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:22.000000000 +0100
@@ -1,7 +1,7 @@
-From 552e2741a3b0ce344c73b3e1d80d385605d49e75 Mon Sep 17 00:00:00 2001
+From c440e750f10ec3a57e7fe204c5a9809c59590126 Mon Sep 17 00:00:00 2001
 From: David Sterba <[email protected]>
 Date: Tue, 29 Apr 2014 17:32:22 +0200
-Subject: [PATCH 42/42] btrfs-progs: move global reserve to overall summary
+Subject: [PATCH 19/42] btrfs-progs: move global reserve to overall summary
 
 It looks confusing among the chunks, it is not in fact a chunk type.
 
@@ -22,7 +22,7 @@
  1 file changed, 20 insertions(+), 2 deletions(-)
 
 diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
-index 7c93247e4f54..0caba159b974 100644
+index e088956f9409..2c3c0a3ed51e 100644
 --- a/cmds-fi-disk_usage.c
 +++ b/cmds-fi-disk_usage.c
 @@ -319,6 +319,8 @@ static int print_filesystem_usage_overall(int fd, struct 
chunk_info *chunkinfo,
@@ -75,7 +75,7 @@
 +              if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
 +                      continue;
 +
-               description = group_type_str(flags);
+               description = btrfs_group_type_str(flags);
  
                table_printf(matrix, 1+i, 0, "<%s", description);
 @@ -715,8 +730,11 @@ static void _cmd_filesystem_usage_linear(int mode,
@@ -88,9 +88,9 @@
 +              if (flags & BTRFS_SPACE_INFO_GLOBAL_RSV)
 +                      continue;
 +
-               description= group_type_str(flags);
-               r_mode = group_profile_str(flags);
+               description = btrfs_group_type_str(flags);
+               r_mode = btrfs_group_profile_str(flags);
  
 -- 
-1.9.0
+2.1.1
 

++++++ 0042-btrfs-progs-fix-linking-with-libbtrfs.patch ++++++
>From b64e66feed24dd9fc008e96f0d5371b0bd0eb019 Mon Sep 17 00:00:00 2001
From: David Sterba <[email protected]>
Date: Thu, 30 Oct 2014 18:33:41 +0100
Subject: [PATCH 42/42] btrfs-progs: fix linking with libbtrfs

Reported at https://github.com/openSUSE/snapper/issues/128

Commit cdb9e22e292275237c added another rbtree file that defines
functions that libbtrfs uses.

Signed-off-by: David Sterba <[email protected]>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 7f76447e3c55..7368502b5416 100644
--- a/Makefile
+++ b/Makefile
@@ -10,14 +10,14 @@ objects = 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 \
          extent-cache.o extent_io.o volumes.o utils.o repair.o \
          qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
-         ulist.o qgroup-verify.o backref.o rbtree-utils.o string-table.o
+         ulist.o qgroup-verify.o backref.o string-table.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
               cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
               cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
               cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
               cmds-property.o cmds-fi-disk_usage.o
 libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
-                  uuid-tree.o utils-lib.o
+                  uuid-tree.o utils-lib.o rbtree-utils.o
 libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
               crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
               extent_io.h ioctl.h ctree.h btrfsck.h version.h
-- 
2.1.1

++++++ 0043-btrfs-progs-libbtrfs-make-exported-headers-compatibl.patch ++++++
>From cafacda441120976105d01c07286e843cb7cbb94 Mon Sep 17 00:00:00 2001
From: David Sterba <[email protected]>
Date: Mon, 3 Nov 2014 23:50:50 +0100
Subject: [PATCH] btrfs-progs: libbtrfs, make exported headers compatible with
 C++

Add externs and don't use a reserved keyword.

Signed-off-by: David Sterba <[email protected]>
---
 rbtree-utils.h     |  8 ++++++++
 rbtree.h           | 10 +++++++++-
 rbtree_augmented.h |  8 ++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/rbtree-utils.h b/rbtree-utils.h
index 7298c72eba3d..718581ff105c 100644
--- a/rbtree-utils.h
+++ b/rbtree-utils.h
@@ -21,6 +21,10 @@
 
 #include "rbtree.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* The common insert/search/free functions */
 typedef int (*rb_compare_nodes)(struct rb_node *node1, struct rb_node *node2);
 typedef int (*rb_compare_keys)(struct rb_node *node, void *key);
@@ -42,4 +46,8 @@ static void free_##name##_tree(struct rb_root *root)  \
        rb_free_nodes(root, free_func);                 \
 }
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
diff --git a/rbtree.h b/rbtree.h
index 03c06d8ec16a..0d4f2bfd5a5e 100644
--- a/rbtree.h
+++ b/rbtree.h
@@ -34,6 +34,10 @@
 #include <btrfs/kerncompat.h>
 #endif /* BTRFS_FLAT_INCLUDES */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct rb_node {
        unsigned long  __rb_parent_color;
        struct rb_node *rb_right;
@@ -75,7 +79,7 @@ extern struct rb_node *rb_first_postorder(const struct 
rb_root *);
 extern struct rb_node *rb_next_postorder(const struct rb_node *);
 
 /* Fast replacement of a single node without remove/rebalance/add/rebalance */
-extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, 
+extern void rb_replace_node(struct rb_node *victim, struct rb_node *new_node,
                            struct rb_root *root);
 
 static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
@@ -107,4 +111,8 @@ static inline void rb_link_node(struct rb_node * node, 
struct rb_node * parent,
                        typeof(*pos), field); 1; }); \
             pos = n)
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LINUX_RBTREE_H */
diff --git a/rbtree_augmented.h b/rbtree_augmented.h
index 079eb978dc4d..cbc963981667 100644
--- a/rbtree_augmented.h
+++ b/rbtree_augmented.h
@@ -26,6 +26,10 @@
 
 #include "rbtree.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * Please note - only struct rb_augment_callbacks and the prototypes for
  * rb_insert_augmented() and rb_erase_augmented() are intended to be public.
@@ -228,4 +232,8 @@ rb_erase_augmented(struct rb_node *node, struct rb_root 
*root,
                __rb_erase_color(rebalance, root, augment->rotate);
 }
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _LINUX_RBTREE_AUGMENTED_H */
-- 
2.1.1

++++++ btrfs-progs-v3.16.2.tar.gz -> btrfs-progs-v3.17.tar.gz ++++++
++++ 8004 lines of diff (skipped)

++++++ local-version-override.patch ++++++
--- /var/tmp/diff_new_pack.dMOV45/_old  2014-11-11 09:59:23.000000000 +0100
+++ /var/tmp/diff_new_pack.dMOV45/_new  2014-11-11 09:59:23.000000000 +0100
@@ -6,8 +6,8 @@
  # Copyright 2008, Oracle
  # Released under the GNU GPLv2
   
--v="v3.16.2"
-+v="v3.16.2+20141003"
+-v="v3.17"
++v="v3.17+20141103"
  
  lib_major=0
  lib_minor=1

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to