platform/upstream/btrfs-progs.git
8 years agobtrfs-progs: update docs for inspect-internal dump-super
Alexander Fougner [Wed, 24 Feb 2016 10:52:34 +0000 (11:52 +0100)]
btrfs-progs: update docs for inspect-internal dump-super

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
[ minor formatting updates ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: introduce inspect-internal dump-super
Alexander Fougner [Wed, 24 Feb 2016 10:52:33 +0000 (11:52 +0100)]
btrfs-progs: introduce inspect-internal dump-super

The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: update docs and completion for inspect-internal dump-tree
Alexander Fougner [Mon, 22 Feb 2016 14:49:50 +0000 (15:49 +0100)]
btrfs-progs: update docs and completion for inspect-internal dump-tree

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: copy functionality of btrfs-debug-tree to inspect-internal subcommand
Alexander Fougner [Mon, 22 Feb 2016 14:49:49 +0000 (15:49 +0100)]
btrfs-progs: copy functionality of btrfs-debug-tree to inspect-internal subcommand

The long-term plan is to merge the features of standalone tools
into the btrfs binary, reducing the number of shipped binaries.

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agoBtrfs progs v4.4.1
David Sterba [Fri, 26 Feb 2016 17:22:09 +0000 (18:22 +0100)]
Btrfs progs v4.4.1

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Import interval tree implemenation from Linux v4.0-rc7.
Mark Fasheh [Wed, 20 Jan 2016 21:49:25 +0000 (13:49 -0800)]
btrfs-progs: Import interval tree implemenation from Linux v4.0-rc7.

While I had the chance, I compared the rbtre code in btrfs-progs to that of
the latest kernel.  No new bug fixes need importing, however rbtree.h and
rbtree_augmented.h get documentation updates

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: misc-test: Add regression test for find-root gives empty result
Qu Wenruo [Mon, 22 Feb 2016 06:59:57 +0000 (14:59 +0800)]
btrfs-progs: misc-test: Add regression test for find-root gives empty result

Add regression test for btrfs-find-root gives empty result even the fs
is OK.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ enhanced test ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: find-root: Allow btrfs-find-root to search chunk root even chunk root...
Qu Wenruo [Mon, 22 Feb 2016 06:59:56 +0000 (14:59 +0800)]
btrfs-progs: find-root: Allow btrfs-find-root to search chunk root even chunk root is corrupted

Since now open_ctree_fs_info() can even return a valid fs_info with only
system chunk mapping from super block, use this ability to do chunk root
search for heavily damanged fs.

As an fast alternative for time consuming and buggy chunk-recovery.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Add support for tree block operations on fs_info without roots
Qu Wenruo [Mon, 22 Feb 2016 06:59:55 +0000 (14:59 +0800)]
btrfs-progs: Add support for tree block operations on fs_info without roots

Since open_ctree_fs_info() now may return a fs_info even without any
roots, modify functions like read_tree_block() to operate with such
fs_info.

This provides the basis for btrfs-find-root to operate on chunk tree
with corrupted fs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ coding style adjustments, unified declarations ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Allow open_ctree to return fs_info even chunk tree is corrupted
Qu Wenruo [Mon, 22 Feb 2016 06:59:54 +0000 (14:59 +0800)]
btrfs-progs: Allow open_ctree to return fs_info even chunk tree is corrupted

Current open_ctree_fs_info() won't return anything if chunk tree root is
corrupted.
This makes some function, like btrfs-find-root, unable to find any older
chunk tree root, even it is possible to use system_chunk_array in super
block.

And at least two users in mail list has reported such heavily chunk
corruption.
Although we have 'btrfs rescue chunk-recovery' but it's too time
consuming and sometimes not able to cope with a specific filesystem
corruption.

This patch adds a new open ctree flag,
OPEN_CTREE_IGNORE_CHUNK_TREE_ERROR, allowing fs_info to be returned from
open_ctree_fs_info() even there is no valid tree root in it.

Also adds a new close_ctree() variant, close_ctree_fs_info() to handle
possible fs_info without any root.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ adjusted error messages ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: volume: Fix a bug causing btrfs-find-root to skip first chunk
Qu Wenruo [Mon, 22 Feb 2016 06:59:53 +0000 (14:59 +0800)]
btrfs-progs: volume: Fix a bug causing btrfs-find-root to skip first chunk

There is a small bug from 2011, where btrfs_next_bg (formally
btrfs_next_metadata) function will always skip the first chunk.

That's OK for that time, as there is always 3 empty temporary chunks.
But now, we may ended up with only one metadata or system chunk, with
empty chunk auto-remove from kernel or new mkfs.btrfs.

So fix it by checking the initial value so btrfs_next_bg() will return
the first chunk if its *logical parameter is 0.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix symlink creation multiple times
Hongxu Jia [Fri, 19 Feb 2016 02:14:34 +0000 (21:14 -0500)]
btrfs-progs: fix symlink creation multiple times

The rule to create symlink in Makefile caused parallel issue:
$ make -j 40 DESTDIR=/image install BUILD_VERBOSE=1
...
  1     [LN]     libbtrfs.so.0
  2     [LN]     libbtrfs.so
  3 ln -s -f libbtrfs.so.0.1 libbtrfs.so.0
  4 ln -s -f libbtrfs.so.0.1 libbtrfs.so.0
  5 ln -s -f libbtrfs.so.0.1 libbtrfs.so
  6 ln -s -f libbtrfs.so.0.1 libbtrfs.so
...

It failed occasionally:
...
|symlinkat: couldn't stat 'git/libbtrfs.so' even though symlink
creation succeeded (No such file or directory).
|ln: failed to create symbolic link 'libbtrfs.so': No such file or directory
...

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: use common variables and helpers
David Sterba [Thu, 11 Feb 2016 18:26:26 +0000 (19:26 +0100)]
btrfs-progs: tests: use common variables and helpers

Use TEST_DEV and the associated helpers to manage the tested image.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: store checksums in /tmp
David Sterba [Thu, 11 Feb 2016 18:21:24 +0000 (19:21 +0100)]
btrfs-progs: tests: store checksums in /tmp

We don't want to store the checksum on filesystem that we're converting.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: do checksum verification with convert-tests
Lakshmipathi.G [Mon, 25 Jan 2016 16:08:33 +0000 (21:38 +0530)]
btrfs-progs: tests: do checksum verification with convert-tests

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: write down the meaning of BTRFS_ARG_BLKDEV
Satoru Takeuchi [Fri, 5 Feb 2016 08:07:34 +0000 (17:07 +0900)]
btrfs-progs: write down the meaning of BTRFS_ARG_BLKDEV

Although BTRFS_ARG_BLKDEV can be returned from check_arg_type(),
it's not explained the meaning.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: describe btrfs-send requires read-only subvolume
Satoru Takeuchi [Thu, 4 Feb 2016 05:02:14 +0000 (14:02 +0900)]
btrfs-progs: describe btrfs-send requires read-only subvolume

Both man btrfs-send(8) and usage message don't describe
btrfs-send needs read-only snapshot as its argument.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Fix self-reference of man btrfs-subvolume
Satoru Takeuchi [Thu, 4 Feb 2016 01:51:23 +0000 (10:51 +0900)]
btrfs-progs: Fix self-reference of man btrfs-subvolume

btrfs-subvolume(8) is mentioned at "SEE ALSO" section of itself.

Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: doc: fix size suffix in mkfs.btrfs
Tsutomu Itoh [Thu, 28 Jan 2016 08:00:33 +0000 (17:00 +0900)]
btrfs-progs: doc: fix size suffix in mkfs.btrfs

There is no petabyte in the explanation of the suffix of
the size parameter. So, it's added.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: doc: fix typo of some documents
Tsutomu Itoh [Thu, 28 Jan 2016 08:00:24 +0000 (17:00 +0900)]
btrfs-progs: doc: fix typo of some documents

Some typos are corrected.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix compat_ro mask for free space tree
David Sterba [Mon, 25 Jan 2016 14:35:30 +0000 (15:35 +0100)]
btrfs-progs: fix compat_ro mask for free space tree

The BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE bit is supposed to be in the
COMPAT_RO_SUPP bitmask.

Reported-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Makefile.in: Simplify/correct install-static
Mike Gilbert [Thu, 21 Jan 2016 15:59:32 +0000 (10:59 -0500)]
btrfs-progs: Makefile.in: Simplify/correct install-static

install -D does not create the last component, so this failed if
$(DESTDIR)$(bindir) did not already exist.

There's no need for a loop here since install accepts multiple source
arguments.

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agoBtrfs progs v4.4
David Sterba [Mon, 18 Jan 2016 12:56:35 +0000 (13:56 +0100)]
Btrfs progs v4.4

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs: update balance manual page
David Sterba [Fri, 15 Jan 2016 14:17:46 +0000 (15:17 +0100)]
btrfs-progs: docs: update balance manual page

Make the new balance filters' syntax more explicit. Other rewording and
reformatting.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: debug-tree: tweak tree node checks
David Sterba [Fri, 15 Jan 2016 13:00:41 +0000 (14:00 +0100)]
btrfs-progs: debug-tree: tweak tree node checks

The tree root and chunk root base pointers are verified in open_ctree so
we don't get NULL here. We still check the node pointers to get better
error message.

Resolves-coverity-id: 1348450
Resolves-coverity-id: 1348451
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix static build
Noah Massey [Fri, 15 Jan 2016 12:31:01 +0000 (13:31 +0100)]
btrfs-progs: fix static build

Change in "btrfs-progs: introduce helper for parsing args without
options" added a dependency on help.o that was duplicated for the static
build.

Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Use AC_CHECK_TOOL to find AR
Mike Gilbert [Thu, 14 Jan 2016 10:18:03 +0000 (05:18 -0500)]
btrfs-progs: Use AC_CHECK_TOOL to find AR

AC_CHECK_TOOL takes the --host option into account for cross-compiling.

Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agoBtrfs progs v4.4-rc1
David Sterba [Thu, 14 Jan 2016 10:16:27 +0000 (11:16 +0100)]
Btrfs progs v4.4-rc1

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol show: use clean_args_no_options instead of opencoding
David Sterba [Thu, 14 Jan 2016 09:37:02 +0000 (10:37 +0100)]
btrfs-progs: subvol show: use clean_args_no_options instead of opencoding

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: introduce helper for parsing args without options
David Sterba [Thu, 14 Jan 2016 09:30:35 +0000 (10:30 +0100)]
btrfs-progs: introduce helper for parsing args without options

All commands should support the "--" option separator. This is
transparently handled by getopt, but we don't use that everywhere.
Introduce a helper for commands that take no options (just the path).
The object file dependencies need to be adjusted a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: move prefixcmp to utils
David Sterba [Thu, 14 Jan 2016 09:29:13 +0000 (10:29 +0100)]
btrfs-progs: move prefixcmp to utils

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: receive: don't leak open find handle
David Sterba [Thu, 14 Jan 2016 08:40:24 +0000 (09:40 +0100)]
btrfs-progs: receive: don't leak open find handle

Resolves-coverity-id: 1348121
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: also check filesystem type in test_issubvolume
David Sterba [Wed, 13 Jan 2016 17:44:59 +0000 (18:44 +0100)]
btrfs-progs: also check filesystem type in test_issubvolume

A subvolume is a directory with inode number 256 on a btrfs filesytem.
Add the missing check to test_issubvolume for completeness, otherwise we
always do that in btrfs_open_dir.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: more verbose errors from test_issubvolume
David Sterba [Wed, 13 Jan 2016 17:14:32 +0000 (18:14 +0100)]
btrfs-progs: more verbose errors from test_issubvolume

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: let test_issubvolume return the exact error
David Sterba [Wed, 13 Jan 2016 16:45:39 +0000 (17:45 +0100)]
btrfs-progs: let test_issubvolume return the exact error

Return any error from stat, minor cleanups.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use symbolic name for subvolume inode number in test_issubvolume
David Sterba [Wed, 13 Jan 2016 17:08:34 +0000 (18:08 +0100)]
btrfs-progs: use symbolic name for subvolume inode number in test_issubvolume

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: handle errors from test_isdir
David Sterba [Wed, 13 Jan 2016 17:04:22 +0000 (18:04 +0100)]
btrfs-progs: handle errors from test_isdir

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: let test_isdir return the exact error
David Sterba [Wed, 13 Jan 2016 16:45:39 +0000 (17:45 +0100)]
btrfs-progs: let test_isdir return the exact error

Return any error from stat, normalize the return value in case the path
is a directory.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: debug-tree: teach -t option about the chunk and root trees
David Sterba [Wed, 13 Jan 2016 15:05:56 +0000 (16:05 +0100)]
btrfs-progs: debug-tree: teach -t option about the chunk and root trees

A user on IRC wanted to dump the chunk tree using the -t option. As the
-t option enumerates only trees pointed by the tree_root, the chunk tree
is skipped. Similar for th tree of tree roots.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol show: handle options by getopt
David Sterba [Wed, 13 Jan 2016 14:38:28 +0000 (15:38 +0100)]
btrfs-progs: subvol show: handle options by getopt

The subvolume show command does not take any optios but at least it
should honor "--", as reported.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110181
Reported-by: <moviuro+kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fi usage: support mixed blockgroups
David Sterba [Wed, 13 Jan 2016 11:59:42 +0000 (12:59 +0100)]
btrfs-progs: fi usage: support mixed blockgroups

Properly account the duplicated block groups and global reserve.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110111
Reported-by: Chris Murphy <bugzilla@colorremedies.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs: enhance btrfs-filesystem manual page
David Sterba [Tue, 12 Jan 2016 17:42:49 +0000 (18:42 +0100)]
btrfs-progs: docs: enhance btrfs-filesystem manual page

Wording, formatting, explanations, examples.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: add missing prerequisites
David Sterba [Tue, 12 Jan 2016 14:16:11 +0000 (15:16 +0100)]
btrfs-progs: tests: add missing prerequisites

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-porgs: fi usage: rename variable to avoid shadowing
David Sterba [Tue, 12 Jan 2016 13:34:41 +0000 (14:34 +0100)]
btrfs-porgs: fi usage: rename variable to avoid shadowing

Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-porgs: check: rename variable to avoid shadowing
David Sterba [Tue, 12 Jan 2016 13:34:41 +0000 (14:34 +0100)]
btrfs-porgs: check: rename variable to avoid shadowing

Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-porgs: qgroup: rename variable to avoid shadowing
David Sterba [Tue, 12 Jan 2016 13:34:41 +0000 (14:34 +0100)]
btrfs-porgs: qgroup: rename variable to avoid shadowing

Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: add function attributes for the printf-like
David Sterba [Tue, 12 Jan 2016 13:25:23 +0000 (14:25 +0100)]
btrfs-progs: add function attributes for the printf-like

Reported by gcc -Wsuggest-attribute=format .

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: build: fix builds with extra warnings, W=1
David Sterba [Tue, 12 Jan 2016 13:18:24 +0000 (14:18 +0100)]
btrfs-progs: build: fix builds with extra warnings, W=1

Wrong variable name used in the main makefile.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check for negative return value from ioctl
David Sterba [Tue, 12 Jan 2016 12:35:50 +0000 (13:35 +0100)]
btrfs-progs: check for negative return value from ioctl

Handle only negative values returned by ioctl syscalls, with exception
of the device remove. It returns positive values that are handled later.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove unnecessary errno temp variables
David Sterba [Tue, 12 Jan 2016 10:20:18 +0000 (11:20 +0100)]
btrfs-progs: remove unnecessary errno temp variables

We can read errno directly if it's not clobbered by any intermediate
calls.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: free-space-tree: minor message adjustments
David Sterba [Mon, 11 Jan 2016 15:44:44 +0000 (16:44 +0100)]
btrfs-progs: free-space-tree: minor message adjustments

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfsprogs: corrupt-blocks: include limits.h to define PATH_MAX
Khem Raj [Sun, 10 Jan 2016 03:04:23 +0000 (19:04 -0800)]
btrfsprogs: corrupt-blocks: include limits.h to define PATH_MAX

limits.h is needed for PATH_MAX definition

Fixes
| btrfs-corrupt-block.c: In function 'corrupt_dir_item':
| btrfs-corrupt-block.c:478:12: error: 'PATH_MAX' undeclared (first use in this function)
|   char name[PATH_MAX];

Signed-off-by: Khem Raj <raj.khem@gmail.com>
[ minor changelog edits ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs: document new mount option fragment
David Sterba [Mon, 11 Jan 2016 15:28:14 +0000 (16:28 +0100)]
btrfs-progs: docs: document new mount option fragment

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs: sort mount options alphabetically
David Sterba [Mon, 11 Jan 2016 15:12:28 +0000 (16:12 +0100)]
btrfs-progs: docs: sort mount options alphabetically

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check the free space tree in btrfsck
Omar Sandoval [Wed, 30 Sep 2015 03:51:45 +0000 (20:51 -0700)]
btrfs-progs: check the free space tree in btrfsck

This reuses the existing code for checking the free space cache, we just
need to load the free space tree. While we do that, we check a couple of
invariants on the free space tree itself. This requires pulling in some
code from the kernel to exclude the super stripes.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: add basic awareness of the free space tree
Omar Sandoval [Wed, 30 Sep 2015 03:51:44 +0000 (20:51 -0700)]
btrfs-progs: add basic awareness of the free space tree

To start, let's tell btrfs-progs to read the free space root and how to
print the on-disk format of the free space tree. However, we're not
adding the FREE_SPACE_TREE read-only compat bit to the set of supported
bits because progs doesn't know how to keep the free space tree
consistent.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs: rename btrfs-mount to btrfs-man5
David Sterba [Mon, 11 Jan 2016 14:32:38 +0000 (15:32 +0100)]
btrfs-progs: docs: rename btrfs-mount to btrfs-man5

The page does will not contain only mount options but other stuff.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs, btrfs-mount: enhance file attributes section
David Sterba [Mon, 11 Jan 2016 14:28:08 +0000 (15:28 +0100)]
btrfs-progs: docs, btrfs-mount: enhance file attributes section

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cleanup, move usage help strings closer to the command callbacks
David Sterba [Mon, 11 Jan 2016 13:31:20 +0000 (14:31 +0100)]
btrfs-progs: cleanup, move usage help strings closer to the command callbacks

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd property: use correct usage strings
David Sterba [Mon, 11 Jan 2016 14:35:07 +0000 (15:35 +0100)]
btrfs-progs: cmd property: use correct usage strings

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd fi usage: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd fi usage: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd filesystem: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd filesystem: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd replace: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd replace: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd subvolume: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd subvolume: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd send: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd send: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd receive: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd receive: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd qgroup: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd qgroup: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd property: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd property: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd balance: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd balance: switch to common error message wrapper

Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd quota: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd quota: switch to common error message wrapper

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: cmd rescue: switch to common error message wrapper
David Sterba [Mon, 11 Jan 2016 10:01:47 +0000 (11:01 +0100)]
btrfs-progs: cmd rescue: switch to common error message wrapper

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: catch memory allocation failure in btrfs_split_item
David Sterba [Wed, 6 Jan 2016 14:52:11 +0000 (15:52 +0100)]
btrfs-progs: catch memory allocation failure in btrfs_split_item

Do the dumb BUG_ON now, the function needs more changes to handle all
errors.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: handler memory allocation failure in add_extent_rec
David Sterba [Wed, 6 Jan 2016 14:52:11 +0000 (15:52 +0100)]
btrfs-progs: handler memory allocation failure in add_extent_rec

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: catch memory allocation failure from alloc_data_backref
David Sterba [Wed, 6 Jan 2016 14:52:11 +0000 (15:52 +0100)]
btrfs-progs: catch memory allocation failure from alloc_data_backref

Do the dumb BUG_ON now, the function needs more changes to handle all
errors.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: catch memory allocation failure from alloc_tree_backref
David Sterba [Wed, 6 Jan 2016 14:52:11 +0000 (15:52 +0100)]
btrfs-progs: catch memory allocation failure from alloc_tree_backref

Do the dumb BUG_ON now, the function needs more changes to handle all
errors.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: catch memory allocation failure in splice_shared_node
David Sterba [Wed, 6 Jan 2016 14:52:11 +0000 (15:52 +0100)]
btrfs-progs: catch memory allocation failure in splice_shared_node

Do the dumb BUG_ON now, the function needs more changes to handle all
errors.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: handle errors in get_inode_backref and fail in the caller
David Sterba [Wed, 6 Jan 2016 14:08:46 +0000 (15:08 +0100)]
btrfs-progs: handle errors in get_inode_backref and fail in the caller

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: handle errors in get_root_backref and fail in the caller
David Sterba [Wed, 6 Jan 2016 14:37:06 +0000 (15:37 +0100)]
btrfs-progs: handle errors in get_root_backref and fail in the caller

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: return errors from get_root_rec, fail in callers
David Sterba [Wed, 6 Jan 2016 14:08:46 +0000 (15:08 +0100)]
btrfs-progs: return errors from get_root_rec, fail in callers

get_root_rec return value is enahanced, callers will just BUG_ON now
and will be fixed one by one.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: handle errors in add_shared_node and fail in the caller
David Sterba [Wed, 6 Jan 2016 14:37:06 +0000 (15:37 +0100)]
btrfs-progs: handle errors in add_shared_node and fail in the caller

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: return errors from clone_inode_rec, fail in callers
David Sterba [Wed, 6 Jan 2016 14:08:46 +0000 (15:08 +0100)]
btrfs-progs: return errors from clone_inode_rec, fail in callers

clone_inode_rec return value is enahanced, callers will just BUG_ON now
and will be fixed one by one.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: return errors from get_inode_rec, fail in callers
David Sterba [Wed, 6 Jan 2016 14:08:46 +0000 (15:08 +0100)]
btrfs-progs: return errors from get_inode_rec, fail in callers

get_inode_rec return value is enahanced, callers will just BUG_ON now
and will be fixed one by one.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs, enhance the mount option manual page
David Sterba [Fri, 8 Jan 2016 18:33:02 +0000 (19:33 +0100)]
btrfs-progs: docs, enhance the mount option manual page

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs, btrfs-mount: enhance fatal_erros
David Sterba [Fri, 8 Jan 2016 13:46:44 +0000 (14:46 +0100)]
btrfs-progs: docs, btrfs-mount: enhance fatal_erros

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs, btrfs-mount: put NOTE tag to new paragraph
David Sterba [Fri, 8 Jan 2016 13:34:48 +0000 (14:34 +0100)]
btrfs-progs: docs, btrfs-mount: put NOTE tag to new paragraph

Otherwise it's not rendered properly.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: docs, btrfs-mount: unindent descriptions
David Sterba [Fri, 8 Jan 2016 13:31:05 +0000 (14:31 +0100)]
btrfs-progs: docs, btrfs-mount: unindent descriptions

Asciidoc ignores special keywords like WARNING or NOTE if they're not at
the beginning of the line and they're not renedered very visibly in the
end.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: document snapshot unaware defrag
Christoph Anton Mitterer [Sun, 27 Dec 2015 02:41:28 +0000 (03:41 +0100)]
btrfs-progs: document snapshot unaware defrag

In btrfs-filesystem(8), improved the documentation of snapshot unaware
defragmentation and included the exact kernel version numbers being affected as
well as the possible effects.
No longer use the word "unlink" which is easily understood as "deleting a file".
Moved the warning more to the beginning of "defragment" subcommand's
documentation where it's more visible to readers.

Added the same warning to the "autodefrag" option of btrfs-mount(5).

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
8 years agobtrfs-progs: docs, update btrfs(8) manual page
David Sterba [Thu, 7 Jan 2016 15:28:05 +0000 (16:28 +0100)]
btrfs-progs: docs, update btrfs(8) manual page

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agoBtrfs-progs: fix typo in parse_range
Liu Bo [Wed, 6 Jan 2016 21:08:53 +0000 (13:08 -0800)]
Btrfs-progs: fix typo in parse_range

s/*end/*start.

This makes 'btrfs balance start -dvrange=xxx..yyy' really work.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use on-stack buffer in add_symbolic_link
David Sterba [Wed, 6 Jan 2016 13:22:34 +0000 (14:22 +0100)]
btrfs-progs: use on-stack buffer in add_symbolic_link

Also get rid of the unhandled memory allocation.

Resolves-coverity-id: 1338298
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs: only free root_path if it was allocated from the heap
Neil Horman [Thu, 3 Dec 2015 18:45:44 +0000 (13:45 -0500)]
btrfs: only free root_path if it was allocated from the heap

Noticed this while doing some snapshots in a chroot environment

btrfs receive can set root_path to either realmnt, which is passed in from the
command line, or to a heap allocated via find_mount_root  in do_receive.  We
should only free the later, not the former, as the former results in an invalid
pointer warning from glibc during free.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix using on-disk structure to store in memory data
Byongho Lee [Mon, 4 Jan 2016 01:01:34 +0000 (10:01 +0900)]
btrfs-progs: fix using on-disk structure to store in memory data

In 'qgroup_count' structure 'diskinfo' and 'info' are used to store only
in memory data but its types are for on-disk structure as a result sparse
warns it (different base types).  So fix it by adding new structure
'qgroup_info' to store in memory data and replace on-disk structure
'btrfs_qgroup_info_item' by 'qgroup_info'.  In addition in alloc_cnt()
'generation' is set but not used after that so remove the relevant code.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix endian bug in update_super()
Byongho Lee [Mon, 4 Jan 2016 01:01:33 +0000 (10:01 +0900)]
btrfs-progs: fix endian bug in update_super()

In update_super() 'chunk->stripe.devid' and 'super->dev_item.devid' both
are little endian. So we should not use endian helper
btrfs_set_stack_stripe_devid().

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fix endian bugs in chunk rebuilding
Byongho Lee [Mon, 4 Jan 2016 01:01:32 +0000 (10:01 +0900)]
btrfs-progs: fix endian bugs in chunk rebuilding

This is a same patch as Zach Brown's but we lost so I resend it based on
current code.
 - 'commit 2cd95f945a61 ("fix endian bugs in chunk rebuilding")'

Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: make private symbols to static
Byongho Lee [Mon, 4 Jan 2016 01:01:31 +0000 (10:01 +0900)]
btrfs-progs: make private symbols to static

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use NULL instead of 0
Byongho Lee [Mon, 4 Jan 2016 01:01:30 +0000 (10:01 +0900)]
btrfs-progs: use NULL instead of 0

Fix the code assigning 0 to pointer instead of NULL.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: get sparse checking working
Byongho Lee [Mon, 4 Jan 2016 01:01:29 +0000 (10:01 +0900)]
btrfs-progs: get sparse checking working

When I run sparse checking it gives the following error:

 $ make C=1 V=1
 gcc -MM -MG -MF cmds-fi-usage.o.d -MT cmds-fi-usage.o -MT \
 cmds-fi-usage.static.o -MT cmds-fi-usage.o.d -g -O1 -Wall \
 -D_FORTIFY_SOURCE=2 -include config.h -DBTRFS_FLAT_INCLUDES \
 -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC   cmds-fi-usage.c
    [SP]     ctree.c
 sparse -g -O1 -Wall -D_FORTIFY_SOURCE=2 -include config.h \
 -DBTRFS_FLAT_INCLUDES -D_XOPEN_SOURCE=700 -fno-strict-aliasing -fPIC \
 -include  -D__CHECKER__ -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized \
 -Wshadow -Wundef -U_FORTIFY_SOURCE ctree.c
 builtin:1:15: error: unable to open '-D__CHECKER__'
 Makefile:177: recipe for target 'ctree.o' failed
 make: *** [ctree.o] Error 1

It means '$(check_defs)' is passed to sparse as NULL and looks
'$(check_defs)'should be assigned before assigning '$(CHECKER_FLAGS)'.
BTW, I'm not familiar with make tool so there could be some my
misunderstanding and better solution.

Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Enhance chunk validation check
Qu Wenruo [Tue, 15 Dec 2015 02:04:01 +0000 (10:04 +0800)]
btrfs-progs: Enhance chunk validation check

Enhance chunk validation:
1) Num_stripes
   We already have such check but it's only in super block sys chunk
   array.
   Now check all on-disk chunks.

2) Chunk logical
   It should be aligned to sector size.
   This behavior should be *DOUBLE CHECKED* for 64K sector size like
   PPC64 or AArch64.
   Maybe we can found some hidden bugs.

3) Chunk length
   Same as chunk logical, should be aligned to sector size.

4) Stripe length
   It should be power of 2.

5) Chunk type
   Any bit out of TYPE_MAS | PROFILE_MASK is invalid.

With all these much restrict rules, several fuzzed image reported in
mail list should no longer cause btrfsck error.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: ftw_add_entry_size: Round up file size to sectorsize
Chandan Rajendra [Tue, 15 Dec 2015 10:02:00 +0000 (15:32 +0530)]
btrfs-progs: ftw_add_entry_size: Round up file size to sectorsize

ftw_add_entry_size() assumes 4k as the block size of the underlying
filesystem and hence the file sizes computed is incorrect for non-4k
sectorsized filesystems. Fix this by rounding up file sizes to
sectorsize.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: balance: enhance the usage filter with range
David Sterba [Thu, 22 Oct 2015 08:26:10 +0000 (10:26 +0200)]
btrfs-progs: balance: enhance the usage filter with range

We can do more with the balance usage filter. Enhance it so we can
specify also the minimum usage of the block groups to process. The
'usage' filter now accepts a range (a..b, can be partial) and needs
kernel support.

The 'usage=value' filter is equivalent to 'limit=..value' but works on
older kernels as well.

The min/max values are 32bit, unlike the single-value limit which is
64bit.

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