platform/upstream/btrfs-progs.git
7 years agobtrfs-progs: dump-tree: improved error handling in print_extents
David Sterba [Fri, 26 Aug 2016 10:53:31 +0000 (12:53 +0200)]
btrfs-progs: dump-tree: improved error handling in print_extents

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fi usage: improved error handling in load_device_info
David Sterba [Fri, 26 Aug 2016 10:53:31 +0000 (12:53 +0200)]
btrfs-progs: fi usage: improved error handling in load_device_info

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: scrub: improved error handling in scrub_read_file
David Sterba [Fri, 26 Aug 2016 10:53:31 +0000 (12:53 +0200)]
btrfs-progs: scrub: improved error handling in scrub_read_file

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoBtrfs progs v4.7.3
David Sterba [Wed, 21 Sep 2016 11:59:53 +0000 (13:59 +0200)]
Btrfs progs v4.7.3

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: update CHANGES for 4.7.3
David Sterba [Thu, 28 Jul 2016 12:18:59 +0000 (14:18 +0200)]
btrfs-progs: update CHANGES for 4.7.3

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: use preallocated buffers for config uuids
David Sterba [Wed, 31 Aug 2016 17:38:31 +0000 (19:38 +0200)]
btrfs-progs: mkfs: use preallocated buffers for config uuids

No need for dynamic allocation, the buffers are small, remove the
now-useless error conditions.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: fix reading rotational status value
David Sterba [Wed, 21 Sep 2016 11:36:04 +0000 (13:36 +0200)]
btrfs-progs: mkfs: fix reading rotational status value

ASAN reports that we're reading beyond the bounds, and is right. The
variable is too short to store a nonempty string for atoi.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: defrag: set errno correctly in the callback
David Sterba [Tue, 20 Sep 2016 14:45:36 +0000 (16:45 +0200)]
btrfs-progs: defrag: set errno correctly in the callback

In case defrag fails, the errno is not properly reported everywhere but
rather the last value of 'e', which could be 0. Then we get confusing
error messages like:

ERROR: defrag failed on /path/to/file: Success

Reported-by: Adam Mizerski <adam@mizerski.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: subvol create: remove v from getopt
David Sterba [Mon, 19 Sep 2016 17:43:24 +0000 (19:43 +0200)]
btrfs-progs: subvol create: remove v from getopt

The option 'v' was mistakenly added in
2ed161bd281beca29feebebbc8c4227cc6e918c3 but there's no such option for
create at the moment, remove it.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: subvol delete: add missing verbose option
Vincent Batts [Thu, 15 Sep 2016 19:15:50 +0000 (15:15 -0400)]
btrfs-progs: subvol delete: add missing verbose option

There was already the logic for verbose output, but the flag parsing did
not include it.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: docs: fix typos in btrfs-subvolume
adduxa [Sat, 17 Sep 2016 08:34:38 +0000 (11:34 +0300)]
btrfs-progs: docs: fix typos in btrfs-subvolume

[ Documentation fix, github pull request 16 ]
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoRevert "btrfs-progs: fix compat_ro mask for free space tree"
Omar Sandoval [Sat, 10 Sep 2016 00:02:14 +0000 (17:02 -0700)]
Revert "btrfs-progs: fix compat_ro mask for free space tree"

btrfs-progs can't mount space_cache=v2 filesystems read-write, which is
why the compat bit wasn't added to the supported mask in the first
place. Remove it.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: reorganize extent_buffer and fix alignment of data
David Sterba [Mon, 12 Sep 2016 09:13:24 +0000 (11:13 +0200)]
btrfs-progs: reorganize extent_buffer and fix alignment of data

Reported by UBSAN, the checksum code tries to access unaligned data that
come from the extent_buffer.

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u32                        len;                  /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        struct extent_io_tree *    tree;                 /*    72     8 */
        struct list_head           lru;                  /*    80    16 */
        struct list_head           recow;                /*    96    16 */
        int                        refs;                 /*   112     4 */
        u32                        flags;                /*   116     4 */
        int                        fd;                   /*   120     4 */
        char                       data[0];              /*   124     0 */

        /* size: 128, cachelines: 2, members: 11 */
        /* sum members: 120, holes: 1, sum holes: 4 */
        /* padding: 4 */
};

Add explicit alignment to data.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156471
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add 021-partially-dropped-snapshot-case
Wang Xiaoguang [Thu, 25 Aug 2016 05:21:01 +0000 (13:21 +0800)]
btrfs-progs: tests: add 021-partially-dropped-snapshot-case

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: check: make low memory mode support partially dropped snapshots
Wang Xiaoguang [Thu, 25 Aug 2016 05:21:00 +0000 (13:21 +0800)]
btrfs-progs: check: make low memory mode support partially dropped snapshots

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: better error report in btrfs_scan_fs_devices
David Sterba [Fri, 9 Sep 2016 13:56:18 +0000 (15:56 +0200)]
btrfs-progs: better error report in btrfs_scan_fs_devices

Print the found sizes.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed images for bad block group offset
David Sterba [Fri, 9 Sep 2016 13:33:20 +0000 (15:33 +0200)]
btrfs-progs: tests: add fuzzed images for bad block group offset

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: avoid looping forever when a bad blockgroup key is found
Jeff Mahoney [Fri, 9 Sep 2016 13:22:19 +0000 (15:22 +0200)]
btrfs-progs: avoid looping forever when a bad blockgroup key is found

If we discover a bad BLOCK_GROUP_ITEM_KEY with offset = 0, we'll end up looping
forever when we read the block groups in.  This is due to the search for the
next block group starting at the current object + the offset.  If offset is 0,
we'll just get the same key over and over and never advance.  This patch
ensures that we'll advance at least one objectid per iteration.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: remove stray newline from message in check_super
David Sterba [Thu, 8 Sep 2016 16:42:45 +0000 (18:42 +0200)]
btrfs-progs: remove stray newline from message in check_super

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: run check with various options on the fuzzed images
David Sterba [Thu, 8 Sep 2016 16:17:48 +0000 (18:17 +0200)]
btrfs-progs: tests: run check with various options on the fuzzed images

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzz test to try btrfs-image on all images
David Sterba [Thu, 8 Sep 2016 16:06:44 +0000 (18:06 +0200)]
btrfs-progs: tests: add fuzz test to try btrfs-image on all images

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: rename test 001 to mention check
David Sterba [Thu, 8 Sep 2016 15:57:02 +0000 (17:57 +0200)]
btrfs-progs: tests: rename test 001 to mention check

Make it more clear that the test does 'btrfs check'.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed image for a bad backref
David Sterba [Thu, 8 Sep 2016 12:12:25 +0000 (14:12 +0200)]
btrfs-progs: tests: add fuzzed image for a bad backref

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tree-stats: check and report mount status
David Sterba [Wed, 7 Sep 2016 13:31:27 +0000 (15:31 +0200)]
btrfs-progs: tree-stats: check and report mount status

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: docs: update flushoncommit default value
David Sterba [Tue, 6 Sep 2016 17:06:42 +0000 (19:06 +0200)]
btrfs-progs: docs: update flushoncommit default value

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: docs: Add warning for build RAID btrfs on partions from the same device
Qu Wenruo [Tue, 6 Sep 2016 15:35:33 +0000 (17:35 +0200)]
btrfs-progs: docs: Add warning for build RAID btrfs on partions from the same device

Quite a common sense for any RAID-like multi-device setup, just in case.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: Warn user for minimal RAID5/6 devices setup
Qu Wenruo [Tue, 6 Sep 2016 15:35:06 +0000 (17:35 +0200)]
btrfs-progs: mkfs: Warn user for minimal RAID5/6 devices setup

For RAID5, 2 devices setup is just RAID1 with more overhead.
For RAID6, 3 devices setup is RAID1 with 3 copies, not what most user
want.

So warn user at mkfs time for such case, and add explain in man pages.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: post btrfs-convert verify permissions and ACLs
Lakshmipathi.G [Mon, 5 Sep 2016 19:27:36 +0000 (21:27 +0200)]
btrfs-progs: tests: post btrfs-convert verify permissions and ACLs

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: build: add UBSAN to debugging features
David Sterba [Sat, 3 Sep 2016 19:36:53 +0000 (21:36 +0200)]
btrfs-progs: build: add UBSAN to debugging features

usage: make D=ubsan

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: dump-super: changes in options to specify superblocks
David Sterba [Fri, 2 Sep 2016 14:57:23 +0000 (16:57 +0200)]
btrfs-progs: dump-super: changes in options to specify superblocks

Some tools (check, select-super, dump-super) can use the alternate
superblocks, but the options are not consistent. To make it less
confusing, change the meaning of option -s in 'dump-super' to specify
the superblock copy, instead of taking the offset.

Though this is a change in UI, the old usage is detected and the result
would be the same, no breakage in existing scripts.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoBtrfs progs v4.7.2
David Sterba [Mon, 5 Sep 2016 10:21:24 +0000 (12:21 +0200)]
Btrfs progs v4.7.2

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: update CHANGES for 4.7.2
David Sterba [Thu, 28 Jul 2016 12:18:59 +0000 (14:18 +0200)]
btrfs-progs: update CHANGES for 4.7.2

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoRevert "btrfs-progs: check: supplement extent backref list with rbtree"
David Sterba [Mon, 5 Sep 2016 10:02:31 +0000 (12:02 +0200)]
Revert "btrfs-progs: check: supplement extent backref list with rbtree"

This reverts commit 31d8235410985e0b64487354c9ba67d40c4bdfe3.

False report of backref mismatches, lots of messages similar to:

Incorrect local backref count on 12713984 root 5 owner 257 offset 12845056 found 1 wanted 0 back 0x7b3ed0
backpointer mismatch on [12713984 131072]

Repairing will make things worse. A fix has been proposed, but is not
finalized so we go with a revert.

Reported-by: Chris Murphy <bugzilla@colorremedies.com>
References: https://bugzilla.kernel.org/show_bug.cgi?id=155791
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoRevert "btrfs-progs: check: switch to iterating over the backref_tree"
David Sterba [Mon, 5 Sep 2016 10:01:07 +0000 (12:01 +0200)]
Revert "btrfs-progs: check: switch to iterating over the backref_tree"

This reverts commit bbebe814c0e335745cfa773df966418e754b50e3.

7 years agobtrfs-progs: build: add ASAN to debugging features
David Sterba [Sat, 3 Sep 2016 19:36:53 +0000 (21:36 +0200)]
btrfs-progs: build: add ASAN to debugging features

usage: make D=asan

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed image for heap overflow while checking chunk items
David Sterba [Sat, 3 Sep 2016 18:52:18 +0000 (20:52 +0200)]
btrfs-progs: tests: add fuzzed image for heap overflow while checking chunk items

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed image for invalid chunk sectorsize
David Sterba [Sat, 3 Sep 2016 18:52:18 +0000 (20:52 +0200)]
btrfs-progs: tests: add fuzzed image for invalid chunk sectorsize

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed image for invalid sys_array and stripe_len
David Sterba [Sat, 3 Sep 2016 18:52:18 +0000 (20:52 +0200)]
btrfs-progs: tests: add fuzzed image for invalid sys_array and stripe_len

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add fuzzed image for invalid sub_stripe value
David Sterba [Sat, 3 Sep 2016 18:47:21 +0000 (20:47 +0200)]
btrfs-progs: tests: add fuzzed image for invalid sub_stripe value

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: image: more verbose syntax erors for -t and -c
David Sterba [Sat, 3 Sep 2016 18:34:47 +0000 (20:34 +0200)]
btrfs-progs: image: more verbose syntax erors for -t and -c

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: print help test to stdout
David Sterba [Sat, 3 Sep 2016 18:30:50 +0000 (20:30 +0200)]
btrfs-progs: print help test to stdout

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests: add 015-dump-super-garbage
David Sterba [Thu, 1 Sep 2016 18:05:20 +0000 (20:05 +0200)]
btrfs-progs: tests: add 015-dump-super-garbage

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: dump-super: detect invalid checksum type
David Sterba [Thu, 1 Sep 2016 17:54:04 +0000 (19:54 +0200)]
btrfs-progs: dump-super: detect invalid checksum type

The helper btrfs_super_csum_size unconditionally bugs on a bogus value,
the dump-super is supposed to dump even corrupted superblocks so this
must not happen here. Group the checsum values in the output and be more
robust agains garbage values.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: drop permission arg from non-creating open
David Sterba [Thu, 1 Sep 2016 17:38:23 +0000 (19:38 +0200)]
btrfs-progs: drop permission arg from non-creating open

The permissions do not make sense without O_CREATE mode.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: docs: describe filesystem features
David Sterba [Thu, 1 Sep 2016 16:51:18 +0000 (18:51 +0200)]
btrfs-progs: docs: describe filesystem features

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: build: only install udev rules for udev >= 190
Jeff Mahoney [Wed, 31 Aug 2016 01:15:44 +0000 (21:15 -0400)]
btrfs-progs: build: only install udev rules for udev >= 190

Prior to udev v190, there was no btrfs builtin helper.  Installing it on
systems with an older udev will cause problems.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: tests README: fuzzed images
David Sterba [Tue, 30 Aug 2016 15:09:10 +0000 (17:09 +0200)]
btrfs-progs: tests README: fuzzed images

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fuzz-test: Add test case for unaligned extent item
Qu Wenruo [Tue, 30 Aug 2016 07:22:17 +0000 (15:22 +0800)]
btrfs-progs: fuzz-test: Add test case for unaligned extent item

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fsck: Avoid abort and BUG_ON in add_tree_backref
Qu Wenruo [Tue, 30 Aug 2016 07:22:16 +0000 (15:22 +0800)]
btrfs-progs: fsck: Avoid abort and BUG_ON in add_tree_backref

Add_tree_backref() can cause BUG_ON() and abort() in quite a lot of
cases, from the ENOMEM to existing tree backref records.

Change all these BUG_ON() and abort() to return proper values.
And modify all callers to handle such problems.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fsck: Check bytenr alignment for extent item
Qu Wenruo [Tue, 30 Aug 2016 07:22:15 +0000 (15:22 +0800)]
btrfs-progs: fsck: Check bytenr alignment for extent item

Check bytenr alignment for extent item to filter invalid items early.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fuzz-test: Add test case for invalid drop level
Qu Wenruo [Tue, 30 Aug 2016 07:22:14 +0000 (15:22 +0800)]
btrfs-progs: fuzz-test: Add test case for invalid drop level

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fsck: Check drop level before walking through fs tree
Qu Wenruo [Tue, 30 Aug 2016 07:22:13 +0000 (15:22 +0800)]
btrfs-progs: fsck: Check drop level before walking through fs tree

Exposed by fuzzed image from Lukas, which contains invalid drop level
(16), causing segfault when accessing path->nodes[drop_level].

This patch will check drop level against fs tree level and
BTRFS_MAX_LEVEL to avoid such problem.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fuzz-test: Add image for unaligned tree block ptr
Qu Wenruo [Tue, 30 Aug 2016 03:29:33 +0000 (11:29 +0800)]
btrfs-progs: fuzz-test: Add image for unaligned tree block ptr

Add test case image for unaligned tree block ptr.
It should lead to BUG_ON in free_extent_buffer().

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: check: do early check for read_tree_block
Qu Wenruo [Tue, 30 Aug 2016 03:29:32 +0000 (11:29 +0800)]
btrfs-progs: check: do early check for read_tree_block

Although we have enhanced read_tree_block() from a lot of different
aspects, it lacks the early bytenr/blocksize alignment check.

And the lack of such check can lead to strange use-after-free bugs, due
to the fact that alloc_extent_buffer() will free overlapping extent
buffers, and allocate new eb for the usage.

So we should not allow invalid bytenr/blocksize even passed to
btrfs_find_create_tree_block().

This patch will add such check so we won't trigger use-after-free bug
then.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: fuzz-test: Add image for wrong chunk item in root tree
Qu Wenruo [Tue, 30 Aug 2016 02:15:50 +0000 (10:15 +0800)]
btrfs-progs: fuzz-test: Add image for wrong chunk item in root tree

Reported by Lukas and the same image from him.

DATA_RELOC tree's key type is modifed to CHUNK_ITEM, causing btrfsck
interpret it as CHUNK_ITEM and cause 0 num_stripes.

Add the image to fuzz-test.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ added bko-NNN- prefix to the files ]
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: Do extra chunk check before processing chunk item
Qu Wenruo [Mon, 29 Aug 2016 08:09:02 +0000 (16:09 +0800)]
btrfs-progs: Do extra chunk check before processing chunk item

Current we only do chunk validation check at mount time.

It's good for most case, but for fuzzed or manually crafted images, we
can insert a CHUNK_ITEM key into root tree.

Since mount time check will only check chunk tree, it will not check
CHUNK_ITEM in root tree.

Even with previous key type check against leaf owner, it is still
possible to modify the leaf owner to by-pass it.

So we still need to check chunk validation before processing it.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: check: ignore invalid key in invalid root
Qu Wenruo [Mon, 29 Aug 2016 08:09:01 +0000 (16:09 +0800)]
btrfs-progs: check: ignore invalid key in invalid root

Btrfs tree implies a lot of restriction on which key types are allowed
in specific roots.

Like CHUNK_ITEM keys are only valid in chunk root.

This patch will add such check at run_next_block() for original mode.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: Enhance and export print_key_type function
Qu Wenruo [Mon, 29 Aug 2016 08:09:00 +0000 (16:09 +0800)]
btrfs-progs: Enhance and export print_key_type function

Just the same thing done for print_objectid().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: Enhance and export print_objectid function
Qu Wenruo [Mon, 29 Aug 2016 08:08:59 +0000 (16:08 +0800)]
btrfs-progs: Enhance and export print_objectid function

This function is quite useful for a lot of error report.
Enhance it to support custom output other than stdout.
And export it for later btrfsck enhancement.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
7 years agoBtrfs progs v4.7.1
David Sterba [Thu, 25 Aug 2016 17:33:48 +0000 (19:33 +0200)]
Btrfs progs v4.7.1

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: update CHANGES for 4.7.1
David Sterba [Thu, 28 Jul 2016 12:18:59 +0000 (14:18 +0200)]
btrfs-progs: update CHANGES for 4.7.1

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: add rest of stack operations for btrfs_dir_item
David Sterba [Thu, 25 Aug 2016 17:02:18 +0000 (19:02 +0200)]
btrfs-progs: add rest of stack operations for btrfs_dir_item

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: switch to common error helpers in do_rollback
David Sterba [Tue, 23 Aug 2016 17:58:07 +0000 (19:58 +0200)]
btrfs-progs: convert: switch to common error helpers in do_rollback

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: reword message when conversion fails
David Sterba [Tue, 23 Aug 2016 17:43:20 +0000 (19:43 +0200)]
btrfs-progs: convert: reword message when conversion fails

The filesystem will not be finalized, no difference if it's before or
after the chunk mapping fixups.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: switch to message helpers in do_convert
David Sterba [Tue, 23 Aug 2016 17:40:32 +0000 (19:40 +0200)]
btrfs-progs: convert: switch to message helpers in do_convert

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: remove redundant check
David Sterba [Tue, 23 Aug 2016 17:33:05 +0000 (19:33 +0200)]
btrfs-progs: convert: remove redundant check

The check for sectorsize is properly done in do_convert, remove the
BUG_ON.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: improve error hanling of init_btrfs
David Sterba [Tue, 23 Aug 2016 17:24:48 +0000 (19:24 +0200)]
btrfs-progs: convert: improve error hanling of init_btrfs

Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: improve error hanling of create_subvol
David Sterba [Tue, 23 Aug 2016 17:24:48 +0000 (19:24 +0200)]
btrfs-progs: convert: improve error hanling of create_subvol

Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: improve error hanling of link_subvol
David Sterba [Tue, 23 Aug 2016 17:24:48 +0000 (19:24 +0200)]
btrfs-progs: convert: improve error hanling of link_subvol

Replace BUG_ONs and verbosely report the errors.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: make ext2 compilation honor the configure options
David Sterba [Tue, 23 Aug 2016 16:05:56 +0000 (18:05 +0200)]
btrfs-progs: convert: make ext2 compilation honor the configure options

Now ext2 conversion will be built in iff it's selected by --with-convert
option. Default is yes.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move prepare_system_chunk_sb
David Sterba [Tue, 23 Aug 2016 15:50:51 +0000 (17:50 +0200)]
btrfs-progs: convert: move prepare_system_chunk_sb

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move migrate_super_block
David Sterba [Tue, 23 Aug 2016 15:50:16 +0000 (17:50 +0200)]
btrfs-progs: convert: move migrate_super_block

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move init_btrfs
David Sterba [Tue, 23 Aug 2016 15:49:54 +0000 (17:49 +0200)]
btrfs-progs: convert: move init_btrfs

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move make_convert_data_block_groups
David Sterba [Tue, 23 Aug 2016 15:49:08 +0000 (17:49 +0200)]
btrfs-progs: convert: move make_convert_data_block_groups

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move create_subvol
David Sterba [Tue, 23 Aug 2016 15:48:44 +0000 (17:48 +0200)]
btrfs-progs: convert: move create_subvol

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move link_subvol
David Sterba [Tue, 23 Aug 2016 15:48:29 +0000 (17:48 +0200)]
btrfs-progs: convert: move link_subvol

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move create_image
David Sterba [Tue, 23 Aug 2016 15:48:07 +0000 (17:48 +0200)]
btrfs-progs: convert: move create_image

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move convert_read_used_space
David Sterba [Tue, 23 Aug 2016 15:46:25 +0000 (17:46 +0200)]
btrfs-progs: convert: move convert_read_used_space

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move calculate_available_space
David Sterba [Tue, 23 Aug 2016 15:45:54 +0000 (17:45 +0200)]
btrfs-progs: convert: move calculate_available_space

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move wipe_reserved_ranges
David Sterba [Tue, 23 Aug 2016 15:45:15 +0000 (17:45 +0200)]
btrfs-progs: convert: move wipe_reserved_ranges

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move wipe_one_reserved_range
David Sterba [Tue, 23 Aug 2016 15:44:36 +0000 (17:44 +0200)]
btrfs-progs: convert: move wipe_one_reserved_range

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move _expand_extent_cache
David Sterba [Tue, 23 Aug 2016 15:44:03 +0000 (17:44 +0200)]
btrfs-progs: convert: move _expand_extent_cache

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move migrate_reserved_ranges
David Sterba [Tue, 23 Aug 2016 15:43:21 +0000 (17:43 +0200)]
btrfs-progs: convert: move migrate_reserved_ranges

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move migrate_one_reserved_range
David Sterba [Tue, 23 Aug 2016 15:42:23 +0000 (17:42 +0200)]
btrfs-progs: convert: move migrate_one_reserved_range

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move create_image_file_range
David Sterba [Tue, 23 Aug 2016 15:42:01 +0000 (17:42 +0200)]
btrfs-progs: convert: move create_image_file_range

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move block_iterate_proc
David Sterba [Tue, 23 Aug 2016 15:41:20 +0000 (17:41 +0200)]
btrfs-progs: convert: move block_iterate_proc

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move record_file_blocks
David Sterba [Tue, 23 Aug 2016 15:41:00 +0000 (17:41 +0200)]
btrfs-progs: convert: move record_file_blocks

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move init_blk_iterate_data
David Sterba [Tue, 23 Aug 2016 15:40:08 +0000 (17:40 +0200)]
btrfs-progs: convert: move init_blk_iterate_data

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move csum_disk_extent
David Sterba [Tue, 23 Aug 2016 15:38:55 +0000 (17:38 +0200)]
btrfs-progs: convert: move csum_disk_extent

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move read_disk_extent
David Sterba [Tue, 23 Aug 2016 15:36:13 +0000 (17:36 +0200)]
btrfs-progs: convert: move read_disk_extent

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move convert_insert_dirent
David Sterba [Tue, 23 Aug 2016 15:35:05 +0000 (17:35 +0200)]
btrfs-progs: convert: move convert_insert_dirent

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: move intersect_with_sb
David Sterba [Tue, 23 Aug 2016 15:34:43 +0000 (17:34 +0200)]
btrfs-progs: convert: move intersect_with_sb

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: convert: prefix all ext2-related helpers
David Sterba [Tue, 23 Aug 2016 15:31:34 +0000 (17:31 +0200)]
btrfs-progs: convert: prefix all ext2-related helpers

Add ext2_ prefix to all functions that seem to be ext2-specific.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: build: extend convert options
David Sterba [Tue, 23 Aug 2016 15:21:30 +0000 (17:21 +0200)]
btrfs-progs: build: extend convert options

Add --with-convert[=VALUE] option to configure. Accepts ext2, auto, yes,
or no, but will be extended to more in the future. The configure-time
defines are not used in the code, ext2 is built-in unconditionally.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: build: add per-tool cflags variable
David Sterba [Tue, 23 Aug 2016 16:04:37 +0000 (18:04 +0200)]
btrfs-progs: build: add per-tool cflags variable

The standalone tools are built from pattern rules, add support for
per-tool cflaags, like btrfs_something_clfags.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: cleanup, open_ctree to fs_info and use directly
David Sterba [Tue, 23 Aug 2016 14:18:33 +0000 (16:18 +0200)]
btrfs-progs: mkfs: cleanup, open_ctree to fs_info and use directly

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: kill print_version
David Sterba [Tue, 23 Aug 2016 14:12:36 +0000 (16:12 +0200)]
btrfs-progs: mkfs: kill print_version

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: clean up make_image
David Sterba [Mon, 22 Aug 2016 17:14:20 +0000 (19:14 +0200)]
btrfs-progs: mkfs: clean up make_image

The exact errors are printed, the removed message does not seem to be
necessary. Return proper errors.

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: help and usage now to to stdout
David Sterba [Mon, 22 Aug 2016 16:18:54 +0000 (18:18 +0200)]
btrfs-progs: mkfs: help and usage now to to stdout

Signed-off-by: David Sterba <dsterba@suse.com>
7 years agobtrfs-progs: mkfs: handle and report transaction commit failures
David Sterba [Mon, 22 Aug 2016 16:18:14 +0000 (18:18 +0200)]
btrfs-progs: mkfs: handle and report transaction commit failures

Signed-off-by: David Sterba <dsterba@suse.com>