Commit Graph

73 Commits

Author SHA1 Message Date
David Sterba 4884ae2f5e btrfs-progs: tests: enhance TEST_LOG features
Add new keyword to dump the log file after any test fails. Can be useful
for remote analysis of test failures.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-23 10:51:43 +01:00
Qu Wenruo 4dc315e68a btrfs-progs: remove send-test tool
Since new "receive --dump" has better output and structure, it's time
to remove old and function-weak send-test tool.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-09 13:47:28 +01:00
Qu Wenruo fd48a96b9a btrfs-progs: rename raid6.c to raid56.c
This allows us to put raid5 codes into that file other than creating a
new raid5.c.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 15:03:20 +02:00
David Sterba e0c979343d btrfs-progs: test: add default ioctl-test build
Add another target that'll use default compiler options, eg. if we don't
know the bitness of the architecture or gcc does not recognize the
-m32/-m64 options.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:57:32 +02:00
David Sterba 6f306e8d62 btrfs-progs: tests: make the ioctl-test actually useful
Enhance the test to verify ioctl uniqueness, compare the defined values
against the hardcoded expected values, and take care of the 32bit/64bit
compatibility workarounds.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:57:19 +02:00
David Sterba 5aade6f9c3 btrfs-progs: ioctl: make build-time structure size checks optional
Temporarily make the build checks optional. The structure sizes could
change on arches due to alignment requirements or padding inserted into
the structures. We need more extensive tests to make sure we'd not break
ioctls.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 10:11:31 +02:00
David Sterba 01ddfdbbcb btrfs-progs: build: add explicit option separator to rm commands
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:24 +02:00
David Sterba eae42a1fe4 btrfs-progs: build: add alias for check tests
$ make test-check"

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 1200be31e6 btrfs-progs: move 3rd party kernel library modules to own directory
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
David Sterba 605ed50b8c btrfs-progs: build: add basic support for subdirectory build
Add explicit target file names and set the top source directory.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00
David Sterba 9cc6e92972 btrfs-progs: build: add UBSAN to debugging features
usage: make D=ubsan

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 11:46:47 +02:00
David Sterba 857e55ab02 btrfs-progs: build: add ASAN to debugging features
usage: make D=asan

Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-05 12:20:24 +02:00
David Sterba 73071f0ce4 btrfs-progs: build: extend convert options
Add --with-convert[=VALUE] option to configure. Accepts ext2, auto, yes,
or no, but will be extended to more in the future. The configure-time
defines are not used in the code, ext2 is built-in unconditionally.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba aa07e4be00 btrfs-progs: build: add per-tool cflags variable
The standalone tools are built from pattern rules, add support for
per-tool cflaags, like btrfs_something_clfags.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-24 14:37:36 +02:00
David Sterba 4241e27ee1 btrfs-progs: build: add more debugging features
Add options to show file and line or stack trace for error/warning
messages that use the common helpers. Possible to let any error stop
execution for ease of analysis and debugging.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-08-22 16:44:22 +02:00
David Sterba 6a0d3bf28d btrfs-progs: makefile: add target for testing installation
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
Anand Jain b5ae826637 btrfs-progs: makefile: add clean-all to the usage
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 2e8b5209c8 btrfs-progs: build: add support for debugging builds
Add an easy way to build a debugging version, without optimizations and
with debugging info by default. Any overrides can be done via
DEBUG_CFLAGS that are added on top of the defaults. Can be combined with
V, C or W options.

Usage:
  $ make D=1

Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
Jeff Mahoney 62c0666378 btrfs-progs: udev: add rules for dm devices
Systemd's btrfs rule runs btrfs dev ready on each device
as it's discovered.  The btrfs command is executed as a builtin
command via an IMPORT{builtin} rule, which means it gets
executed at rule evaluation time, not rule execution time.  That
means that the device mapper links haven't been setup yet and the only
nodes that can be depended upon are /dev/dm-#.  That we see
/dev/mapper/name names in /proc/mounts is only because we replace the
device name we have cached with the one passed in via mount.  If
we have a multi-device file system and the primary device is removed,
the remaining devices will show /dev/dm-#.  In addition, if the
udev rule is executed again by someone generating a change event (e.g.
partprobe), the names are also replaced by the /dev/dm-# names.

This patch adds a new rule that adds a run rule that calls btrfs dev
ready again using the device mapper links once they're created.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
Alexander Fougner d4abd0bfb0 btrfs-progs: copy btrfs-calc-size to inspect-internal tree-stats
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:39:53 +02:00
David Sterba d75f0c12d2 btrfs-progs: tests: add support for command line coverage tests
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:39:46 +02:00
David Sterba 338e5832e7 btrfs-progs: fix build of standalone utilities after clean
$ make clean
$ make btrfs-debug-tree

will fail because the dependency from $(btrfs_debug_tree_objects) is
missing. The variable standalone_deps magically collects all the deps
and will build them in advance. The simple fix to use the existing
substitution based on $@ does not work for pattern rules, as Noah found
out.

Reported-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:25:53 +02:00
Noah Massey 74a5d7478a btrfs-progs: build: fix static standalone utilities
commit b5e7979 "btrfs-progs: build: extend per-binary objects" allows
the standalone utilities to link against object files shared with the
main binary. However, the btrfs-*.static targets need to be adjusted
to build against the static versions of the common files.

Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-30 16:22:47 +02:00
Mark Fasheh a2e7ff1eae btrfs-progs: filesystem: add 'du' command
'btrfs du' differs from regular du in that it will work to resolve which
blocks are shared between files in its list. This gives the user a more
accurate bytecount from which they can make decisions regarding management
of their file space.

We still print a total number of bytes counted (like regular du), but also
print the number of bytes which were found to have been shared amongst the
file set provided. From there it becomes trivial to calculate how much space
is exclusively owned.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
[ rename files to reflect the filesystem command group, add GPL v2
  file headers ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba b5e7979ad2 btrfs-progs: build: extend per-binary objects
The standalone utilities could share object files with the main utility,
add a way to specify additional object files in a similar way to the
extra libs. The variable name must match the binary plus _objects
suffix and  s/-/_/ .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Alexander Fougner eaa93e3b02 btrfs-progs: introduce inspect-internal dump-super
The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Alexander Fougner fcd480a4d0 btrfs-progs: copy functionality of btrfs-debug-tree to inspect-internal subcommand
The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
Hongxu Jia bfc2cb7cfb btrfs-progs: fix symlink creation multiple times
The rule to create symlink in Makefile caused parallel issue:
$ make -j 40 DESTDIR=/image install BUILD_VERBOSE=1
...
  1     [LN]     libbtrfs.so.0
  2     [LN]     libbtrfs.so
  3 ln -s -f libbtrfs.so.0.1 libbtrfs.so.0
  4 ln -s -f libbtrfs.so.0.1 libbtrfs.so.0
  5 ln -s -f libbtrfs.so.0.1 libbtrfs.so
  6 ln -s -f libbtrfs.so.0.1 libbtrfs.so
...

It failed occasionally:
...
|symlinkat: couldn't stat 'git/libbtrfs.so' even though symlink
creation succeeded (No such file or directory).
|ln: failed to create symbolic link 'libbtrfs.so': No such file or directory
...

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-02-26 17:27:58 +01:00
Mike Gilbert 30ce6c76c1 btrfs-progs: Makefile.in: Simplify/correct install-static
install -D does not create the last component, so this failed if
$(DESTDIR)$(bindir) did not already exist.

There's no need for a loop here since install accepts multiple source
arguments.

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-21 19:35:33 +01:00
Noah Massey 1bb0bba1b6 btrfs-progs: fix static build
Change in "btrfs-progs: introduce helper for parsing args without
options" added a dependency on help.o that was duplicated for the static
build.

Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-15 13:31:44 +01:00
David Sterba a6cc8ea10a btrfs-progs: introduce helper for parsing args without options
All commands should support the "--" option separator. This is
transparently handled by getopt, but we don't use that everywhere.
Introduce a helper for commands that take no options (just the path).
The object file dependencies need to be adjusted a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba f9ae914756 btrfs-progs: build: fix builds with extra warnings, W=1
Wrong variable name used in the main makefile.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:55 +01:00
Omar Sandoval e4797df6a9 btrfs-progs: check the free space tree in btrfsck
This reuses the existing code for checking the free space cache, we just
need to load the free space tree. While we do that, we check a couple of
invariants on the free space tree itself. This requires pulling in some
code from the kernel to exclude the super stripes.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:54 +01:00
Byongho Lee dea6b51bae btrfs-progs: get sparse checking working
When I run sparse checking it gives the following error:

 $ make C=1 V=1
 gcc -MM -MG -MF cmds-fi-usage.o.d -MT cmds-fi-usage.o -MT \
 cmds-fi-usage.static.o -MT cmds-fi-usage.o.d -g -O1 -Wall \
 -D_FORTIFY_SOURCE=2 -include config.h -DBTRFS_FLAT_INCLUDES \
 -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC   cmds-fi-usage.c
    [SP]     ctree.c
 sparse -g -O1 -Wall -D_FORTIFY_SOURCE=2 -include config.h \
 -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC \
 -include  -D__CHECKER__ -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized \
 -Wshadow -Wundef -U_FORTIFY_SOURCE ctree.c
 builtin:1:15: error: unable to open '-D__CHECKER__'
 Makefile:177: recipe for target 'ctree.o' failed
 make: *** [ctree.o] Error 1

It means '$(check_defs)' is passed to sparse as NULL and looks
'$(check_defs)'should be assigned before assigning '$(CHECKER_FLAGS)'.
BTW, I'm not familiar with make tool so there could be some my
misunderstanding and better solution.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:01:05 +01:00
David Sterba b85c7b7694 btrfs-progs: tests: add test driver for fuzzed images
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba a141d51696 btrfs-progs: tests: add mkfs tests
Mkfs deserves it's own.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:05 +01:00
David Sterba d3d1a995a5 btrfs-progs: build: make support for static checkers more generic
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-21 14:29:26 +02:00
David Sterba a9a7df9645 btrfs-progs: a bit of makefile documentation
Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-21 14:29:26 +02:00
David Sterba b556a992c3 btrfs-progs: build: allow to build with various compiler warnings
Copied from linux kernel, 'make W=1' will build with various additional
warnings turned on. There are 3 levels, combinations are possible. The
build is quite noisy, not all warnings need to be fixed.

A specific warning can be turned on by 'make EXTRA_CFLAGS=-Wsomething'.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-10-21 14:29:26 +02:00
Arnd Hannemann afff169e1a btrfs-progs: makefile: drop u option from ar invocation
In newer distros (ubuntu 15.10, fedora rawhide) the binutils
ar uses the new D flag per default to build deterministic
binaries.
Without this patch the following warning is issued, when
building btrfs-progs:

    [AR]     libbtrfs.a
/usr/bin/ar: `u' modifier ignored since `D' is the default (see `U')

For libtrfs.a performance benefit of the u option can be neglected,
so drop the u option and silence the warning.

In the future one might want to explicitly add the D option anyway.

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-08 13:53:33 +02:00
David Sterba 123f4bc78c btrfs-progs: makefile: add support for additional build flags
Allow fine tuned build options via EXTRA_CFLAGS and EXTRA_LDFLAGS
variables. Useful for additional debugging flags or warnings etc.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-01 14:02:50 +02:00
David Sterba 7c41d25ec6 btrfs-progs: do not install static binaries over non-static
The builds should be able to coexist, so we don't want to forcibly
overwite the standard version.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-08-31 19:25:11 +02:00
David Sterba 36cc0b67f7 btrfs-progs: Makefile: fix typo, dependencies for cmds-* files
The dependency generation skipped all cmds-*.c files due to a typo
in variable name, since day one.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-16 17:15:03 +02:00
David Sterba 10b6b0b3a8 btrfs-progs: tests: add driver script for misc tests
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-02 15:56:43 +02:00
David Sterba b51cc1d325 btrfs-progs: tests: add script to clean intermediate images
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-25 16:10:58 +02:00
David Sterba c8927d5116 btrfs-progs: cleanup, rename *disk_usage* files to usage
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-22 18:21:48 +02:00
David Sterba 047dd1bf5d btrfs-progs: tests: split make rule for fsck and convert tests, fix prerequisities
We'd like to run each class of tests separately. There were some missing
prerequisities that should be/are verified by the tests, makefile rules
have been synced.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:36:59 +02:00
Qu Wenruo a1231346d6 btrfs-progs: Move -rdynamic linker only option to LDFLAGS
Same thing as clang cleanup patch commit 040b3f11ba
"btrfs-progs: Makefile: Move linker only option to LDFLAGS"

But the move to autoconfig seems using old Makefile.
So do it again.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-11 19:08:41 +01:00
Qu Wenruo 68351e4162 btrfs-progs: Add new find-root.[ch] infrastructure
Introduce new find-root.[ch] infrastructure which has better tree root
judgment and uses much less codes to do it.

The new infrastructure will only record tree blocks with highest level
among its generation, and do better judgment whether the found tree block
is the desired one(level + generation check other than the original
generation only check).

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-11 18:34:04 +01:00
David Sterba 9b31d84fce btrfs-progs: build, do not install everything by default
Commit 878affd47d ("btrfs-progs: build more utilities by default")
resulted in installation of new utilities, that were not installed
before. Make them build but do not install them.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-05 16:12:09 +01:00