Commit Graph

1985 Commits (250a58f34d57588de8f0b2f118cb5cd152744158)
 

Author SHA1 Message Date
Josef Bacik 34a5ec12ee 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>
2015-02-09 14:53:15 -05:00
Josef Bacik c6b388ef2d 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 0b8aa1969b 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>
2015-02-09 14:53:15 -05:00
Josef Bacik ce0517b364 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 08a4597223 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>
2015-02-09 14:53:15 -05:00
Josef Bacik bce7dbba28 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 797a937e5d 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>
2015-02-09 14:53:15 -05:00
Josef Bacik c7e3b63b7e 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 32bb725f66 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 20feed2ea4 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>
2015-02-09 14:53:15 -05:00
Josef Bacik 65ac3b2758 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>
2015-02-09 14:53:14 -05:00
Josef Bacik 1b7126f937 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>
2015-02-09 14:53:14 -05:00
Josef Bacik cc73e60d95 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>
2015-02-09 14:53:14 -05:00
Josef Bacik 8ab2d7a9dd 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>
2015-02-09 14:53:07 -05:00
Josef Bacik 63d66268f4 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>
2015-02-09 14:41:51 -05:00
David Sterba 8fa8156a0e
Btrfs progs v3.19-rc2
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-05 17:14:36 +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 9143fda114 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>
2015-02-05 14:33:36 +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 edbd407008
Btrfs progs v3.19-rc1
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 18:53:58 +01:00
David Sterba 999a420639 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>
2015-02-03 18:37:33 +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 8fa3fed3a4 btrfs-progs: autoconf: check if backtrace is really supported
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 17:13:57 +01:00
David Sterba 93e0bd4703 btrfs-progs: autoconf: print summary about features
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 e1f0d9d446 btrfs-progs: autoconf: detect tools to build docs
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 16:06:52 +01:00
David Sterba 505669320b 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>
2015-02-03 16:03:30 +01:00
David Sterba 52e65ab121 btrfs-progs: autoconf: use variable substitutions in doc makefile
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-03 16:03:28 +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
David Sterba 42e4dfe772 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>
2015-02-03 14:41:00 +01:00
Qu Wenruo ccdd0a067f 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>
2015-02-02 19:21:24 +01:00
David Sterba 3e75249112 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>
2015-02-02 18:18:16 +01:00
David Sterba ace45622ce 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>
2015-02-02 17:49:41 +01:00
Qu Wenruo 16584ea51e 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>
2015-02-02 14:16:38 +01:00
Qu Wenruo ad03f840f0 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>
2015-02-02 14:16:38 +01:00
Qu Wenruo bb06029f9b 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>
2015-02-02 14:16:38 +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
Qu Wenruo 0ddf63c09f 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>
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 1fabba7ef7 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>
2015-01-28 19:03:23 +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