Anand Jain [Mon, 1 Jun 2015 06:25:18 +0000 (14:25 +0800)]
btrfs-progs: use function is_block_device() instead
Here the delete code as below, is trying to check if the provided device
is a block device, there is a function for it. Use it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Sam Tygier [Sat, 30 May 2015 14:54:48 +0000 (15:54 +0100)]
btrfs-progs: mkfs: check metadata redundancy
Currently BTRFS allows you to make bad choices of data and
metadata levels. For example -d raid1 -m raid0 means you can
only use half your total disk space, but will lose everything
if 1 disk fails. It should give a warning in these cases.
When making a filesystem, check that metadata mode is at least
as redundant as the data mode. For example give warning when:
-d raid1 -m raid0
Signed-off-by: Sam Tygier <samtygier@yahoo.co.uk>
[make the check more visible in mkfs output]
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 2 Jun 2015 14:37:20 +0000 (16:37 +0200)]
btrfs-progs: tests: add misc test for fs features
A sample test for the misc-test category. Verify that btrfstune sets the
requested fs features. Now implemented extrefs, skinny-metadata and
seeding.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 2 Jun 2015 13:57:51 +0000 (15:57 +0200)]
btrfs-progs: tests: common: add helper run_check_stdout
Sometimes we need to process the output of the command, but run_check
captures all the output into results file.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 2 Jun 2015 13:00:32 +0000 (15:00 +0200)]
btrfs-progs: tests: add driver script for misc tests
Signed-off-by: David Sterba <dsterba@suse.cz>
Anand Jain [Mon, 1 Jun 2015 06:20:24 +0000 (14:20 +0800)]
btrfs-progs: add info about list-all to the help
mkfs.btrfs -O list-all is a good options to list features,
publish it in the help.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 27 May 2015 16:29:57 +0000 (18:29 +0200)]
btrfs-progs: receive: restore capabilities after chown
Capabilities are cleared after chown, and the btrfs-stream encodes the
CHOWN command after any SET_XATTR command. So the capabilites are not
always preserved.
This could be fixed in kernel to emit the instructions in the right
order, but fix in userspace will make it work for older kernels.
If we see the capabilities among xattrs, cache the value and apply it
again in case it's followed by chown on that file.
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=68891
Reported-by: Juan Orti Alcaine <j.orti.alcaine@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 06:36:35 +0000 (14:36 +0800)]
btrfs-progs: btrfstune: fix a bug which makes unfinished fsid change unrecoverable
This bug is found by making break point after change_fsid_prepare() and
then kill the unfinished change, then try to restore the unfinished fsid
change.
If fsid change is canceled, open_ctree will still fail even with
IGNORE_FSID_MIMATCH open ctree flag, since it can't find device with
mismatched fsid, making it unable to restoring.
Now add ignore_fsid_mismatch judgment in btrfs_find_device() to fix the
bug and allow later restore to work as expected.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 06:28:26 +0000 (14:28 +0800)]
btrfs-progs: Documentation: uuid change
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[updated wodring]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 06:28:25 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: add '-U' and '-u' option to change fsid
Add two options, '-U' and '-u' for btrfstune.
For '-u', it is used to change fsid to a random new UUID.
For '-U', it is used to change fsid to a specified UUID.
Both will also change the internal use only chunk_tree_uuid to a random
new UUID.
Although there is a GNU getopt extension "::" to get optional
option-argument, but is forbidden by POSIX.1-2008, so use split options
here.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 06:28:24 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: add ability to restore unfinished fsid change
Now change_uuid() can auto detected unfinished fsid change and restore
it.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 06:28:23 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: rework change_uuid
Change the change_uuid():
1) Remove new_chunk_tree_uuid parameter
As chunk_tree_uuid is only internal used, no need to manual specify it.
Use random generated UUID instead.
2) Don't use heap allocated memory for fs_info->new_fsid/chunk_tree_id.
It's easy to forgot free or double free heap memory.
Use stack memory instead.
(In fact, I forgot to free them in previous patchset)
3) Print destination fsid.
As now it's possible to change fsid to random uuid, it's better to print
it out.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Josef Bacik [Tue, 19 May 2015 14:21:04 +0000 (10:21 -0400)]
Btrfs-progs: corrupt-block: add the ability to remove csums
Sometimes we need to test what happens when we're missing a csum for a range, so
add an option to btrfs-corrupt-block to be able to remove a csum range. Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Emil Karlson [Thu, 21 May 2015 15:42:29 +0000 (18:42 +0300)]
btrfs-progs: use openat for process_clone in receive
This will fix breakage, when doing chrooted receive with cloned paths
outside main subvolume.
Steps to reproduce:
$ create subvolume
$ create file
$ snapshot to snap1
$ delete file
$ snapshot to snap2
$ reflink file from snap1
$ snapsthot to snap3
$ send full snap1 | receive --chroot
$ send incremental snap2 | receive --chroot
$ send incremental snap3 | receive --chroot
The last step would fail with:
Chroot to /mnt/recvdir
At snapshot snap3
ERROR: failed to open /recvdir/snap1/file. No such file or directory
Signed-off-by: Emil Karlson <jekarlson@gmail.com>
[added reproducer]
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 25 May 2015 14:08:46 +0000 (16:08 +0200)]
btrfs-progs: tests: add script to clean intermediate images
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 25 May 2015 13:39:29 +0000 (15:39 +0200)]
btrfs-progs: test: 015-check-bad-memory-access
Crafted images may trigger out-of-bounds access during check, fixed by
"btrfs-progs: Enhance read_tree_block to avoid memory corruption"
Now adding image for the first one, the other need enhancements in the
testing framework.
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97171
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97191
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97271
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 25 May 2015 13:35:58 +0000 (15:35 +0200)]
btrfs-progs: tests: sort image files
If a test has several images let filenames enforce a particular order of
checks if desired.
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 22 May 2015 01:01:23 +0000 (09:01 +0800)]
btrfs-progs: Enhance read_tree_block to avoid memory corruption
Add the following tree block check to avoid memory corruption on hostile
image:
1) Check level.
Level >= BTRFS_MAX_LEVEL won't be read out.
2) Nritems.
For nr_items > max_nritems, the tree_block won't be read out.
Max nritems is calculated in a easy method.
For node, it's straightforward, just (nodesize - header size) /
(btrfs_key_ptr)
For leaf, (nodesize - header size) / (btrfs_item), as btrfs support zero
item size
This fixes 3 kernel bugs: BZ#97171, BZ#97191, BZ#97271.
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 21 May 2015 16:48:55 +0000 (18:48 +0200)]
btrfs-progs: tests: use readlink -f to resolve path
The utility 'realpath' from coreutils is new enough to be missing on my
"old" reference build host.
Signed-off-by: David Sterba <dsterba@suse.cz>
Dimitri John Ledkov [Thu, 21 May 2015 12:50:55 +0000 (13:50 +0100)]
btrfs-progs: fsck.btrfs: Fix bashism and bad getopts processing
First fix == bashism, as that is not accepted by e.g. Debian/Ubuntu
dash.
Secondly shift OPTIND, such that last parameter is checked to exist.
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 21 May 2015 14:33:16 +0000 (16:33 +0200)]
btrfs-progs: tests: support more formats of test images
We're using he meta-dump images, now we support compressed meta-dump,
raw and compressed raw images.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 21 May 2015 13:04:29 +0000 (15:04 +0200)]
btrfs-progs: tests: log the test name in results file
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 20 May 2015 13:12:44 +0000 (15:12 +0200)]
Btrfs progs v4.0.1
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 15 May 2015 05:11:14 +0000 (13:11 +0800)]
btrfs-progs: Fix a bug in chunk item extra check and allow degraded chunk.
For DUP profile, the num_stripes should be 2 not 1.
This causes btrfs offline tool fails on valid image.
Also, num_stripes check is too restrict for btrfsck self test,
as there is some image in degraded mode, so modify it to allow degraded
chunk.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 13 May 2015 09:15:36 +0000 (17:15 +0800)]
btrfs-progs: Add extra chunk item check to avoid btrfs-progs crash.
Adds extra check when reading a chunk item:
1) Check chunk type.
Don't allow any unsupported type/profile bit.
2) Check num_stripes
Any chunk item should contain at least one stripe.
For system chunk, the chunk item size(calculated by btrfs_stripe size *
(num_stripes - 1) + btrfs_chunk size) should not exceed
BTRFS_SYSTEM_CHUNK_SIZE(2048).
For normal chunk, the chunk item size(calculated) should match the chunk
item size.
3) Check num_stripes/sub_stripes against chunk profile.
Num_stripes/sub_stripes must meet its lower limit for its chunk profile.
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 13 May 2015 09:15:33 +0000 (17:15 +0800)]
btrfs-progs: Remove non-exist csum size.
Current btrfs only support CRC32 as checksum algorithm.
But in btrfs_csum_sizes array, we have an extra 0 at tail, causing
csum_type 1 can still be considered as supported csum type.
Fix it by removing the tailing 0.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 13 May 2015 14:42:21 +0000 (16:42 +0200)]
btrfs-progs: Introduce change_uuid function
This function does all the needed things for changing filesystem uuid.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 13 May 2015 14:41:51 +0000 (16:41 +0200)]
btrfs-progs: Introduce change_fsid_prepare and change_fsid_done functions
These two functions will write flags to all supers before and after
fsid/chunk tree id change, informing kernel not to mount a inconsistent
fs.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[removed chunk tree super flag]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:50 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_devices_uuid function.
This function will change all device items' fsid.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:49 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_device_uuid function
This function changes a device items uuid.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:48 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_extents_uuid function
This is the function which iterates all metadata extents and changes
their fsid.
This function also does it without transaction.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:47 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_header_uuid function
This function is used to change fsid and chunk_tree_uuid of a node/leaf.
The function does it without transaction protection.
This is the basis of offline uuid change.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:46 +0000 (16:08 +0800)]
btrfs-progs: Export write_tree_block
Export write_tree_block() function and allow it write extent without
transaction.
This provides the basis for later uuid change function.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:45 +0000 (16:08 +0800)]
btrfs-progs: Add open_ctree check for uuid changing
Now open_ctree will exit if it found the superblock is marked
CHANGING_FSID, except given IGNORE_FSID open ctree flags.
Kernel will do the same thing later.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[removed the chunk tree flag, reworded the error message]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:44 +0000 (16:08 +0800)]
btrfs-progs: show-super: print human readable text for super flags
Use the new __print_readable_flag() to implement
print_readable_super_flag().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[removed the chunk tree flag]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:43 +0000 (16:08 +0800)]
btrfs-progs: Use unified function to implement print_readable_*_flag function
Now add a new unified __print_readable_flag() function to implement
print_readable_incompat_flag().
This makes later extension for human readable flags easier.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 11 May 2015 08:08:42 +0000 (16:08 +0800)]
btrfs-progs: Add CHANGING_FSID super flag
Add the super flag to inform kernel not to mount a filesystem wich fsid
change is in progress.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[removed the chunk tree flag]
Signed-off-by: David Sterba <dsterba@suse.cz>
Anand Jain [Mon, 11 May 2015 13:55:52 +0000 (21:55 +0800)]
btrfs-progs: use the correct variable
It's res instead of ret, wrong error message could be prointed in case
of error.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Anand Jain [Tue, 7 Oct 2014 00:08:31 +0000 (08:08 +0800)]
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>
Qu Wenruo [Tue, 5 May 2015 02:20:19 +0000 (10:20 +0800)]
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>
David Sterba [Mon, 4 May 2015 16:36:21 +0000 (18:36 +0200)]
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>
David Sterba [Wed, 29 Apr 2015 16:26:08 +0000 (18:26 +0200)]
btrfs-progs: restore: add more long option variants
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 29 Apr 2015 16:11:46 +0000 (18:11 +0200)]
btrfs-progs: restore: shift option texts
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 29 Apr 2015 16:08:28 +0000 (18:08 +0200)]
btrfs-progs: restore: use bigger buffer for output path name
Signed-off-by: David Sterba <dsterba@suse.cz>
Dan Merillat [Wed, 29 Apr 2015 16:06:27 +0000 (18:06 +0200)]
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>
Dan Merillat [Thu, 23 Apr 2015 16:51:33 +0000 (12:51 -0400)]
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>
David Sterba [Wed, 29 Apr 2015 14:56:22 +0000 (16:56 +0200)]
Btrfs progs v4.0
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 29 Apr 2015 14:48:04 +0000 (16:48 +0200)]
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>
David Sterba [Fri, 24 Apr 2015 16:01:32 +0000 (18:01 +0200)]
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>
David Sterba [Fri, 24 Apr 2015 15:28:37 +0000 (17:28 +0200)]
btrfs-progs: fix typos in restore help/doc
Signed-off-by: David Sterba <dsterba@suse.cz>
Dan Merillat [Thu, 23 Apr 2015 16:50:26 +0000 (12:50 -0400)]
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>
David Sterba [Thu, 23 Apr 2015 15:41:08 +0000 (17:41 +0200)]
btrfs-progs: restore: cleanup, use PATH_MAX
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 23 Apr 2015 15:28:30 +0000 (17:28 +0200)]
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>
David Sterba [Thu, 23 Apr 2015 15:15:04 +0000 (17:15 +0200)]
btrfs-progs: restore: convert copy_file exit paths to a single return
Resolves-coverity-id: 1295365
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 23 Apr 2015 14:55:03 +0000 (16:55 +0200)]
btrfs-progs: restore: convert search_dir exit paths to a single return
Resolves-coverity-id: 1295366
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 23 Apr 2015 14:40:07 +0000 (16:40 +0200)]
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>
Lauri Võsandi [Sun, 19 Apr 2015 11:46:28 +0000 (14:46 +0300)]
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>
Dan Merillat [Tue, 21 Apr 2015 05:48:24 +0000 (01:48 -0400)]
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>
Zygo Blaxell [Wed, 22 Apr 2015 03:38:47 +0000 (23:38 -0400)]
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>
Anand Jain [Wed, 22 Apr 2015 16:16:41 +0000 (18:16 +0200)]
btrfs-progs: fix typo in btrfs-device.txt
Signed-off-by: David Sterba <dsterba@suse.cz>
Josef Bacik [Fri, 17 Apr 2015 18:02:15 +0000 (14:02 -0400)]
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>
George Wang [Mon, 20 Apr 2015 05:33:16 +0000 (13:33 +0800)]
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>
David Sterba [Wed, 13 Nov 2013 17:55:12 +0000 (18:55 +0100)]
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>
David Sterba [Fri, 17 Apr 2015 16:29:38 +0000 (18:29 +0200)]
btrfs-progs: cleanup, rename *disk_usage* files to usage
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 17 Apr 2015 16:20:32 +0000 (18:20 +0200)]
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>
David Sterba [Tue, 14 Apr 2015 15:37:23 +0000 (17:37 +0200)]
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>
Anand Jain [Mon, 13 Apr 2015 12:37:01 +0000 (20:37 +0800)]
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>
Anand Jain [Tue, 14 Apr 2015 13:07:31 +0000 (15:07 +0200)]
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>
WorMzy Tykashi [Wed, 8 Apr 2015 14:50:04 +0000 (15:50 +0100)]
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>
David Sterba [Wed, 8 Apr 2015 15:39:51 +0000 (17:39 +0200)]
btrfs-progs: getopt, use symbolic name for argument requirements
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 8 Apr 2015 15:33:55 +0000 (17:33 +0200)]
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>
David Sterba [Mon, 23 Mar 2015 18:49:51 +0000 (19:49 +0100)]
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>
David Sterba [Mon, 23 Mar 2015 18:20:37 +0000 (19:20 +0100)]
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>
David Sterba [Mon, 2 Feb 2015 14:51:15 +0000 (15:51 +0100)]
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>
David Sterba [Tue, 7 Apr 2015 17:09:39 +0000 (19:09 +0200)]
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>
David Sterba [Tue, 7 Apr 2015 16:34:00 +0000 (18:34 +0200)]
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>
David Sterba [Tue, 7 Apr 2015 16:29:05 +0000 (18:29 +0200)]
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>
David Sterba [Tue, 7 Apr 2015 16:09:18 +0000 (18:09 +0200)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:23:13 +0000 (15:23 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:17 +0000 (15:01 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:16 +0000 (15:01 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:15 +0000 (15:01 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:14 +0000 (15:01 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:13 +0000 (15:01 +0800)]
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>
Qu Wenruo [Fri, 3 Apr 2015 07:01:12 +0000 (15:01 +0800)]
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>
Qu Wenruo [Thu, 2 Apr 2015 02:21:35 +0000 (10:21 +0800)]
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>
Chen Hanxiao [Wed, 1 Apr 2015 07:52:57 +0000 (03:52 -0400)]
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>
Zach Brown [Fri, 27 Mar 2015 21:58:43 +0000 (14:58 -0700)]
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>
David Sterba [Wed, 25 Mar 2015 17:43:42 +0000 (18:43 +0100)]
Btrfs progs v3.19.1
Signed-off-by: David Sterba <dsterba@suse.cz>
Mike Gilbert [Wed, 25 Mar 2015 00:55:41 +0000 (20:55 -0400)]
btrfs-progs: Fix autoconf handling of --enable-convert
AC_ARG_ENABLE(convert) sets $enable_convert, not $enable_btrfsconvert.
Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 24 Mar 2015 18:39:46 +0000 (19:39 +0100)]
Btrfs progs v3.19.1-rc1
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 2 Feb 2015 14:35:37 +0000 (15:35 +0100)]
btrfs-progs: mkfs, add required arguments to help strings
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 2 Feb 2015 14:32:11 +0000 (15:32 +0100)]
btrfs-progs: mkfs, align help strings
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Mon, 23 Mar 2015 17:45:56 +0000 (18:45 +0100)]
btrfs-progs: convert, add long options for all short options
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:38 +0000 (16:26 +0800)]
btrfs-progs: Print warning message if qgroup data is inconsistent
Before this patch, qgroup show won't check btrfs qgroup status, so even
the INCONSISTENT flags is set, user is not aware of it.
This patch will include BTRFS_QGROUP_STATUS_ITEM in the search range and
check the flag, if there is any flag meaning the inconsistence of qgroup
data, info user.
NOTE: There is several kernel bugs from INCONSISTENT flags is always set
to RUNNING flags is not cleared until umount.
So this warning will always be here if using a newer kernel fixing these
bugs.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:37 +0000 (16:26 +0800)]
btrfs-progs: Add stack get/set functions for btrfs_qgroup_status_item
This provides the basis for later qgroup related changes.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:36 +0000 (16:26 +0800)]
btrfs-progs: Allow parse_qgroupid() to resolve subvolume path into qgroupid
Now parse_qgroupid() can resolve subvolume path into qgroupid.
This is quite handy for handling level 0 qgroupid, and user don't need
to resolve rootid by hand now.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[constify string in __is_subvol]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:35 +0000 (16:26 +0800)]
btrfs-progs: Move parse_qgroupid() to utils.c
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[constified strings in parse_qgroupid]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:34 +0000 (16:26 +0800)]
btrfs-progs: Allow btrfs-debug-tree to print human readable qgroup status flag.
Now btrfs-debug-tree can print qgroup status flag as ON|INCONSISTENT
instead of 0x5.
BTW, this patch helped us to find a bug that INCONSISTENT flag is never
cleared in kernel.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[renamed to qgroup_flags_to_str]
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 27 Feb 2015 08:26:33 +0000 (16:26 +0800)]
btrfs-progs: Update qgroup status flags and replace qgroup level/subvid calculation with inline function
Ctree.h of btrfs-progs contains wrong flags for btrfs_qgroup_status.
Update it with the one in kernel.
Also, introduce the inline function btrfs_qgroup_(level/subvid) to get
the level/subvolid of qgroup, to replace the old open-coded bit
operations.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>