Commit Graph

55 Commits (62c0666378eb70285b6a3052bf4144d2132a5891)

Author SHA1 Message Date
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
David Sterba dfbbe312ad btrfs-progs: autoconf: do not force fortify flags
Make it default, but let the user override it.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-05 15:11:40 +01:00
David Sterba f00d59d78f btrfs-progs: autoconf: largefile support is driven by configure
Don't force it in the makefile.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-05 15:05:23 +01:00
David Sterba 005526d065 btrfs-progs: autoconf: move custom CFLAGS from makefile
Keep only flags that are required to build properly, current fine
tunings are moved to the optional defaults in configure and can be
overriden by the user.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-05 15:05:21 +01:00
David Sterba 4aa32c9deb btrfs-progs: build, use the static library for the utilities
Commit 2c2e6c4e12 ("btrfs-progs: autoconf: cleanup compilation
flags usage") added the shared library to the linking command so the
resulting binaries depend dependent on libbtrfs.so. This is not
intended.

Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-04 18:45:54 +01:00
David Sterba 779499a9ad btrfs-progs: build, fix the source of btrfsck symlink
The installed symlink points to the absolute path of btrfs,
a relative link is enough.

Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-04 18:10:23 +01:00
David Sterba f47834dd1b btrfs-progs: autoconf: set exec_prefix in makefile
Lost in the conversion and breaks the build unless set explicitly.

Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-04 18:08:23 +01:00
David Sterba 99c53e440e btrfs-progs: autoconf: check btrfs-convert dependencies
Use the standard pkg-config checks.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 17:13:57 +01:00
David Sterba 1275c4fc1b btrfs-progs: autoconf: make btrfs-convert build optional
Proposed at https://github.com/kdave/btrfs-progs/pull/6, I've added the
configure options.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 17:13:55 +01:00
David Sterba d90978c9cc btrfs-progs: autoconf: generate documentation makefile as well
This is plain move to .in.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 15:42:34 +01:00
Qu Wenruo aae2c8421b btrfs-progs: Add btrfs_get_extent() and btrfs_punch_hole().
Add btrfs_get_extent() and btrfs_punch_hole() for btrfs-progs.

Btrfs_get_extent() will act much like kernel one, return the first
extent that covers the given range.
The difference will be that progs btrfs_get_extent() can't handle
no-holes feature, which means caller should handle it carefully.

Btrfs_punch_hole() will punch a hole in given range of given inode,
however it differs from kernel one since it won't zero any page or drop
any extents if there is any extent in the hole range.

These functions are mainly used for later I_ERR_FILE_EXTENT_DISCOUNT
repair function.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-02 14:16:38 +01:00
David Sterba 878affd47d btrfs-progs: build more utilities by default
Get better build coverage, btrfs-fragments require external libraries.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 19:06:47 +01:00
David Sterba 58f92c7caf btrfs-progs: build, use autoconf to detect RM
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 19:03:23 +01:00
David Sterba 412c9c3428 btrfs-progs: build, clean all generated files
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:28:37 +01:00
David Sterba 5989e9dd50 btrfs-progs: build, make build test work again
We need to regenerate version.h after clean-all.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:16:10 +01:00
Karel Zak badb4a15af btrfs-progs: autoconf: add --disable-documentation
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:01:00 +01:00
Karel Zak a22c3a0dcf btrfs-progs: autoconf: add --disable-backtrace
It's better to use ./configure than manually edit Makefile.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:01:00 +01:00
Karel Zak 67b1307955 btrfs-progs: autoconf: clean generated files, make version.h stuff more robust
- add rule to generated version.h when any relevant stuff changed
- add rule to clean generated files on "make clean-all"

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:01:00 +01:00
Karel Zak 2c2e6c4e12 btrfs-progs: autoconf: cleanup compilation flags usage
- define basic default CFLAGS in configure.ac, because:

   * autoconf default is -g -O2, but btrfs uses -g -O1

   * it's better to follow autoconf; standard way to modify
     CFLAGS is to call:  CFLAGS="foo bar" ./configure

- move all flags to one place in Makefile.in

- don't use AM_CFLAGS, the CFLAGS and STATIC_CFLAGS are enough

- don't mix objects and flags in $LIBS, it's more readable to
  add $(libs) to make rules

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:01:00 +01:00