Commit Graph

267 Commits (d1efe50d0a64e757fac0775858ea92e1266ce16d)

Author SHA1 Message Date
Gu Jinxiang 64a938ff70 btrfs-progs: add prerequisite btrfs-image for test-fuzz
Since tests/fuzz-tests/002-simple-image/test.sh need the btrfs-image for
prerequisite.  So add the dependency in Makefile.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
Gu Jinxiang 837c850415 btrfs-progs: add prerequisite mkfs.btrfs for test-cli
Since tests/cli-tests/002-balance-full-no-filters/test.sh need
the mkfs.btrfs for prerequisite.
So add the dependency in Makefile.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-13 15:41:32 +01:00
David Sterba 6d3fea8f46 btrfs-progs: check: rename files after moving code
Add prefixes to the files so it's clear they belong to the mode group.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-02 16:01:59 +01:00
Qu Wenruo b8d706e58e btrfs-progs: check: Move lowmem check code to its own check/lowmem.[ch]
Since lowmem mode code is highly internally connected, it's pretty hard to
move them piece by piece.
In theory it's possible to move part of the functions and temporarily
export them, but it will just cause extra temporarily modifications.

So this patch moves the whole lowmem check part into its own
check/lowmem.[ch].

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-02 16:01:59 +01:00
Qu Wenruo b695ef1ddc btrfs-progs: check: Move count_csum_range function to check/common.c
Despite of moving it to check/common.c, also:

1) Add extra comment of the function
2) Change @root parameter to @fs_info
   Since @root is never used, csum_root is picked from fs_info anyway.

Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-02 16:01:58 +01:00
Qu Wenruo c772db30e9 btrfs-progs: Move cmds-check.c to check/main.c
Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-02-02 16:01:57 +01:00
David Sterba 2e1932e6a3 btrfs-progs: build: simplify version tracking
There will be a plain file tracking the last released version.

The rest will be simplified to print it where needed. The version
augmented by the current git status was not working anyway since we've
switched to autoconf. The result of version.h with the potential git
status was generated at configure time, which does not mean it's
accurate regarding the git status.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-31 15:14:01 +01:00
Gu Jinxiang 60fa9e945f btrfs-progs: build: Remove unused variable TESTS
Variable is never used.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 19:25:05 +01:00
Hans van Kranenburg 9303f1dd1b btrfs-progs: Fix progs_extra build dependencies
The Makefile does not have a dependency path that builds dependencies
for tools listed in progs_extra.

E.g. doing make btrfs-show-super in a clean build environment results in:
    gcc: error: cmds-inspect-dump-super.o: No such file or directory
    Makefile:389: recipe for target 'btrfs-show-super' failed

Signed-off-by: Hans van Kranenburg <hans@knorrie.org>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 18:18:29 +01:00
Qu Wenruo 075580471e btrfs-progs: mkfs: move image creation of rootdir to its own files
In fact, --rootdir option is getting more and more independent from
normal mkfs code.

So move image creation function, make_image() and its related code to
mkfs/rootdir.[ch], and rename the function to btrfs_mkfs_fill_dir().

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-01-08 18:11:24 +01:00
David Sterba ea085932dc btrfs-progs: image: move sanitization to new file
Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
David Sterba af524c9539 btrfs-progs: build: use variables for btrfs-image images
More separate sources will be created for btrfs-image.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-11-14 15:59:00 +01:00
Naohiro Aota 0792c17028 btrfs-progs: build: set include path relatively
Currently, gcc is passed the include directory with full path. As a result,
dependency files (*.o.d) also record the full path at the build time. Such
full path dependency is annoying for sharing the source between multiple
machines, containers, or anything the path differ.

And this is the same way what other program using autotools e.g. e2fsprogs
is doing:

$ grep top_builddir Makefile
top_builddir = .
CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib
BUILD_CFLAGS = -g -O2  -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -DHAVE_CONFIG_H
<snip>

Signed-off-by: Naohiro Aota <naota@elisp.net>
[ set TOPDIR=. instead of -I as discussed, does not harm linker ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:16:01 +02:00
David Sterba aafb4593fe btrfs-progs: build: add absolute path for topdir
We'll need TOPDIR to be ./ but library-test is intentionally built
outside of the git repository so we need to make them separate.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-13 20:15:58 +02:00
David Sterba 15beadeaa2 btrfs-progs: build: add more sparse warning checks
- declarations after statements (style issue)
- bitfields without defined signedness

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:44 +02:00
David Sterba 5d57bdeb23 btrfs-progs: build: use -std=gnu89 for sparse
Sparse does not seem to support gnu90 that we'd like to keep for the
regular build. Use gnu89 for C=1 build.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:40 +02:00
David Sterba 4498f53707 btrfs-progs: build: add missing defines for the C=1 build
Sparse complains that BTRFSCONVERT_EXT2 and _RESIERFS are not defined.
The per-target options are missing from the default CFLAGS and only
added in the specific rule.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:37 +02:00
Naohiro Aota 3efd322db2 btrfs-progs: build: omit unnecessary -MD flag
According to gcc(1), "-MD is equivalent to -M -MF file, except that -E is not
implied." Since the rule in the Makefile is just generating dependency file
and not building object file, it is no use to have "-MD" here. Also, it's
overridden and conflicting with the following "-MM" flag. I guess we can drop
it.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:45 +02:00
Naohiro Aota fd8c78a47c btrfs-progs: build: generate all dependency files
We're missing several dependency files like:

$ diff -u <(find -name '*.o'|cut -d. -f2|sort) <(find -name '*.o.d'|cut -d. -f2|sort)
@@ -3,7 +3,6 @@
 /btrfs-corrupt-block
 /btrfs-debug-tree
 /btrfs-find-root
-/btrfs-list
 /btrfs-map-logical
 /btrfs-select-super
 /btrfstune
@@ -29,11 +28,6 @@
 /cmds-scrub
 /cmds-send
 /cmds-subvolume
-/convert/common
-/convert/main
-/convert/source-ext2
-/convert/source-fs
-/convert/source-reiserfs
 /ctree
 /dir-item
 /disk-io
<snip>

This is due to moving things out of objects and cmds_objects variables. Such
missing dependency files cause mis-building of some source files (try touch
utils.h; make mkfs/main.o).

This patch introduce a new variable "all_objects" to keep all the objects and
use the variable to generate proper dependency file building rules.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:42 +02:00
David Sterba bcaadc2e49 btrfs-progs: build: whitespace adjustment of [LD] fssum
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:35 +02:00
Nick Terrell 717a8b1e5d btrfs-progs: Add zstd support
Adds zstd support to the btrfs program. An optional dependency on libzstd
>= 1.0.0 is added. Autoconf accepts `--enable-zstd' or `--disable-zstd' and
defaults to detecting if libzstd is present using `pkg-config'.

The patch is also available in my fork of btrfs-progs [1], which passes
Travis-CI with the new tests. The prebuilt binary is available there.

I haven't updated Android.mk.

[1] https://github.com/terrelln/btrfs-progs/tree/devel

Signed-off-by: Nick Terrell <terrelln@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:13 +02:00
David Sterba 37c271b216 btrfs-progs: move transaction implementation out of header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba a31458b966 btrfs-progs: build: fix asan and ubsan build
Probably with a new gcc (7.1.1) I started to see asan/ubsan link failures.
Fixed by explicitly linking the libraries.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 2e5617c9a6 btrfs-progs: build: fix building libbtrfs.so with tsan
Except libbtrfs.so object, all other tools compile fine. The error is:

ld: send-stream.o: relocation R_X86_64_PC32 against symbol
`stderr@@GLIBC_2.2.5' can not be used when making a shared object;
recompile with -fPIC

Compiling with -fPIC fixes the problem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b8c9c457c1 btrfs-progs: build: properly pass the LDFLAGS during tsan build
The variable LD_FLAGS does not exist and the flags are not used, we need
to use the newly added internal debugging linker flags.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 339019c934 btrfs-progs: build: add internal LDFLAGS for the D= features
We might want to pass additional linker flags for various sanitization
features.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 5d8b645f6f btrfs-progs: build: fix PIE build
Patch from Marcus Meissner <meissner@suse.com>. The CFLAGS are passed to
the linker and mix up the compilation and linker flags for PIE support.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Jeff Mahoney 99340c2ef7 btrfs-progs: convert: add support for converting reiserfs
This patch adds support to convert reiserfs file systems in-place to btrfs.

It will convert extended attribute files to btrfs extended attributes,
translate ACLs, coalesce tails that consist of multiple items into one item,
and convert tails that are too big into indirect files.

This requires that libreiserfscore 3.6.27 be available.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
Qu Wenruo cd30857ceb btrfs-progs: Specify C standard to gnu90 explicitly
Different C compilers have different default language standard.
This sometimes causes problem on different system.

For distribution like CentOS/RHEL7, its gcc is still 4.8 and will report
error for c90 style declaration, while most developers are using newer
gcc which will just ignore it.
This makes us hard to detect such language standard problem.

This patch will specify standard to gnu90 explicitly to avoid such problem.
Gnu90 is a good mix of c90 while provide a lot of useful gnu extension,
and is supported by all modern gcc and clang.

Reported-by: Marco Lorenzo Crociani <marcoc@prismatelecomtesting.com>
Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:06:33 +02:00
David Sterba f929b62ae8 btrfs-progs: build: do not regenerate kernel-lib/tables.c
As reported in
https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg66765.html
cross-compilation does not work very well with current tables.c. We can
simpy keep the pergenerated file in the repository and update if needed.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-08-24 19:06:12 +02:00
Adam Buchbinder 18aed6a623 btrfs-progs: build: Enable ThreadSanitizer, using D=tsan
Tested with clang-3.9. We have to enable PIE,
(https://clang.llvm.org/docs/ThreadSanitizer.html)

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
Adam Buchbinder 50d037b459 btrfs-progs: tests: Fix missing internal deps in check and misc tests
Doing a straight 'make test' would fail because some misc and fsck
tests require particular tools to already be built. Add dependencies
at the Makefile and shell-script level.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-20 17:43:43 +02:00
Qu Wenruo 9604ce49d6 btrfs-progs: raid56: Allow raid6 to recover 2 data stripes
Copied from kernel lib/raid6/recov.c raid6_2data_recov_intx1() function.
With the following modification:
- Rename to raid6_recov_data2() for shorter name
- s/kfree/free/g modification

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Qu Wenruo 084d152407 btrfs-progs: raid56: Introduce tables for RAID6 recovery
Use kernel RAID6 galois tables for later RAID6 recovery.

Galois tables file, kernel-lib/tables.c is generated by user space
program, mktable.

Galois field tables declaration, in kernel-lib/raid56.h, is completely
copied from kernel.

The mktables.c is copied from kernel with minor header/macro
modification, to ensure the generated tables.c works well in
btrfs-progs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Qu Wenruo 5e2a2acc9a btrfs-progs: raid56: Introduce raid56 header for later recovery usage
Introduce a new header, kernel-lib/raid56.h, for later raid56 works.

It contains 2 functions, from original btrfs-progs code:
void raid6_gen_syndrome(int disks, size_t bytes, void **ptrs);
int raid5_gen_result(int nr_devs, size_t stripe_len, int dest, void **data);

Will be expanded later and some part of it(RAID6 recover part) may keep
sync with kernel later.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ unify gpl header, rename header macro ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-07-03 13:35:11 +02:00
Sergei Trofimovich 64c2190d94 btrfs-progs: fix missing __error symbol in libbtrfs.so.0
The easiest way to reproduce the error is to try to build
btrfs-progs with
    $ make LDFLAGS=-Wl,--no-undefined

    btrfs-list.o: In function `lookup_ino_path':
    btrfs-list.c:(.text+0x7d2): undefined reference to `__error'

Noticed by Denis Descheneaux when snapper tool
stopped working after upgrade to btrfs-progs-4.10.

As soname didn't change in 4.9 -> 4.10 release
I assume it's just an object file omission
in library depends and not the API/ABI change
of the library error printing.

Cc: linux-btrfs@vger.kernel.org
Cc: Mike Gilbert <floppym@gentoo.org>
Reported-by: Denis Descheneaux
Bug: https://bugs.gentoo.org/show_bug.cgi?id=613890

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-31 14:17:48 +02:00
Qu Wenruo 230092bc48 btrfs-progs: Cleanup kernel-shared dir when execute make clean
Reported-by: Chris <coderight@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-31 14:17:48 +02:00
David Sterba 02947f4105 btrfs-progs: tests: misc/019, use fssum
The fssum utility is now ready to use, test still passes.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba b5d4b3cef3 btrfs-progs: tests: fssum, switch from MD5 to SHA256
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 12cae4c2c6 btrfs-progs: tests: fssum, drop unnecessray build defines
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 9a98589f00 btrfs-progs: tests: add fssum utility
Copy from fstests, originally from
git://git.kernel.org/pub/scm/linux/kernel/git/arne/far-progs.git

Needs libcrypto to link but this check is now missing in configure.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba f3ec118ab7 btrfs-progs: library-test: update test to build outside of topdir
We need to build outside of the topdir so we can use the "btrfs/" prefix
for includes and not accidentally include other files.

Make magic is simple:
- build dependencies inside TOPDIR
- build inside temporary directory, link back to TOPDIR
- library-test.o not built anymore obviously

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 87b971d0cc btrfs-progs: library: distribute sizes.h, fix build
The patch "btrfs-progs: Introduce kernel sizes to cleanup large
intermediate number" (a2203246ae) was taken from kernel but not
properly ported so the build breaks because the header linux/sizes.h is
not exported.

The build tests of library do not cover the case when the macro
BTRFS_FLAT_INCLUDES is not defined (ie. an external build).

Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-16 17:02:44 +01:00
David Sterba 2b92a224c7 btrfs-progs: tests: fix library-test rules and deps
The symbol __error was undefined and the rule did not use the
dependencies from the rule definiton, like the rest.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:48 +01:00
David Sterba 886a8565e0 btrfs-progs: move ulist.[ch] to kernel-shared
The implementation of ulist_* is same for kernel and userspace, without
dependencies, so we can keep it separately for code sync.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:47 +01:00
David Sterba eb111e9f39 btrfs-progs: move message helpers implementation out of header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 5eff096b78 btrfs-progs: build: use MAKEOPTS where missing
$(MAKE) should also use MAKEOPTS.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 0c94504d06 btrfs-progs: build: drop deprecated utility from test dependencies
Standalone btrfs-debug-tree has been superseded by
'btrfs inspect-internal dump-tree'.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba ed4c7428b7 btrfs-progs: move mkfs helper implementation out of utils
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba d7e3f1d0b7 btrfs-progs: build: build library by default
Add a convenience rule and build the library by default, not just at the
installation phase.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 663253415f btrfs-progs: build: add rule for building cscope index
Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
David Sterba 732056e3d3 btrfs-progs: build: split makefile to generated and stable parts
It's not really necessary to configure and regenerate Makefiles in cases
like adding a new source file. The build environment and optional
features are not affected by that.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-03-08 13:00:46 +01:00
Karel Zak 48e728d112 btrfs-progs: autoconf: add ./configure script
- add ./autogen.sh script (necessary after git clean/clone)
- add ./configure.ac
- copy autotool helper scripts from automake
- modify version.sh to be usable from the configure script
- rename Makefile to Makefile.in and use basic variables from configure.ac

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 17:55:36 +01:00
Dimitri John Ledkov e69e015634 btrfs-progs: drop feature defines from C files, in favour of CFLAGS defines
glibc 2.10+ (5+ years old) enables all the desired features:
_XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a
single _GNU_SOURCE define in the makefile alone. For portability to
other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also
defined.

This also resolves Debian bug report filed by Michael Tautschnig -
"Inconsistent use of _XOPEN_SOURCE results in conflicting
declarations". Whilst I was not able to reproduce the results, the
reported fact is that _XOPEN_SOURCE set to 500 in one set of files
(e.g. cmds-filesystem.c) generates/defines different struct stat from
other files (cmds-replace.c).

This patch thus cleans up all feature defines, and sets them at a
consistent level.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-27 14:45:59 +01:00
David Sterba ca7b429f26 btrfs-progs: tests, adjust alignment of the pretty command name
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-14 18:34:18 +01:00
Qu Wenruo 040b3f11ba btrfs-progs: Makefile: Move linker only option to LDFLAGS
Move the linker only option -rdynamic to LDFLAGS.
This resolve lots of the following warning if using clang as CC:
clang: warning: argument unused during compilation: '-rdynamic'

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-19 15:04:43 +01:00
David Sterba bae5edfde8 btrfs-progs: remove false dependency on libm
It ends up in the final binary, but there are not math functions used.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-19 14:59:22 +01:00
David Sterba 4f9d8b1ffa btrfs-progs: tests: build prerequisities, btrfs-image and btrfs
Build required utilities from the main Makefile and just check in the
test scripts.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-12 16:21:42 +01:00
Qu Wenruo 0cc75eddd0 btrfs-progs: Add btrfs_unlink() and btrfs_add_link() functions.
Add btrfs_unlink() and btrfs_add_link() functions in inode.c,
for the incoming btrfs_mkdir() and later inode operations functions.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-10 13:13:06 +01:00
David Sterba 0c753f13e9 btrfs-progs: remove duplicate pthread libs from build
With the task-utils it's in the default LIBS flags now. We want to use
-pthread as it also sets flags for the preprocessor.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 17:21:10 +01:00
Silvio Fricke 48e06b7fa4 btrfs-progs: convert: use task for progress indication of metadata creation
Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 17:13:44 +01:00
Goffredo Baroncelli cbda6f2527 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
tabular format.

The function
	struct string_table *table_create(int columns, int rows)
creates an (empty) table.

The functions
	char *table_printf(struct string_table *tab, int column,
		int row, char *fmt, ...)
	char *table_vprintf(struct string_table *tab, int column,
		int row, char *fmt, va_list ap)
populate the table with text. To align the text to the left, the text
shall be prefixed with '<', otherwise the text shall be prefixed by a
'>'. If the first character is a '=', the the text is replace by a
sequence of '=' to fill the column width.

The function
	void table_free(struct string_table *)
frees all the data associated to the table.

The function
	void table_dump(struct string_table *tab)
prints the table on stdout.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:09 +01:00
Goffredo Baroncelli e12e91e859 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 <kreijack@inwind.it>
[code moved under #if 0 instead of deletion]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-12-04 16:48:09 +01:00
David Sterba 6d95e999ad btrfs-progs: build, update the clean rule
Remove duplicate files, add extra progs, add library test binaries.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-07 17:52:58 +01:00
David Sterba 3fba49eab8 btrfs-progs: build, gather utilities that are not built by default
Add them to build test and to clean rules.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-07 17:52:58 +01:00
David Sterba 86be0aeaf6 btrfs-progs: build, add make target for a build test
A quick check that everything still builds.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-07 17:52:58 +01:00
David Sterba effebebb42 btrfs-progs: build, add basic build test for library
Basic test based on snapper code that uses the send stream API.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-07 17:52:57 +01:00
David Sterba dcf11c371c btrfs-progs: fix linking with libbtrfs
Reported at https://github.com/openSUSE/snapper/issues/128

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

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-11-03 18:42:34 +01:00
Josef Bacik cdb9e22e29 Btrfs-progs: break out rbtree util functions
These were added to deal with duplicated functionality within btrfs-progs, but
we specifically copied rbtree.c from the kernel, so move these functions out
into their own file.  This will make it easier to keep rbtree.c in sync.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-14 10:39:39 +02:00
Josef Bacik d90d8d2323 Btrfs-progs: pull back backref.c and fix it up
This patch pulls back backref.c, adds a couple of helpers everywhere that it
needs, and cleans up backref.c to fit in btrfs-progs.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
[removed free_some_buffers after "do not reclaim extent buffer"]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-14 10:39:38 +02:00
Gustavo Zacarias 05499d865f btrfs-progs: add option to disable backtrace usage
This commit adds the support for a make variable named
"DISABLE_BACKTRACE" which allows to disable the support for backtrace()
usage on ASSERT(), BUG() and BUG_ON() calls.
This is useful because some alternative C libraries like uClibc have
optional support for backtrace() which is rarely built when debugging
isn't taking place.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-10 10:38:38 +02:00
Josef Bacik 3ae0209d94 Btrfs-progs: make BUG*() be more verbose
Currently these macros just tie to assert(), which gives us line number and such
but no backtrace so no actual context.  This patch adds support for spitting out
a backtrace so we can see how we got to the given assert.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
[backtrace_symbols_fd]
Signed-off-by: Naohiro Aota <naota@elisp.net>
[minor fixups]
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-10-01 16:34:29 +02:00
Thomas Petazzoni 1cb7bd2f3c btrfs-progs: Improve static building and installation
This commit improves the static-only building of btrfs-progs, and adds
support for installing the static only tools:

 - It now ensures that all programs are built statically, not only a
   small subset of them, by defining 'progs_static' from the existing
   'progs' variable.

 - It changes the order of libraries in the btrfs-%.static rule so
   that -lpthread (part of STATIC_LIBS) appears *after* the '$($(subst
   -,_,$(subst .static,,$@)-libs))' logic, which brings in
   -lcom_err. This is needed because libcom_err.a uses the semaphore
   functions, which are available in the pthread library.

 - Adds the necessary rules to generate the btrfsck.static link and
   btrfstune.static binary.

 - Adds an 'install-static' target to install the static
   binaries. Note that they are renamed to not carry a '.static'
   suffix.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:23 +02:00
Gustavo Zacarias ef208e98ce btrfs-progs: Add support for DISABLE_DOCUMENTATION
This commit adds the support for a make variable named
"DISABLE_DOCUMENTATION", which allows to disable the build of the
documentation. This is useful in contexts where the tools needed to
build the documentation are not necessarily available.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:05:15 +02:00
Arvin Schnell 68b50d43c0 btrfs-progs: library version defines
commit 46de1a6ec3 changed the
parameters of btrfs_read_and_process_send_stream().  This breaks
snapper compilation. We can include version defines usable for the C
preprocessor.

Version 0.1.0: API up to and including 46de1a6ec3 (3.14.x)

Version 0.1.1: 909131939f (changed in 3.16)

Signed-off-by: Arvin Schnell <aschnell@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-09-02 17:04:15 +02:00
Nils Steinger 2e1accf4fd btrfs-progs: Add uninstall targets to Makefiles.
Signed-off-by: Nils Steinger <git@n-st.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
David Sterba ac9dccad72 btrfs-progs: fix build of static target
A user repoted that static buid fails with

utils-lib.static.o: In function `arg_strtou64':
/home/dsterba/labs/btrfs-progs/utils-lib.c:17: multiple definition of `arg_strtou64'
utils-lib.static.o:/home/dsterba/labs/btrfs-progs/utils-lib.c:17: first defined here

utils-lib.o was mistakenly added to linker twice.

Signed-off-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
2014-08-22 15:07:01 +02:00
Adam Buchbinder 2100836188 btrfs-progs: Add some simple end-to-end tests for btrfs-convert
These use the system's mke2fs, and don't require loop devices
or root privileges.

They don't pick up anything with the default flags right now,
but they do pick up some sanitizer issues when the tools are
compiled with any of -fsanitize={address,memory,thread}.

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:35 +02:00
Mark Fasheh 96ec888aad btrfs-progs: add quota group verify code
This patch adds functionality (in qgroup-verify.c) to compute bytecounts in
subvolume quota groups. The original groups are read in and stored in memory
so that after we compute our own bytecounts, we can compare them with those
on disk. A print function is provided to do this comparison and show the
results on the console.

A 'qgroup check' pass is added to btrfsck. If any subvolume quota groups
differ from what we compute, the differences for them are printed.  We also
provide an option '--qgroup-report' which will run only the quota check code
and print a report on all quota groups.  Other than making it possible to
verify that our qgroup changes work correctly, this mode can also be used in
xfstests for automated checking after qgroup tests.

This patch does not address the following:
- compressed counts are identical to non compressed, because kernel doesn't
  make the distinction yet.  Adding the code to verify compressed counts
  shouldn't be hard at all though once kernel can do this.
- It is only concerned with subvolume quota groups (like most of
  btrfs-progs).

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:33 +02:00
Mark Fasheh 2ab405af95 btrfs-progs: import ulist
qgroup-verify.c wants this for walking root refs.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:33 +02:00
Eric Sandeen 11ffe23531 btrfs-progs: fix btrfs-fragments build
When I made all the btrfs-foo.c targets generic, I somehow
managed to break the libs definition for btrfs-fragments by
dropping the "s" off the end.

Fix that, although apparently nobody is building this tool.  :)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:32 +02:00
David Sterba aa46922c09 btrfs-progs: move arg_strtou64 to a separate file for library
Linking with libbtrfs fails because arg_strtou64 is not defined and we
cannot just add utils.o to library objects because it's not
library-clean.

Reported-by: Arvin Schnell <aschnell@suse.com>
Reported-by: Anton Farygin <rider@altlinux.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-05-02 17:04:28 +02:00
David Sterba fd287d868f btrfs-progs: add separate make target to clean docs
Regenerating the asciidoc takes much longer now and makes quick build
tests long. There's separate clean-doc target for that and clean-all
that cleans docs and sources.

Signed-off-by: David Sterba <dsterba@suse.cz>
2014-04-22 14:15:25 +02:00
Qu Wenruo 7151a86539 btrfs-progs: Switch to the new asciidoc Documentation.
Since all man page are converted to the new asciidoc, the old man page
can be removed.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-04-22 14:15:24 +02:00
Alexander Block 85be2aaf91 Btrfs-progs: introduce btrfs property subgroup
"btrfs filesystem property" is a generic interface to set/get
properties on filesystem objects (inodes/subvolumes/filesystems
/devs).

This patch adds the generic framework for properties and also
implements two properties. The first is the read-only property
for subvolumes and the second is the label property for devices.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:31 -08:00
David Sterba b085b145b6 btrfs-progs: add fsck.btrfs stub and manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:13 -08:00
Chris Mason 8116550e16 Add -fno-strict-aliasing
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-22 08:41:50 -05:00
Emil Karlson e11a9ae9bd btrfs-progs: remove extra uuid-tree.o in objects
This fixes static compile target of btrfs-progs.

Signed-off-by: Emil Karlson <jekarlson@gmail.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-11 16:05:06 -05:00
Josef Bacik 0d342f8fcb Btrfs-progs: add make test framework
We need to start adding some sanity tests to btrfs-progs to make sure we aren't
breaking things with our patches.  The most important of these tools is btrfsck.
This patch gets things started by adding a basic btrfsck test that makes sure we
can fix a corruption problem we know we can fix.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:23:11 -04:00
Wang Shilong 7985fe64e0 Btrfs-progs: add super-recover to recover bad supers
Until now if one of device's first superblock is corrupt,btrfs will
fail to mount. Luckily, btrfs have at least two superblocks for
every disk.

In theory, if silent corrupting happens when we are writting superblocks
into disk, we must hold at least one good superblock.

One side effect is that user must gurantee that the disk must be
a btrfs disk. Otherwise, this tool may destroy other fs.(This is also
reason why btrfs only use first superblock in every disk to mount)

This little program will try to correct bad superblocks from
good superblocks with max generation.

There will be five kinds of return values:

0: all supers are valid, no need to recover
1: usage or syntax error
2: recover all bad superblocks successfully
3: fail to recover bad superblocks
4: abort to recover bad superblocks

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:23:08 -04:00
David Sterba 4e466c8b44 btrfs-progs: add list_sort and use it to sort devices by id
The devices in 'btrfs filesystem show' are now sorted by the device id,
currently the order was undefined.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:22:26 -04:00
David Sterba e9270f6209 btrfs-progs: separate command and implementation of chunk-recover code
The command has been moved and we should rename the files accordingly,
so the entry point is now in cmds-rescue.c and the core functionality
in it's own file.

Return codes of btrfs_recover_chunk_tree have been simplified not to
require a define and another file for defintion.

CC: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:22:23 -04:00
David Sterba 133b1b0377 btrfs-progs: introduce rescue command group
Add an empty 1st level command namespace that will collect specialized
recovery tools like chunk-recover, zero-log, select-super and similar.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:21:36 -04:00
Eric Sandeen dd4d4260d1 Btrfs-progs: Add Makefile infrastructure for subdirs
Preparatory patch to move cmd & test files into their
own subdirs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-09-10 01:34:50 +02:00
Zach Brown 5ac75e2af2 btrfs-progs: get C=1 sparse checking working again
There were a few problems that were breaking sparse checking:

- We were defining CHECK_ENDIAN late in the environment, after
  linux/fs.h has been included which defines __force and __bitwise in
  confusing ways that conflict with ours.  Define it up with __CHECKER__
  so that linux/fs.h and our copy are acting on the same input.

- We had manually set a few of gcc's internal defines to give to sparse.
  It's easier to just ask gcc for all the defines it sets and hand those
  to sparse.

- We weren't passing the same *FLAGS to sparse as we were to CC.

- glibc has so many errors with FORTIFY turned on that sparse gives up
  and doesn't show us any errors from our code.  It's a questionable
  hack to always turn on FORTIFY ourselves, so we'll just not do that
  when building with sparse.

And add a nice '[SP]' quiet output line for sparse checks.

Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-09-03 19:41:12 +02:00
Kusanagi Kouichi 59ac11e41a btrfs-progs: Fix automatic prerequisite generation
Some files don't compile because of insufficient prerequisite.

$ make btrfs
...
    [CC]     btrfs.o
btrfs.c:24:21: fatal error: version.h: No such file or directory
 #include "version.h"
                     ^
compilation terminated.
make: *** [btrfs.o] Error 1

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-08-09 14:32:34 +02:00
Stefan Behrens ad280c1b3a Btrfs-progs: add UUID tree lookup methods
This commit adds UUID tree lookup methods that make use of the search
ioctl. The code is based on the kernel code.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-08-09 14:32:31 +02:00
Richard W.M. Jones 1a29ad83f9 libbtrfs: Set SONAME to "libbtrfs.so.0" (instead of "libbtrfs.so").
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-08-09 14:32:29 +02:00
Eric Sandeen cc94701a73 Btrfs-progs: make btrfsck a hardlink at install time
btrfsck gets hardlinked to btrfs during the build, but the
install phase simply copies them both to the destination without
preserving the link.

Just force-link btrfsck in the destination again during install
so that the installed btrfsck is a link as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-08-09 14:32:29 +02:00
Miao Xie 30d5c8a49f Btrfs-progs: Add chunk recover function - using old chunk items
Add chunk-recover program to check or rebuild chunk tree when the system
chunk array or chunk tree is broken.

Due to the importance of the system chunk array and chunk tree, if one of
them is broken, the whole btrfs will be broken even other data are OK.

But we have some hint(fsid, checksum...) to salvage the old metadata.
So this function will first scan the whole file system and collect the
needed data(chunk/block group/dev extent), and check for the references
between them. If the references are OK, the chunk tree can be rebuilt and
luckily the file system will be mountable.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-07-03 14:06:55 -04:00