Commit Graph

122 Commits (1eb159a295261c56d14b962eb3d4763f8ce38807)

Author SHA1 Message Date
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
Miao Xie 65534643f6 Btrfs-progs: Add block group check funtion
This patch adds the function to check correspondence between block group,
chunk and device extent.

Original-signed-off-by: Cheng Yang <chenyang.fnst@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:54 -04:00
Eric Sandeen ef85e7e285 btrfs-progs: Add default rules to Makefile
Add a default rule for any btrfs-$FOO or btrfs-$FOO.static
target, allowing it to be built from btrfs-$FOO.c along with
all the normal userspace objects.

This gets rid of a lot of the cut and pasted rules for
each individual command, and as an added bonus makes it
easy to build any btrfs-$FOO statically as well, i.e.

  # make btrfs-convert.static

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-04-24 14:08:01 +02:00
Eric Sandeen b1031dfae1 btrfs-progs: standardize tool source filenames
For any btrfs-$FOO executable, rename the main source file from
$FOO.c to to btrfs-$FOO.c

This makes it slightly more obvious what's building what,
and allows us to write a default rule in the Makefile for
these tools.

(also add btrfs-calc-size to the list of objects to remove
on make clean)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-04-24 14:05:33 +02:00
Josef Bacik d93cad2677 Btrfs-progs: add a free space cache checker to fsck V2
In trying to track down a weird tree log problem I wanted to make sure that the
free space cache was actually valid, which we currently have no way of doing.
So this patch adds a bunch of support for the free space cache code and then a
checker to fsck.  Basically we go through and if we can actually load the free
space cache then we will walk the extent tree and verify that the free space
cache exactly matches what is in the extent tree.  Hopefully this will always be
correct, the only time it wouldn't is if the extent tree is corrupt or we have
some sort of awful bug in the free space cache.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
2013-04-23 18:56:21 +02:00
Mark Fasheh e5c6852c0c btrfs-progs: re-add send-test
send-test.c links against libbtrfs and uses the send functionality provided
to decode and print a send stream to the console.

66819df "btrfs-progs: add send-test" contained this file when
submitted, but somehow got lost on commit.

[sandeen@redhat.com: Resurrect lost send-test.c from original commit]

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-04-23 18:56:20 +02:00
Jan Schmidt 08fecd7658 Btrfs-progs: add btrfs-crc tool
This tool can be used to compute btrfs' style crc32c checksums for filenames
as done by the kernel. Additionally, there is -c mode to do a brute force
search for file names with a given checksum.

Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
2013-04-09 18:43:32 +02:00
Arne Jansen 6d37fbfc1f Btrfs-progs: tool to visualize fragmentation
This tool draws per-chunk pngs representing the allocation map. A black
or colored dot means the block is allocated.
The output is written to a subdirectory, together with an index.html to be
viewed in a browser.
There are options to control whether color should be used and which block
group types should be printed.
To build, you need to have libpng and libgd installed. It is not part of
the 'all' target, so please build it explicitely with make btrfs-fragments.

A (rather untypical) example can be seen at

http://sensille.com/fragments

Please regard this as a first scratch version and feel free to improve it :)

Signed-off-by: Arne Jansen <sensille@gmx.net>
2013-03-19 18:24:51 +01:00
David Sterba c535e2f7a7 btrfs-progs: makefile: clean static targets
* create .static.o version from the library objects as well and use them
  for building static targets
* remove build dependencies on libbtrfs.*
* other minor cleanups

Signed-off-by: David Sterba <dsterba@suse.cz>
2013-03-19 18:21:59 +01:00
Goffredo Baroncelli f243fcd1b2 Removing btrfsctl, btrfs-vol, btrfs-show
With the commit 002d021c (committed October 2011)
btrfsctl, btrfs-vol, btrfs-show were declared deprecated.
The last patches related to these commands are dated December 2010.

These tools are replaced by the "btrfs" tool in all the
functionality.

This commit removes all the related code.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-03-19 18:21:41 +01:00
Sergei Trofimovich cf7e3472d7 Makefile: allow user set LDFLAGS for libbtrfs.so as well
Detected by gentoo's QA checker:

 * QA Notice: Files built without respecting LDFLAGS have been detected
 *  Please include the following list of files in your report:
 * /usr/lib/libbtrfs.so.0.1

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2013-03-19 18:21:30 +01:00
Josef Bacik b268a41725 btrfs-progs: add lzo compression support to restore
This patch simply adds support to decompress lzo compressed extents in restore.

Signed-off-by: Josef Bacik <josef@redhat.com>
2013-03-18 18:14:19 +01:00
Hugo Mills 84a42b7c71 btrfs-progs: add Makefile rule for static build of btrfs-find-root
btrfs-find-root isn't yet integrated into the main btrfs tool, and is
an important recovery tool, so it deserves to be built as a static
binary.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
2013-03-14 23:08:44 +01:00
Antoine Sirinelli 2648a11841 btrfs-progs: Add a rule to build a static mkfs.btrfs
Static mkfs.btrfs can be used to "bootstrap" a system from a live CD
which does not provide mkfs.btrfs.

The executable produced is named mkfs.btrfs.static and built by invoking
the "static" make rule.

Signed-off-by: Antoine Sirinelli <antoine@monte-stello.com>
2013-03-12 16:23:14 +01:00
David Sterba 5e24225670 btrfs-progs: don't link binaries to a dynamic library
Linking 'btrfs' and other binaries against the dynamic library makes it
tedious to use directly from the git repo. This is useful for testing
various fixes, but now it'd need to also set LD_LIBRARY_PATH or install
the library to a known path.

Add a target for static library and use it for linking, the dynamic
library is to be used by external users.

Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-27 15:24:27 +01:00
Mark Fasheh e5cb128a95 btrfs-progs: libify some parts of btrfs-progs
External software wanting to use the functionality provided by the btrfs
send ioctl has a hard time doing so without replicating tons of work. Of
particular interest are functions like btrfs_read_and_process_send_stream()
and subvol_uuid_search(). As that functionality requires a bit more than
just send-stream.c and send-utils.c we have to pull in some other parts of
the progs package.

This patch adds code to the Makefile and headers to create a library,
libbtrfs which the btrfs command now links to.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-27 15:24:25 +01:00
Jeff Liu efbbbc88cb btrfs-progs: move btrfslabel.[c|h] stuff to utils.[c|h]
Clean btrfslabel.[c|h] out of the source tree and move those related
functions to utils.[c|h].

CC: Gene Czarcinski <gene@czarc.net>
Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-26 19:27:22 +01:00
Eric Sandeen 2a2d8e1962 btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table
The core of this is shamelessly stolen from xfsprogs.

Use blkid to detect an existing filesystem or partition
table on any of the target devices.  If something is found,
require the '-f' option to overwrite it, hopefully avoiding
disaster due to mistyped devicenames, etc.

# mkfs.btrfs /dev/sda1

WARNING! - Btrfs v0.20-rc1-59-gd00279c-dirty IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using

/dev/sda1 appears to contain an existing filesystem (xfs).
Use the -f option to force overwrite.
#

This does introduce a requirement on libblkid.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-02-19 11:15:31 +01:00
Mark Fasheh 66819df285 btrfs-progs: add send-test
send-test.c links against libbtrfs and uses the send functionality provided
to decode and print a send stream to the console.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-13 11:53:21 +01:00
Ian Kumlien e43cc46155 Btrfs-progs: add restore command to btrfs
Add 'btrfs restore' command which previously existed as a separate
utility btrfs-restore.

Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-12 23:46:15 +01:00
David Sterba e31f6172aa btrfs-progs: build btrsfck to keep compatibility
The command 'btrfsck' is commonly used and we should build it by
default.

Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-12 23:46:12 +01:00
Ian Kumlien 5956f752c6 Btrfs-progs: add btrfsck functionality to btrfs
This patch includes the functionality of btrfs, it's
found as "btrfs check".

Signed-off-by: Ian Kumlien <pomac@demius.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2013-02-12 19:09:47 +01:00
Ian Kumlien 93f06520b8 Btrfs-progs: -U_FORTIFY_SOURCE before -D
My builds are cluttered with:
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined [enabled by
default]

Which makes it hard to tell if something breaks or not.

Signed-off-by: Ian Kumlien <pomac@demius.net>
2013-02-12 15:22:57 +01:00
Ian Kumlien 6e0ade1767 Btrfs-progs: add static compile target
Sometimes, when you least expect it, a static binary is what you need to
rescue your data... Or just get a good enough handle on things to make
it work again ;)

"make static" is a gift to you, dear user with filesystem problems!

Anyway, on a more serious note, changed the cflags and ldflags so that
we create a smaller binary, 1.1MB stripped on my 64 bit system
(2.7MB with debug data)

Signed-off-by: Ian Kumlien <pomac@demius.net>
2013-02-12 15:22:55 +01:00
Chris Mason 7b1c567c84 Merge branch 'for-chris' of git://repo.or.cz/btrfs-progs-unstable/devel into raid56
Conflicts:
	ctree.h

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-02-06 12:42:24 -05:00
David Woodhouse 4d48b96b28 Add basic RAID[56] support
David Woodhouse originally contributed this code, and Chris Mason
changed it around to reflect the current design goals for raid56.

The original code expected all metadata and data writes to be full
stripes.  This meant metadata block size == stripe size, and had a few
other restrictions.

This version allows metadata blocks smaller than the stripe size.  It
implements both raid5 and raid6, although it does not have code to
rebuild from parity if one of the drives is missing or incorrect.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-02-01 14:22:07 -05:00
David Sterba 7aaf00fc2b btrfs-progs: fix parallel build
Parallel build may fail due to late creation of version.h, fix the rule name
that does not match the filename.

Signed-off-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Eri Sandeen <sandeen@redhat.com>
2013-01-31 18:55:34 +01:00
Stefan Behrens 7e08a9116d Btrfs-progs: add support for device replace procedure
This is the user mode part of the device replace patch series.

The command group "btrfs replace" is added with three commands:
- btrfs replace start srcdev|srcdevid targetdev [-Bfr] mount_point
- btrfs replace status mount_point [-1]
- btrfs replace cancel mount_point

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-01-31 13:47:26 +01:00
Anand Jain 46e3b8087b Btrfs-progs: move open_file_or_dir() to utils.c
The definition of the function open_file_or_dir() is moved from common.c
to utils.c in order to be able to share some common code between scrub
and the device stats in the following step. That common code uses
open_file_or_dir(). Since open_file_or_dir() makes use of the function
dirfd(3), the required XOPEN version was raised from 6 to 7.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Original-Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
2013-01-30 00:40:35 +01:00
Eric Sandeen 69af4b4ee2 btrfs-progs pretty/quiet build
A quieter build makes warnings more obvious.

This could probably be improved, but just to see
if people like this or if they hate it.  :)

make V=1 overrides it and gets you the full
glory again.

    [CC]     ctree.o
    [CC]     disk-io.o
    [CC]     radix-tree.o
    [CC]     extent-tree.o
    ...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-01-26 12:32:24 +01:00
Stefan Behrens c11d32446d btrfs-progs: Add btrfs-show-super
Just a small program to print the fields of a super block.

Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
2013-01-23 19:41:27 +01:00
Josef Bacik 124053b1d9 Btrfs-progs: detect if the disk we are formatting is a ssd
Patch rebased because of changes in mkfs.c but otherwise the same
as created by Josef Bacik

SSD's do not gain anything by having metadata DUP turned on.  The underlying
file system that is a part of all SSD's could easily map duplicate metadat
blocks into the same erase block which effectively eliminates the benefit of
duplicating the metadata on disk.  So detect if we are formatting a single
SSD drive and if we are do not use DUP.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Gene Czarcinski <gene@czarc.net>
2013-01-23 19:32:30 +01:00
Arne Jansen 89fe5b5f66 Btrfs progs: quota groups support
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Arne Jansen <sensille@gmx.net>
2012-09-04 11:15:49 +02:00
Chris Mason c1690a3832 Switch to -O1 for optimizations to enable FORTIFY_SOURCE
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2012-07-26 14:51:27 -04:00
Alexander Block f1c24cd80d Btrfs-progs: add btrfs send/receive commands
Add user space commands for btrfs send/receive.

Signed-off-by: Alexander Block <ablock84@googlemail.com>
Reviewed-by: David Sterba <dave@jikos.cz>
Reviewed-by: Arne Jansen <sensille@gmx.net>
Reviewed-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Reviewed-by: Alex Lyakas <alex.bolshoy.btrfs@gmail.com>
2012-07-26 14:51:27 -04:00
Sergei Trofimovich 996722194f Makefile: use $(MAKE) instead of hardcoded 'make'
CC: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2012-06-05 19:56:19 +01:00
Sergei Trofimovich b0a408ac63 Makefile: use $(CC) as a compilers instead of $(CC)/gcc
CC: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2012-06-05 19:56:19 +01:00
Chris Mason af00db292e Btrfsck: add the ability to prune corrupt extent allocation tree blocks
When we discover bad blocks in the extent allocation tree, repair can
now discard them and recreate the references from the rest of the trees.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-02-21 14:37:21 -05:00
Chris Mason d01fcebeb5 Fix btrfs-convert, btrfs-restore and btrfs-find-root build
Signed-off-by: Chris Mason <chris.mason@oracle.com>

fixit
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-02-08 23:11:49 -05:00
Chris Mason 3e5b13bfb5 Turn off some commands in Makefile
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2012-02-08 21:38:20 -05:00
Ilya Dryomov 888b7005ca Btrfs-progs: add 'balance' command group infrastructure
Add balance command group under both 'btrfs' and 'btrfs filesystem'.
Preserve the old 'btrfs filesystem balance <path>' behaviour.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:02:30 +02:00
Ilya Dryomov 8b4e3d8b5b Btrfs-progs: implement new subcommand parser
This completely replaces the existing subcommand infrastructure, which
is not flexible enough to accomodate our needs.  Instead of a global
command table we now have per-level tables and command group handlers,
which allows command-group-specific handling of options and subcommands.
The new parser exports a clear interface and gets out of the way - all
control over how matching is done is passed to commands and command
group handlers.

One side effect of this is that command implementors have to check the
number of arguments themselves - patch to fix up all existing commands
follows.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00
Ilya Dryomov 4f26833193 Btrfs-progs: rearrange files in the repo
Separate every command group into its own file (cmds_<group>.c) and
rearrange includes.  Remove btrfs_cmds.c.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
2012-02-03 21:00:17 +02:00
Arnd Hannemann fdb6c04023 Btrfs-progs: Relocate -lpthread in makefile
This patch fixes the following compile error when compiled with
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3):

gcc -lpthread -g -O0 -o btrfs btrfs.o btrfs_cmds.o scrub.o \
		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 crc32c.o rbtree.o extent-cache.o extent_io.o volumes.o utils.o btrfs-list.o btrfslabel.o  -luuid
scrub.o: In function `scrub_start':
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1342: undefined reference to `pthread_create'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1360: undefined reference to `pthread_create'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1374: undefined reference to `pthread_join'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1430: undefined reference to `pthread_cancel'
/home/arnd/Projekte/kernel/btrfs-progs/scrub.c:1432: undefined reference to `pthread_join'
collect2: ld returned 1 exit status
make: *** [btrfs] Error 1

The gcc man page says: "[...] the placement of the -l option is significant." so lets include -lpthread together with the usual $(LIBS)

Signed-off-by: Arnd Hannemann <arnd@arndnet.de>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-12-01 11:33:21 -05:00
Chris Mason 18c970767f btrfs-progs: add a utility to corrupt a single block 2011-10-27 22:38:02 -04:00
Chris Mason ff91b185f7 restore: deal with holes and set i_size correctly
This changes restore to set the i_size of the files it
copies out based on the size in the inode.  It also changes
it to skip over holes.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
2011-10-27 16:25:12 -04:00