Commit Graph

1890 Commits (e9b5ff23eafffa37c1d7bab979f97b1a285556cb)
 

Author SHA1 Message Date
Anand Jain e9b5ff23ea btrfs-progs: btrfs_scan_block_devices is unused function delete it
After Patch:
 remove BTRFS_SCAN_PROC scan method
There isn't any consumer for btrfs_scan_block_devices() so delete it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
Qu Wenruo f4fac5d46e btrfs-progs: fsck: Fix a shallow copy which will leads to segfault.
In copy_inode_rec(), a shallow copy happens on rec->holes rb_root.
So for shared inode case, new rec->holes still points to old rb_root,
and when the old inode record is freed, the new inode_rec->holes will
points to garbage and cause segfault when we try to free new
inode_rec->holes.

Fix it by calling copy_file_extent_holes() to do deep copy.

Reported-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Filipe David Manana <fdmanana@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
David Sterba ab5984ff6c btrfs-progs: convert: drop dependency on sys/acl.h
The file sys/acl.h is part of libacl and if the development package is
not installed, build of btrfs-convert fails.

We do not link against libacl nor use the functions provided by libacl.  The
ACL_* values are directly read from the extN data, so it's more part of the
on-disk format rather than an interface to libacl.

The dependency on libacl is completely dropped.

Reported-by: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
David Sterba bea9ba0acb btrfs-progs: restore: add more long option variants
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
David Sterba 18b48340de btrfs-progs: restore: shift option texts
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
David Sterba ffd53c0fe8 btrfs-progs: restore: use bigger buffer for output path name
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:06 +02:00
Dan Merillat bd91f80725 btrfs-progs: optionally restore symlinks.
Restore symlinks, optionally with owner/times.

Signed-off-by: Dan Merillat <dan.merillat@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-05-14 15:41:02 +02:00
Dan Merillat 829950844e btrfs-progs: restore: separate the overwrite check
Symlink restore needs this, but the cut&paste became too complicated.
Simplify everything.

Signed-off-by: Dan Merillat <dan.merillat@gmail.com>
[message wording adjustments]
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-29 17:55:18 +02:00
David Sterba 19a806f575
Btrfs progs v4.0
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-29 16:56:22 +02:00
David Sterba 630a917aa1 btrfs-progs: restore: don't misreport errors from search_dir
The logic around return value has changed in the metadata restore
patches. The return value from btrfs_search_slot may remain non-zero and
is returned. This is incorrectly interpreted as an error.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-29 16:48:04 +02:00
David Sterba 1b7dd327f4 btrfs-progs: receive: unconditionally print if doing chroot
The chroot action seems important enough to be printed unconditionally
and without the verbose option that prints way too much information.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 18:01:32 +02:00
David Sterba 582e156baf btrfs-progs: fix typos in restore help/doc
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 17:28:37 +02:00
Dan Merillat ce72ae32d2 btrfs-progs: restore: document metadata restore.
This was lost in the cleanup of 71a559

Signed-off-by: Dan Merillat <dan.merillat@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 17:07:34 +02:00
David Sterba faf8b94323 btrfs-progs: restore: cleanup, use PATH_MAX
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
David Sterba 6e0a620ba6 btrfs-progs: check: fix compile warnings in del_file_extent_hole
make[1]: Nothing to be done for `all'.
cmds-check.c: In function ‘del_file_extent_hole’:
cmds-check.c:289:26: warning: ‘prev.start’ may be used uninitialized in this function
cmds-check.c:289:26: warning: ‘prev.len’ may be used uninitialized in this function
cmds-check.c:290:26: warning: ‘next.start’ may be used uninitialized in this function
cmds-check.c:290:26: warning: ‘next.len’ may be used uninitialized in this function

Reported-by: Anand Jain <Anand.Jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
David Sterba 9ea0eff31f btrfs-progs: restore: convert copy_file exit paths to a single return
Resolves-coverity-id: 1295365
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
David Sterba 97f8e20930 btrfs-progs: restore: convert search_dir exit paths to a single return
Resolves-coverity-id: 1295366
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
David Sterba a8762e43fd btrfs-progs: restore: fix path leak in copy_metadata
The path lifecycle spans only this function and we have to free it.

Resolves-coverity-id: 1295367
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
Lauri Võsandi 9a86668071 btrfs-progs: optionally enforce chroot for btrfs receive
This patch forces btrfs receive to issue chroot before
parsing the btrfs stream using command-line flag -C
to confine the process and minimize damage that could
be done via malicious btrfs stream.

Signed-off-by: Lauri Võsandi <lauri.vosandi@gmail.com>
[added long option variant, added docs]
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:05 +02:00
Dan Merillat 7732e6ef62 btrfs-progs: restore: optionally restore metadata
As long as the inode is intact, the file metadata can be restored.
Directory data is restored at the end of search_dir.  Errors are
checked and returned, unless ignore_errors is requested.

Signed-off-by: Dan Merillat <dan.merillat@gmail.com>
[minor style fixes, error message updates]
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:04 +02:00
Zygo Blaxell 7ab0bdd712 btrfs-progs: report failure when resize ioctl fails
The BTRFS_IOC_RESIZE ioctl returns 0 on success, negative for POSIX
errors, and positive for btrfs-specific errors.

If resize fails with a btrfs-specific error, decode the error and
report it.  If we can't decode the error, report its numeric value so
that the userspace tool is not instantly useless when a new error code
is defined in the kernel.

Exit with non-zero status on any resize error.  This is very important
for scripts that will shrink the underlying storage when btrfs reports
success!

Signed-off-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:04 +02:00
Anand Jain 2890c41504 btrfs-progs: fix typo in btrfs-device.txt
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:04 +02:00
Josef Bacik 2681e00f00 btrfs-progs: check for matching free space in cache
We have this check in the kernel but not in userspace, which makes fsck
fail when we wouldn't have a problem in the kernel.  This was meant to
catch this case because it really isn't good, unfortunately it will
require a design change to fix in the kernel so in the meantime add this
check so we can be sure our tests only catch real problems.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:42:04 +02:00
George Wang fb399a1301 btrfs-progs: fix btrfs quota rescan failed on PPC64 arch
PPC64 arch use such following IOC values "
\#define _IOC_NONE       1U
\#define _IOC_READ       2U
\#define _IOC_WRITE      4U
" comparing to the default IOC values "
\#define _IOC_NONE       0U
\#define _IOC_READ       2U
\#define _IOC_WRITE      1U"

This means the value "_IOW*" will be negative when we store it in the int
variables. Such as the "BTRFS_IOC_QGROUP_CREATE", it will be "0x4010942e" on
X86_64, but "0x8010942e" on PPC64.
Notice that the IOC values are the "unsigned long" type, so we use the
"unsigned long" to store it, and this can insure the comparison between the
variable and BTRFS_IOC_* valid.

Signed-off-by: George Wang <xuw2015@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[manpage states that it's int, kernel uses unsigned int, glibc wants
unsigned long int]
Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-24 15:41:59 +02:00
David Sterba 49eab99172 btrfs-progs: add zero-log to rescue command
Copy the functionality of standalone btrfs-zero-log to the main tool.
Delete man page for btrfs-zero-log and copy the relevant parts into
btrfs-rescue(8).  The standalone utility will be removed later.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-22 18:21:48 +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 e57dc6c753 btrfs-progs: fi resize: accept only directories as paths
Resize of a filesystem image does not work as expected. This has been
confusing and can have bad consequences as people have reported,
resizing the wrong filesystem.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-22 18:21:47 +02:00
David Sterba 7ffccaf0c3 btrfs-progs: Documentaion: rename to .asciidoc
A few minor benefits:

* editors set highliting according to the extensions
* web access to the git repository (github) renders the .asciidoc
  files:
  * we can link to them from the wiki
  * the files are editable via browser and such editations can be
    submitted for merge easily

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-14 17:41:27 +02:00
Anand Jain 32ca2fa502 btrfs-progs: improve troubleshooting avoid duplicate error strings
my troubleshooting experience says have unique error string per module.

In the below eg, its one additional step to know error line,

cat -n cmds-device.c | egrep "error removing the device"
   185	"ERROR: error removing the device '%s' - %s\n",
   190	"ERROR: error removing the device '%s' - %s\n",

which is completely avoidable.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
[merged the two messages into one]
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-14 15:19:04 +02:00
Anand Jain 672076d4b7 Btrfs-progs: fix compile warnings
simple compile time warning fixes.

btrfs-calc-size.c: In function ‘print_seek_histogram’:
btrfs-calc-size.c:221: warning: ‘group_start’ may be used uninitialized in this function
btrfs-calc-size.c:223: warning: ‘group_end’ may be used uninitialized in this function

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-14 15:11:24 +02:00
WorMzy Tykashi c5b2f66d63 btrfs-progs: use local btrfs-image in leaf corruption test
Currently this test uses the system btrfs-image. If there isn't a
btrfs-image on $PATH, the test fails. The test should be using the
locally compiled btrfs-image, not the system one.

Signed-off-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-09 18:45:00 +02:00
David Sterba 08f9acadab btrfs-progs: getopt, use symbolic name for argument requirements
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-08 17:39:51 +02:00
David Sterba 4074ae5f2b btrfs-progs: cleanup option index argument from getopt_long
We're not using it anywhere. The best practice is to add enums with
values > 255 for the long options, option index counting is error prone.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-08 17:33:55 +02:00
David Sterba 39b3d7c77a btrfs-progs: print fs features filtered by a mask
mkfs and convert will not support the same features, -O will print only
the list according to the given mask.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 19:25:16 +02:00
David Sterba 7ea86ad282 btrfs-progs: move feature parsing from mkfs to utils
We'll use them in convert as well. Move defines and the interface
functions to utils.*.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 19:24:35 +02:00
David Sterba a297698edc btrfs-progs: mkfs, deprecate leafsize and clean up the code
Using the --leafsize will issue a warning. Replace leafsize with
nodesize in the mkfs-related code.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 19:20:17 +02:00
David Sterba 445ed1f11c btrfs-progs: convert: use exact size for reading superblock
We've passed blocksize to prepare_system_chunk and used it to read and
write superblock. While this does not cause a bug (SUPER_INFO is
blocksize ie. page size on most arches), we should really use the
correct size.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 19:09:39 +02:00
David Sterba 54d316b5ec btrfs-progs: tests: remove duplicate output for fsck test 013
The test name is logged since it lives in it's own directory.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:37:49 +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
David Sterba 35d53302ac btrfs-progs: convert tests: preserve test image permissions
If the test image is eg. on NFS it's not writable for root, so chmod
0777 fixes that but then we must not delete the file.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 18:36:55 +02:00
Qu Wenruo 96563f961c btrfs-progs: Doc: Add warning and note on btrfs-convert.
Although btrfs-convert can rollback converted btrfs, it still has some
limitation to ensure rollback.

Add a warning on the limitations.

Also add a note for users who decides to go on with btrfs and don't need
the rollback ability.

Reported-by: Vytautas D <vytdau@gmail.com>
Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:44:05 +02:00
Qu Wenruo 45678c3048 btrfs-progs: convert-tests: Add check for converted btrfs with regular file extent.
Regression test for previous patch "btrfs-progs: convert: Make
ext*_image file obey datacsum setting."

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:23:12 +02:00
Qu Wenruo 0d9bbdc5e3 btrfs-progs: convert-tests: Update to use test framework infrastructure.
Also change the test() to convert_test(), to avoid conflict name with
bash test function.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:35 +02:00
Qu Wenruo a18f8b1665 btrfs-progs: fsck-tests: Add fallback TEST_DEV for test case 013
Add fallback TEST_DEV for test case 013.
Fallback to $TOP/tests/test.img.

Now all test cases of btrfs-progs need no extra setting except sudo.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:30 +02:00
Qu Wenruo 691695fe34 btrfs-progs: fsck-tests: Update 013-extent-tree-rebuild to use more test framework infrastructure.
Update 013-extent-tree-rebuild to use more framework infrastructure,
including:
1) Use run_check other than open-coded redirect
2) Add root privillege
3) Add dependency on 'btrfs-debug-tree' command

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:30 +02:00
Qu Wenruo 74dc9d82af btrfs-progs: fsck-tests: Remove duplicatesd TEST_MNT setup.
Since we have already had TEST_MNT fallback setup to $TOP/tests/mnt,
just remove duplicated setting in 012-leaf-corruption/test.sh

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:30 +02:00
Qu Wenruo 8720e15cd1 btrfs-progs: test-frame: Update variant names
Use upper case variant name for the following variants:
1) top -> TOP
2) script_dir -> SCRIPT_DIR

And change the following variant name:
1) RESULT -> RESULTS

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-07 17:22:30 +02:00
Qu Wenruo ffe9554b78 btrfs-progs: convert: Make ext*_image file obey datacsum setting.
Before this patch, ext*_image is always set NODATACSUM inode flag.
However btrfs-convert will set normal file with DATACUSM flag by
default, and generate checksum for regular file extent.

Now, a regular file extent is shared by a btrfs file inode with DATACSUM
and ext*_image with NODATACSUM, and it has checksum in csum tree.
This will cause btrfsck complain about odd checksum, since ext*_image is
set NODATACSUM but has checksum generated from regular file extent.

This patch makes convert completely obey datacsum setting, meaning
btrfs-convert will generate csum for every file extent by default.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-02 17:33:37 +02:00
Chen Hanxiao 153bbb93ec btrfs-progs doc: emphasis that only mounted device works for btrfs device stats
We provided format <path>|<device> in command line.
But btrfs device stats doesn't work if device is not mounted.

Also fix some tailing whitespace.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-02 17:26:35 +02:00
Zach Brown 6f0a14303f btrfs-progs: silence fake fsck
Harald suggested that we remove the message from the fake fsck.btrfs
that some distros run at boot:

  https://bugzilla.redhat.com/show_bug.cgi?id=1206502

"This output does not add anything, but is a disturbing element of
booting up a system. It's the only message I get, when starting my
system, before gdm is started."

I'm inclined to agree.

This makes the tiniest change to remove the message that's output for an
auto invocation.  My guess is that it was just copied from the xfs
fsck.xfs and that no one actually cares about it.

Signed-off-by: Zach Brown <zab@zabbo.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-02 17:03:20 +02:00