summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: tests: common: add helper run_check_stdoutDavid Sterba2015-06-02
| | | | | | | 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>
* btrfs-progs: tests: add driver script for misc testsDavid Sterba2015-06-02
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add info about list-all to the helpAnand Jain2015-06-01
| | | | | | | | 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>
* btrfs-progs: receive: restore capabilities after chownDavid Sterba2015-05-27
| | | | | | | | | | | | | | | | 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>
* btrfs-progs: btrfstune: fix a bug which makes unfinished fsid change ↵Qu Wenruo2015-05-26
| | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: Documentation: uuid changeQu Wenruo2015-05-26
| | | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [updated wodring] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: add '-U' and '-u' option to change fsidQu Wenruo2015-05-26
| | | | | | | | | | | | | | | | | 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>
* btrfs-progs: btrfstune: add ability to restore unfinished fsid changeQu Wenruo2015-05-26
| | | | | | | | 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>
* btrfs-progs: btrfstune: rework change_uuidQu Wenruo2015-05-26
| | | | | | | | | | | | | | | | | | | 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>
* Btrfs-progs: corrupt-block: add the ability to remove csumsJosef Bacik2015-05-26
| | | | | | | | 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>
* btrfs-progs: use openat for process_clone in receiveEmil Karlson2015-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: tests: add script to clean intermediate imagesDavid Sterba2015-05-25
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: test: 015-check-bad-memory-accessDavid Sterba2015-05-25
| | | | | | | | | | | | | 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>
* btrfs-progs: tests: sort image filesDavid Sterba2015-05-25
| | | | | | | If a test has several images let filenames enforce a particular order of checks if desired. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Enhance read_tree_block to avoid memory corruptionQu Wenruo2015-05-25
| | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: tests: use readlink -f to resolve pathDavid Sterba2015-05-21
| | | | | | | 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>
* btrfs-progs: fsck.btrfs: Fix bashism and bad getopts processingDimitri John Ledkov2015-05-21
| | | | | | | | | | 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>
* btrfs-progs: tests: support more formats of test imagesDavid Sterba2015-05-21
| | | | | | | 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>
* btrfs-progs: tests: log the test name in results fileDavid Sterba2015-05-21
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs progs v4.0.1David Sterba2015-05-20
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Fix a bug in chunk item extra check and allow degraded chunk.Qu Wenruo2015-05-20
| | | | | | | | | | | | 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>
* btrfs-progs: Add extra chunk item check to avoid btrfs-progs crash.Qu Wenruo2015-05-14
| | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: Remove non-exist csum size.Qu Wenruo2015-05-14
| | | | | | | | | | | 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>
* btrfs-progs: Introduce change_uuid functionQu Wenruo2015-05-14
| | | | | | | 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>
* btrfs-progs: Introduce change_fsid_prepare and change_fsid_done functionsQu Wenruo2015-05-14
| | | | | | | | | | 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>
* btrfs-progs: Introduce change_devices_uuid function.Qu Wenruo2015-05-14
| | | | | | | 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>
* btrfs-progs: Introduce change_device_uuid functionQu Wenruo2015-05-14
| | | | | | | This function changes a device items uuid. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_extents_uuid functionQu Wenruo2015-05-14
| | | | | | | | | | 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>
* btrfs-progs: Introduce change_header_uuid functionQu Wenruo2015-05-14
| | | | | | | | | | 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>
* btrfs-progs: Export write_tree_blockQu Wenruo2015-05-14
| | | | | | | | | | 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>
* btrfs-progs: Add open_ctree check for uuid changingQu Wenruo2015-05-14
| | | | | | | | | | | 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>
* btrfs-progs: show-super: print human readable text for super flagsQu Wenruo2015-05-14
| | | | | | | | | 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>
* btrfs-progs: Use unified function to implement print_readable_*_flag functionQu Wenruo2015-05-14
| | | | | | | | | | 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>
* btrfs-progs: Add CHANGING_FSID super flagQu Wenruo2015-05-14
| | | | | | | | | 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>
* btrfs-progs: use the correct variableAnand Jain2015-05-14
| | | | | | | | 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>
* btrfs-progs: btrfs_scan_block_devices is unused function delete itAnand Jain2015-05-14
| | | | | | | | | 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>
* btrfs-progs: fsck: Fix a shallow copy which will leads to segfault.Qu Wenruo2015-05-14
| | | | | | | | | | | | | | | 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>
* btrfs-progs: convert: drop dependency on sys/acl.hDavid Sterba2015-05-14
| | | | | | | | | | | | | | 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>
* btrfs-progs: restore: add more long option variantsDavid Sterba2015-05-14
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: restore: shift option textsDavid Sterba2015-05-14
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: restore: use bigger buffer for output path nameDavid Sterba2015-05-14
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: optionally restore symlinks.Dan Merillat2015-05-14
| | | | | | | Restore symlinks, optionally with owner/times. Signed-off-by: Dan Merillat <dan.merillat@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: restore: separate the overwrite checkDan Merillat2015-04-29
| | | | | | | | | 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>
* Btrfs progs v4.0David Sterba2015-04-29
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: restore: don't misreport errors from search_dirDavid Sterba2015-04-29
| | | | | | | | 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>
* btrfs-progs: receive: unconditionally print if doing chrootDavid Sterba2015-04-24
| | | | | | | 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>
* btrfs-progs: fix typos in restore help/docDavid Sterba2015-04-24
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: restore: document metadata restore.Dan Merillat2015-04-24
| | | | | | | 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>
* btrfs-progs: restore: cleanup, use PATH_MAXDavid Sterba2015-04-24
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: check: fix compile warnings in del_file_extent_holeDavid Sterba2015-04-24
| | | | | | | | | | | | 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>