platform/upstream/btrfs-progs.git
9 years agobtrfs-progs: version.sh: simplify printing the version
David Sterba [Fri, 13 Feb 2015 13:49:31 +0000 (14:49 +0100)]
btrfs-progs: version.sh: simplify printing the version

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: define package url manually if not set
David Sterba [Fri, 13 Feb 2015 13:39:43 +0000 (14:39 +0100)]
btrfs-progs: autoconf: define package url manually if not set

The PACKAGE_URL is set from optional parameter of AC_INIT starting in
autoconf 2.64. There are enterprise distros with version 2.63, we can
make the build work there easily as well.

Fixes build failure:

mkfs.c: In function ?main?:
mkfs.c:1492: error: ?PACKAGE_URL? undeclared (first use in this function)

Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix typo in OPEN_CTREE flag
David Sterba [Thu, 12 Feb 2015 12:41:00 +0000 (13:41 +0100)]
btrfs-progs: fix typo in OPEN_CTREE flag

Introduced in "btrfs-progs: Add new btrfs_open_ctree_flags CHUNK_ONLY"
by my local fixups.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Fix 2 extent buffer leak in btrfs-debug-tree
Qu Wenruo [Wed, 11 Feb 2015 01:57:17 +0000 (09:57 +0800)]
btrfs-progs: Fix 2 extent buffer leak in btrfs-debug-tree

There are 2 known extent buffer leaks:
1) With -t option.
-t option will skip other tree roots, but it will read the root node
first and then skip it.
Where it forgets to free the tree block it read.

2) with -b option.
It forgets to free the tree block it read.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Move -rdynamic linker only option to LDFLAGS
Qu Wenruo [Wed, 11 Feb 2015 00:46:24 +0000 (08:46 +0800)]
btrfs-progs: Move -rdynamic linker only option to LDFLAGS

Same thing as clang cleanup patch commit 040b3f11ba6b5555d793a9ef79ed4d9032d22370
"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>
9 years agoMerge branch 'qu/find-root-v3-part1' into v3.19.x
David Sterba [Wed, 11 Feb 2015 17:35:12 +0000 (18:35 +0100)]
Merge branch 'qu/find-root-v3-part1' into v3.19.x

9 years agobtrfs-progs: find-root, add option to search through all the metadata extents
Qu Wenruo [Fri, 16 Jan 2015 11:32:54 +0000 (19:32 +0800)]
btrfs-progs: find-root, add option to search through all the metadata extents

Add option '-a' for btrfs-find-root to iterate all the metadata extents
even the root is already found.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Cleanup unneeded btrfs-find-root codes
Qu Wenruo [Fri, 16 Jan 2015 08:40:50 +0000 (16:40 +0800)]
btrfs-progs: Cleanup unneeded btrfs-find-root codes

Since we switched to new open_ctree flag and new find-root facility,
there is no need to keep the old find-root codes.

Clean it up.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Switch btrfs-find-root to use the find-root infrastructure
Qu Wenruo [Fri, 16 Jan 2015 08:22:09 +0000 (16:22 +0800)]
btrfs-progs: Switch btrfs-find-root to use the find-root infrastructure

Since the new find-root infrastructure is here with better root
judgement with less codes, just switch to it.

To switch to the new infrastructure, new print function is added and
output format is slighted changed.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add better search generation judgment for btrfs-find-root
Qu Wenruo [Fri, 16 Jan 2015 07:32:35 +0000 (15:32 +0800)]
btrfs-progs: Add better search generation judgment for btrfs-find-root

Before the patch, btrfs-find-root will only consider it find a good root
if its generation matches generation in superblock and its level is
currently found highest level.

But that's not correct in 2 ways.
1) Root with decreased level
Since tree level can decrease, like subvolume/file deletion.
Which will make the new root have higher generation but lower level.

2) Root not updated in latest transaction.
If there is some root not updated in latest transaction, its generation
will be smaller than the one in superblock, and btrfs-find-root will not
find it.

This patch will use different generation for different tree to search,
solving the above problems.

Currently, it only supports generation/level in superblock. Using tree
root level/generation if possible will be introduced later.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Switch btrfs-find-root to use the new open_ctree flags
Qu Wenruo [Fri, 16 Jan 2015 06:30:02 +0000 (14:30 +0800)]
btrfs-progs: Switch btrfs-find-root to use the new open_ctree flags

Since in previous patches, we introduced the new open_ctree flag
OPEN_CTREE_CHUNK_ROOT_ONLY, switch btrfs-find-root to use it instead of
the open_ctree_broken().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add new find-root.[ch] infrastructure
Qu Wenruo [Fri, 16 Jan 2015 05:58:45 +0000 (13:58 +0800)]
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>
9 years agobtrfs-progs: Add new btrfs_open_ctree_flags CHUNK_ONLY
Qu Wenruo [Fri, 16 Jan 2015 03:22:28 +0000 (11:22 +0800)]
btrfs-progs: Add new btrfs_open_ctree_flags CHUNK_ONLY

Add new flag CHUNK_ONLY and internal used only flag __RETURN_CHUNK.

CHUNK_ONLY will imply __RETURN_CHUNK, SUPPRESS_ERROR and PARTIAL, which
will allow the fs to be opened with only chunk tree OK.

This will improve the usability for btrfs-find-root.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add support to suppress tree block csum error output
Qu Wenruo [Fri, 16 Jan 2015 03:04:09 +0000 (11:04 +0800)]
btrfs-progs: Add support to suppress tree block csum error output

Add new open ctree flag OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS to
suppress tree block csum error output.

Provides the basis for new btrfs-find-root and other enhancement on
btrfs offline tools output.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[renamed vars and funcs, added comments]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Cleanup check_tree_block() function
Qu Wenruo [Thu, 29 Jan 2015 08:32:39 +0000 (16:32 +0800)]
btrfs-progs: Cleanup check_tree_block() function

Before this patch, check_tree_block() will print error on bytenr
mismatch but don't output error on fsid mismatch.

This patch will modify check_tree_block(), so it will only return errno
but not print error messages.
The error message will be output by print_tree_block_err() function.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[renamed and cleaned return codes]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoMerge remote-tracking branch 'remotes/josef/for-kdave' into v3.19.x
David Sterba [Tue, 10 Feb 2015 14:17:10 +0000 (15:17 +0100)]
Merge remote-tracking branch 'remotes/josef/for-kdave' into v3.19.x

"This series of patches fixes up btrfsck in lots of ways and adds some
new functionality.  These patches were required to fix Hugo's broken
multi-disk fs as well as fix fsck so it would actually pass all of the
fsck tests.  This also fixes a long standing btrfs-image problem where
it wouldn't restore multi disk images onto a single disk properly."

9 years agoBtrfs-progs: fix bad extent flag
Josef Bacik [Thu, 5 Feb 2015 20:41:32 +0000 (15:41 -0500)]
Btrfs-progs: fix bad extent flag

We can have FULL_BACKREF set or not set when we need the opposite, this patch
fixes this problem by setting a bit when the flag is set improperly.  This way
we can either correct the problem when we re-create the extent item if the
backrefs are also wrong, or we can just set the flag properly in the extent
item.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: skip opening all devices with restore
Josef Bacik [Tue, 3 Feb 2015 14:48:57 +0000 (09:48 -0500)]
Btrfs-progs: skip opening all devices with restore

When we go to fixup the dev items after a restore we scan all existing devices.
If you happen to be a btrfs developer you could possibly open up some random
device that you didn't just restore onto, which gives you weird errors and makes
you super cranky and waste a day trying to figure out what is failing.  This
will make it so that we use the fd we've already opened for opening our ctree.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: make debug-tree spit out full_backref flag
Josef Bacik [Tue, 3 Feb 2015 14:48:29 +0000 (09:48 -0500)]
Btrfs-progs: make debug-tree spit out full_backref flag

Currently btrfs-debug-tree ignores the FULL_BACKREF flag which makes it hard to
figure out problems related to FULL_BACKREF.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: make restore update dev items
Josef Bacik [Wed, 28 Jan 2015 20:38:03 +0000 (12:38 -0800)]
Btrfs-progs: make restore update dev items

When we restore a multi disk image onto a single disk we need to update the dev
items used and total bytes so that fsck doesn't freak out and that we get normal
results from stuff like btrfs fi show.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: unpin excluded extents as we fix things
Josef Bacik [Tue, 27 Jan 2015 22:23:21 +0000 (14:23 -0800)]
Btrfs-progs: unpin excluded extents as we fix things

We don't want to keep extent records pinned down if we fix stuff as we may need
the space and we can be pretty sure that these records are correct.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: remove global transaction from fsck
Josef Bacik [Mon, 9 Feb 2015 15:02:25 +0000 (10:02 -0500)]
Btrfs-progs: remove global transaction from fsck

We hold a transaction open for the entirety of fixing extent refs.  This works
out ok most of the time but we can be tight on space and run out of space when
fixing things.  To get around this just push down the transaction starting dance
into the functions that actually fix things.  This keeps us from ending up with
ENOSPC because we pinned everything and allows the code to be a bit simpler.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: only build space info's for the main flags
Josef Bacik [Mon, 26 Jan 2015 01:41:19 +0000 (17:41 -0800)]
Btrfs-progs: only build space info's for the main flags

Hitting enospc problems with a really corrupt fs uncovered the fact that we
match any flag in a block group when creating space info's.  This is a problem
if we have a raid level set, we'll end up with only one space info that covers
metadata and data because they share a raid level.  We don't want this, we want
to separate out the data and metadata space infos, so mask off the raid level
and only use the main flags.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: Introduce metadump_v2
Josef Bacik [Fri, 6 Feb 2015 18:03:12 +0000 (13:03 -0500)]
Btrfs-progs: Introduce metadump_v2

The METADUMP super flag makes us skip doing the chunk tree reading which isn't
helpful for the new restore since we have a valid chunk tree.  But we still want
to have a way for the kernel to know that this is a metadump restore so it
doesn't do things like verify data checksums.  We also want to skip some of the
device extent checks in fsck since those will obviously not match.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: multi-thread btrfs-image restore
Josef Bacik [Fri, 6 Feb 2015 19:40:45 +0000 (14:40 -0500)]
Btrfs-progs: multi-thread btrfs-image restore

For some reason we only allow btrfs-image restore to have one thread, which is
incredibly slow with large images.  So allow us to do work with more than just
one thread.  This made my restore go from 16 minutes to 3 minutes.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agobtrfs-progs: fix btrfs-image overlapping chunks
Josef Bacik [Mon, 26 Jan 2015 01:39:24 +0000 (17:39 -0800)]
btrfs-progs: fix btrfs-image overlapping chunks

If you create a metadump from a striped volume you will have chunks that refer
to different logical offsets with the same physical offset on different devices.
So when we do the restore we just truncate the number of stripes in each chunk
item and carry on, which causes problems because we then have chunks that point
to the same physical offset for different logical offsets.  To handle this
problem we keep track of logical extents that overlap on physical extents.
Then we go back and remap these extents into different physical extents on the
disk we are restoring onto.  This makes us actually able to restore a multi disk
image onto a single disk and have everything work out properly.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: don't check csums for data reloc root
Josef Bacik [Fri, 23 Jan 2015 16:39:28 +0000 (11:39 -0500)]
Btrfs-progs: don't check csums for data reloc root

The data reloc root is weird with it's csums.  It'll copy an entire extent and
then log any csums it finds, which makes it look weird when it comes to prealloc
extents.  So just skip the data reloc tree, it's special and we just don't need
to worry about it.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: don't try to repair reloc roots
Josef Bacik [Thu, 15 Jan 2015 22:11:41 +0000 (17:11 -0500)]
Btrfs-progs: don't try to repair reloc roots

We have logic to fix the root locations for roots in response to a corruption
bug we had earlier.  However this work doesn't apply to reloc roots and can
screw things up worse, so make sure we skip any reloc roots that we find.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: read super properly in btrfs-image
Josef Bacik [Wed, 14 Jan 2015 19:40:21 +0000 (14:40 -0500)]
Btrfs-progs: read super properly in btrfs-image

When btrfs-image makes a metadump it'll map all the blocks from their logical
address to their physical.  This works out fine with the exception of the super
block, which is the physical offset.  Normally this just works, but if the user
has balanced their fs it'll either crash btrfs-image or it'll copy some
completely arbitrary data.  This forces btrfs-image to read the super directly
from the disk.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: handle -eagain properly
Josef Bacik [Fri, 6 Feb 2015 14:59:54 +0000 (09:59 -0500)]
Btrfs-progs: handle -eagain properly

If we fix bad blocks during run_next_block we will return -EAGAIN to loop around
and start again.  The deal_with_roots work messed up this handling, this patch
fixes it.  With this patch we can properly deal with broken tree blocks.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agobtrfs-progs: deal with no extent info
Josef Bacik [Tue, 13 Jan 2015 20:23:41 +0000 (15:23 -0500)]
btrfs-progs: deal with no extent info

Previously we used to just set FULL_BACKREF if we couldn't lookup an extent info
for an extent.  Now we just bail out if we can't lookup the extent info, which
is less than good since fsck is supposed to fix these very problems.  So instead
figure out the flag we are supposed to use and pass that along instead.  This
patch also provides a test image to test this functionality.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs-progs: let btrfs-corrupt-block specify a root
Josef Bacik [Tue, 13 Jan 2015 20:23:01 +0000 (15:23 -0500)]
Btrfs-progs: let btrfs-corrupt-block specify a root

Sometimes we want to corrupt specific keys or delete items on different roots,
so allow btrfs-corrupt-block to take a root objectid so we can corrupt a
specific root.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
9 years agoBtrfs progs v3.19-rc2
David Sterba [Thu, 5 Feb 2015 16:14:36 +0000 (17:14 +0100)]
Btrfs progs v3.19-rc2

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, do not install everything by default
David Sterba [Thu, 5 Feb 2015 14:46:42 +0000 (15:46 +0100)]
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>
9 years agobtrfs-progs: autoconf: do not force fortify flags
David Sterba [Thu, 5 Feb 2015 14:11:40 +0000 (15:11 +0100)]
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>
9 years agobtrfs-progs: autoconf: largefile support is driven by configure
David Sterba [Thu, 5 Feb 2015 13:52:03 +0000 (14:52 +0100)]
btrfs-progs: autoconf: largefile support is driven by configure

Don't force it in the makefile.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: move custom CFLAGS from makefile
David Sterba [Thu, 5 Feb 2015 13:46:47 +0000 (14:46 +0100)]
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>
9 years agobtrfs-progs: autoconf: set CFLAGS conditionally
David Sterba [Wed, 4 Feb 2015 18:23:38 +0000 (19:23 +0100)]
btrfs-progs: autoconf: set CFLAGS conditionally

The expected way to define custom CFLAGS is

  $ export CFLAGS=...
  $ ./configure ...

the build will use them. No not override the make variables directly
from now on.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, use the static library for the utilities
David Sterba [Wed, 4 Feb 2015 17:45:54 +0000 (18:45 +0100)]
btrfs-progs: build, use the static library for the utilities

Commit 2c2e6c4e12e5af15fd ("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>
9 years agobtrfs-progs: build, fix the source of btrfsck symlink
David Sterba [Wed, 4 Feb 2015 17:10:23 +0000 (18:10 +0100)]
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>
9 years agobtrfs-progs: autoconf: set exec_prefix in makefile
David Sterba [Wed, 4 Feb 2015 17:08:23 +0000 (18:08 +0100)]
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>
9 years agoBtrfs progs v3.19-rc1
David Sterba [Tue, 3 Feb 2015 17:53:58 +0000 (18:53 +0100)]
Btrfs progs v3.19-rc1

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroups, adjust help text
David Sterba [Tue, 3 Feb 2015 17:34:14 +0000 (18:34 +0100)]
btrfs-progs: qgroups, adjust help text

Minor rewording to make the line shorter and.

Resolves-coverity-id: 1267280
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: check btrfs-convert dependencies
David Sterba [Tue, 3 Feb 2015 16:12:28 +0000 (17:12 +0100)]
btrfs-progs: autoconf: check btrfs-convert dependencies

Use the standard pkg-config checks.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: check if backtrace is really supported
David Sterba [Tue, 3 Feb 2015 15:50:33 +0000 (16:50 +0100)]
btrfs-progs: autoconf: check if backtrace is really supported

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: print summary about features
David Sterba [Tue, 3 Feb 2015 15:31:51 +0000 (16:31 +0100)]
btrfs-progs: autoconf: print summary about features

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: make btrfs-convert build optional
David Sterba [Tue, 3 Feb 2015 15:22:55 +0000 (16:22 +0100)]
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>
9 years agobtrfs-progs: autoconf: detect tools to build docs
David Sterba [Tue, 3 Feb 2015 14:38:17 +0000 (15:38 +0100)]
btrfs-progs: autoconf: detect tools to build docs

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, fix version macro name
David Sterba [Tue, 3 Feb 2015 14:04:28 +0000 (15:04 +0100)]
btrfs-progs: build, fix version macro name

Autoconf changed it to PACKAGE_VERSION and moved to config.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: use variable substitutions in doc makefile
David Sterba [Tue, 3 Feb 2015 13:56:06 +0000 (14:56 +0100)]
btrfs-progs: autoconf: use variable substitutions in doc makefile

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: generate documentation makefile as well
David Sterba [Tue, 3 Feb 2015 13:49:09 +0000 (14:49 +0100)]
btrfs-progs: autoconf: generate documentation makefile as well

This is plain move to .in.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, fix rules to clean temporary files in docs
David Sterba [Tue, 3 Feb 2015 13:40:33 +0000 (14:40 +0100)]
btrfs-progs: build, fix rules to clean temporary files in docs

$ make clean-doc
Cleaning Documentation
/usr/bin/rm: cannot remove â€˜*.xml’: No such file or directory
/usr/bin/rm: cannot remove â€˜*.xml+’: No such file or directory
/usr/bin/rm: cannot remove â€˜*.5’: No such file or directory
/usr/bin/rm: cannot remove â€˜*.8’: No such file or directory
make[1]: *** [clean] Error 1
make: *** [clean-doc] Error 2

The RM variable from parent makefile lacks -f, add it where it's
missing.
Minor change in LN_S variable name, same -f change.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: read_tree_block() and read_node_slot() cleanup.
Qu Wenruo [Wed, 28 Jan 2015 02:12:55 +0000 (10:12 +0800)]
btrfs-progs: read_tree_block() and read_node_slot() cleanup.

Allow read_tree_block() and read_node_slot() to return error pointer.
This should help caller to get more specified error number.

For existing callers, change (!eb) judgmentt to
(!extent_buffer_uptodate(eb)) to keep the compatibility, and for caller
missing the check, use PTR_ERR(eb) if possible.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: drop old fi balance syntax from help
David Sterba [Mon, 2 Feb 2015 17:17:05 +0000 (18:17 +0100)]
btrfs-progs: drop old fi balance syntax from help

The command 'btrfs fi balance' still works to keep any scripts working,
we may remove it someday.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add bash completion script
David Sterba [Mon, 2 Feb 2015 16:49:41 +0000 (17:49 +0100)]
btrfs-progs: add bash completion script

Original authors:
  Alfredo Esteban <aedelatorre at gmail.com>
  Joseph Wang <joequant at gmail.com>
  John C F <john.ch.fr at gmail.com>

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add repair function for discount file extent hole.
Qu Wenruo [Fri, 2 Jan 2015 07:12:33 +0000 (15:12 +0800)]
btrfs-progs: Add repair function for discount file extent hole.

Since orphan extents are handled in previous patches, now just punch
holes to fill the file extents hole.

Also since now btrfsck is aware of whether the inode has orphan file
extent, allow repair_inode_no_item() to determine filetype according to
orphan file extent.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add repair and report function for orphan file extent.
Qu Wenruo [Fri, 2 Jan 2015 07:12:32 +0000 (15:12 +0800)]
btrfs-progs: Add repair and report function for orphan file extent.

In some fs tree leaf/node corruption case, file extents may be lost, but
in extent tree, its record may still exists.

This provide the possibility for such orphan file extents to be
recovered even we can't recover its compression and other info, we can
still insert it as a normal non-compression file extent.

This patch provides the repair and report function for such orphan file
extent.
Even after such repair, user may still need to try to decompress its
data if user knows that is a compressed extent.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Record and report every file extent hole.
Qu Wenruo [Fri, 2 Jan 2015 07:12:31 +0000 (15:12 +0800)]
btrfs-progs: Record and report every file extent hole.

Record every file extent discontinuous hole in inode_record using a
rb_tree member.

Before the patch, btrfsck will only record the first file extent hole by
using first_extent_gap, that's good for detecting error, but not
suitable for fixing it.

This patch provides the ability to record every file extent hole and
report it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add btrfs_get_extent() and btrfs_punch_hole().
Qu Wenruo [Fri, 2 Jan 2015 07:12:30 +0000 (15:12 +0800)]
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>
9 years agobtrfs-progs: Record orphan data extent ref to corresponding root.
Qu Wenruo [Fri, 2 Jan 2015 07:12:29 +0000 (15:12 +0800)]
btrfs-progs: Record orphan data extent ref to corresponding root.

Before this patch, when a extent's data ref points to a invalid key in
fs tree, this happens if a leaf/node of fs tree is corrupted, btrfsck
can't do any repair and just exit.

In fact, such problem can be handled in fs tree repair routines, rebuild
the inode item(if missing) and add back the extent data (with some
assumption).

So this patch records such data extent refs for later fs tree recovery
routine.

TODO:
    Restore orphan data extent refs into btrfs_root is not the best
    method. It's best to directly restore it into inode_record, however
    current extent tree and fs tree can't cooperate together, so use
    btrfs_root as a temporary storage until inode_cache is built.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build more utilities by default
David Sterba [Wed, 28 Jan 2015 18:06:47 +0000 (19:06 +0100)]
btrfs-progs: build more utilities by default

Get better build coverage, btrfs-fragments require external libraries.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, make autogen.sh work on older systems
David Sterba [Wed, 28 Jan 2015 18:01:25 +0000 (19:01 +0100)]
btrfs-progs: build, make autogen.sh work on older systems

Try harder to find the support scipts, look into libtool or automake
dirs directly.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, use autoconf to detect RM
David Sterba [Wed, 28 Jan 2015 17:41:17 +0000 (18:41 +0100)]
btrfs-progs: build, use autoconf to detect RM

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, clean all generated files
David Sterba [Wed, 28 Jan 2015 17:28:37 +0000 (18:28 +0100)]
btrfs-progs: build, clean all generated files

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: build, make build test work again
David Sterba [Wed, 28 Jan 2015 17:16:10 +0000 (18:16 +0100)]
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>
9 years agobtrfs-progs: autoconf: add --disable-documentation
Karel Zak [Fri, 12 Dec 2014 10:54:06 +0000 (11:54 +0100)]
btrfs-progs: autoconf: add --disable-documentation

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: add --disable-backtrace
Karel Zak [Wed, 10 Dec 2014 14:21:24 +0000 (15:21 +0100)]
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>
9 years agobtrfs-progs: autoconf: clean generated files, make version.h stuff more robust
Karel Zak [Wed, 10 Dec 2014 11:30:05 +0000 (12:30 +0100)]
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>
9 years agobtrfs-progs: autoconf: cleanup compilation flags usage
Karel Zak [Wed, 10 Dec 2014 10:56:59 +0000 (11:56 +0100)]
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>
9 years agobtrfs-progs: autoconf: use paths and $*_LIBS from ./configure
Karel Zak [Tue, 9 Dec 2014 15:57:10 +0000 (16:57 +0100)]
btrfs-progs: autoconf: use paths and $*_LIBS from ./configure

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: check for build programs in ./configure
Karel Zak [Tue, 9 Dec 2014 15:41:10 +0000 (16:41 +0100)]
btrfs-progs: autoconf: check for build programs in ./configure

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: use ./configure to generate version.h
Karel Zak [Tue, 9 Dec 2014 14:58:11 +0000 (15:58 +0100)]
btrfs-progs: autoconf: use ./configure to generate version.h

The original homemade solution is unnecessary, autotools provides better
infrastructure to generate files.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: use standard PACKAGE_* macros
Karel Zak [Tue, 9 Dec 2014 14:37:03 +0000 (15:37 +0100)]
btrfs-progs: autoconf: use standard PACKAGE_* macros

- use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros
  rather than homemade BTRFS_BUILD_VERSION

- don't #include version.h, now the file is necessary for library API only

Note that "btrfs version" returns "btrfs-progs <version>" instead of
the original confusing "btrfs <version>".

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: use config.h
Karel Zak [Tue, 9 Dec 2014 14:15:47 +0000 (15:15 +0100)]
btrfs-progs: autoconf: use config.h

- the header file is generated by ./configure, the standard autotools
  way is to use -include config.h on compiler command line rather than
  include the file directly from code

- remove _GNU_SOURCE from code, the macros is already defined in config.h
  by AC_USE_SYSTEM_EXTENSIONS autoconf macro

Signed-off-by: Karel Zak <kzak@redhat.com>
[_GNU_SOURCE changes already done]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: autoconf: add ./configure script
Karel Zak [Thu, 4 Dec 2014 12:26:46 +0000 (13:26 +0100)]
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>
9 years agoBtrfs progs v3.18.2
David Sterba [Tue, 27 Jan 2015 16:42:28 +0000 (17:42 +0100)]
Btrfs progs v3.18.2

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: update wording for qgroup limits
David Sterba [Tue, 27 Jan 2015 16:07:40 +0000 (17:07 +0100)]
btrfs-progs: update wording for qgroup limits

Based on a user report, 'max' in help does not clearly point to the
limits that are commonly used as a quota-related term.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: don't output operational status information to stderr
Xing Gu [Mon, 26 Jan 2015 08:26:38 +0000 (16:26 +0800)]
btrfs-progs: don't output operational status information to stderr

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: check: Add --readonly flag
Hugo Mills [Tue, 27 Jan 2015 15:05:53 +0000 (15:05 +0000)]
btrfs-progs: check: Add --readonly flag

Particularly during support conversations, people get confused about
which options to use with btrfs check. Adding a flag, --readonly, which
implies the default read-only behaviour and which conflicts with the
read-write operations, should help make the behaviour of the tool clear.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Make option parsing more robust to code modifications
Hugo Mills [Tue, 27 Jan 2015 15:05:52 +0000 (15:05 +0000)]
btrfs-progs: Make option parsing more robust to code modifications

The current approach to option parsing, where long-only options are
selected on the basis of their position in the long_options array is
fragile and painful to modify if options are to be inserted into the
list, rather than appended.

Instead, use the last field of struct option to return a value which
cannot be a char (and hence a short option), and simply switch on those
within the case statement.

Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroup: make large size aligned
Fan Chengniang [Fri, 23 Jan 2015 01:50:49 +0000 (09:50 +0800)]
btrfs-progs: qgroup: make large size aligned

Problem: when the size is too big, the output format will be unaligned.
The __update__columns_max_len function has been updated to fix this
problem.

Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: drop feature defines from C files, in favour of CFLAGS defines
Dimitri John Ledkov [Sun, 18 Jan 2015 01:52:58 +0000 (01:52 +0000)]
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>
9 years agobtrfs-progs: unify getopt table terminators
David Sterba [Wed, 21 Jan 2015 17:53:02 +0000 (18:53 +0100)]
btrfs-progs: unify getopt table terminators

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add --human-readable option where applicable
David Sterba [Wed, 21 Jan 2015 17:47:24 +0000 (18:47 +0100)]
btrfs-progs: add --human-readable option where applicable

Add an alias to -h to 'filesystem usage', 'filesystem df' and
'device usage' commands, same as the traditional 'df'.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use predefined getopt values for unit suffixes
David Sterba [Wed, 21 Jan 2015 17:09:32 +0000 (18:09 +0100)]
btrfs-progs: use predefined getopt values for unit suffixes

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: define common geopt values for unit suffixes
David Sterba [Wed, 21 Jan 2015 17:02:42 +0000 (18:02 +0100)]
btrfs-progs: define common geopt values for unit suffixes

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: make btrfs qgroups show human readable sizes
Fan Chengniang [Mon, 19 Jan 2015 07:18:18 +0000 (15:18 +0800)]
btrfs-progs: make btrfs qgroups show human readable sizes

add --raw, --si, --iec, --kbytes, --mbytes, --gbytes, --tbytes options
make columns which show sizes align to right. Others aligned to left.

example:
qgroupid         rfer         excl     max_rfer     max_excl parent  child
--------         ----         ----     --------     -------- ------  -----
0/5         299.58MiB    299.58MiB    300.00MiB    300.00MiB 1/1     ---
0/265       299.58MiB     16.00KiB    400.00MiB        0.00B 1/1     ---
0/266       299.58MiB     16.00KiB    350.00MiB        0.00B ---     ---
1/1         599.16MiB    299.59MiB    800.00MiB        0.00B ---     0/5,0/265

Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: unify header file inclusion protections
David Sterba [Wed, 21 Jan 2015 16:49:26 +0000 (17:49 +0100)]
btrfs-progs: unify header file inclusion protections

There are missing ifdefs or defines with very generic names.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Doc: Add explain on 'source' and 'target' for btrfs-image.
Qu Wenruo [Mon, 24 Nov 2014 07:27:44 +0000 (15:27 +0800)]
btrfs-progs: Doc: Add explain on 'source' and 'target' for btrfs-image.

Add explain on 'source' and 'target', which is somewhat confusing for
users who want to restore dumped image.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[reworded texts]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Cleanup, use bitshift instead of immediate number in btrfs_open_ctree_flags.
Qu Wenruo [Mon, 19 Jan 2015 06:45:03 +0000 (14:45 +0800)]
btrfs-progs: Cleanup, use bitshift instead of immediate number in btrfs_open_ctree_flags.

Change the immediate number in btrfs_open_ctree_flags to bit shift.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: force to set seeding flags
Fan Chengniang [Mon, 19 Jan 2015 07:27:30 +0000 (15:27 +0800)]
btrfs-progs: btrfstune: force to set seeding flags

Now we can use -f with -S option when setting seeding flags or clearing
seeding flags

Reported-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
[updated docs]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests, use non-interactive sudo helper
David Sterba [Mon, 19 Jan 2015 18:09:28 +0000 (19:09 +0100)]
btrfs-progs: tests, use non-interactive sudo helper

Sudo may not be configured to run without user prompt, in that case the
tests would be stuck.

Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix check of running scrub
David Sterba [Mon, 19 Jan 2015 17:47:20 +0000 (18:47 +0100)]
btrfs-progs: fix check of running scrub

Scrub on multiple devices may report wrong status if scrub finishes
early on one of them.

Reported-by: Sandy McArthur Jr <sandymac@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: make getopt tables static const
David Sterba [Mon, 19 Jan 2015 12:44:49 +0000 (13:44 +0100)]
btrfs-progs: make getopt tables static const

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: cleanup, move getop long options close to their use
David Sterba [Mon, 19 Jan 2015 12:30:06 +0000 (13:30 +0100)]
btrfs-progs: cleanup, move getop long options close to their use

Move long_option defintions just before getopt_long everywhere.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests, adjust alignment of the pretty command name
David Sterba [Wed, 14 Jan 2015 17:32:17 +0000 (18:32 +0100)]
btrfs-progs: tests, adjust alignment of the pretty command name

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests, use the root helper in 012
David Sterba [Wed, 14 Jan 2015 17:13:21 +0000 (18:13 +0100)]
btrfs-progs: tests, use the root helper in 012

We need it to mount/umount, to traverse lost+found and stat the results.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests, add support for running commands under root
David Sterba [Wed, 14 Jan 2015 17:07:43 +0000 (18:07 +0100)]
btrfs-progs: tests, add support for running commands under root

Most of the checks run fine without root, but some of them may need to
do a mount test or access the data. Add the support to selectively run
commands under root, hardcoded to sudo for now.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Move extent tree rebuild test to its dir
Qu Wenruo [Thu, 25 Dec 2014 01:32:15 +0000 (09:32 +0800)]
btrfs-progs: Move extent tree rebuild test to its dir

Move extent tree rebuild teset to its dir.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Move leaf-corruption no extent data case and add verification script
Qu Wenruo [Thu, 25 Dec 2014 01:32:14 +0000 (09:32 +0800)]
btrfs-progs: Move leaf-corruption no extent data case and add verification script

Move leaf-corruption type no extent data case to its dir, and add
verification script in test.sh

The verification script is based on manual btrfs-debug-tree check.

The image can also be reused to other leaf-corruption type, like
corrupted leaf contains regular file extent data case.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>