platform/upstream/btrfs-progs.git
9 years agobtrfs-progs: update man page for btrfs-show-super
Gui Hecheng [Thu, 8 May 2014 03:03:58 +0000 (11:03 +0800)]
btrfs-progs: update man page for btrfs-show-super

Add '-f' option for btrfs-show-super manpage,
This option implies that sys chunk array and backup roots info
will show up.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs-progs: fsck: add an option to check data csums
Wang Shilong [Wed, 28 May 2014 11:22:40 +0000 (19:22 +0800)]
Btrfs-progs: fsck: add an option to check data csums

This patch adds an option '--check-data-csum' to verify data checksums.
fsck won't check data csums unless users specify this option explictly.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs-progs: fsck: fix wrong check for btrfs_read_fs_root()
Wang Shilong [Wed, 28 May 2014 11:20:41 +0000 (19:20 +0800)]
Btrfs-progs: fsck: fix wrong check for btrfs_read_fs_root()

When encountering a corrupted fs root node, fsck hit following message:

Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
read block failed check_tree_block
Checking filesystem on /dev/sda9
UUID: 0d295d80-bae2-45f2-a106-120dbfd0e173
checking extents
Segmentation fault (core dumped)

This is because in btrfs_setup_all_roots(), we check
btrfs_read_fs_root() return value by verifing whether it is
NULL pointer, this is wrong since btrfs_read_fs_root() return
PTR_ERR(ret), fix it.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix blindly goto failure for chunk-recover
Gui Hecheng [Wed, 28 May 2014 10:49:38 +0000 (18:49 +0800)]
btrfs-progs: fix blindly goto failure for chunk-recover

If the csum of one stripe is not able to judge the order of two
device extents, the stripe may happen to belong to the device extent
that is already kicked out as ordered.
Take this condition into consideration, don't report failure and
give more tries with the stripes following.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix uninitialized number count in chunk-recover
Gui Hecheng [Wed, 28 May 2014 10:49:37 +0000 (18:49 +0800)]
btrfs-progs: fix uninitialized number count in chunk-recover

When count the number of unordered device extents in chunk-recover,
the counter should be reinitialized to be used.
Also, introduce a new function for the counting job.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add quota group verify code
Mark Fasheh [Wed, 7 May 2014 20:07:17 +0000 (13:07 -0700)]
btrfs-progs: add quota group verify code

This patch adds functionality (in qgroup-verify.c) to compute bytecounts in
subvolume quota groups. The original groups are read in and stored in memory
so that after we compute our own bytecounts, we can compare them with those
on disk. A print function is provided to do this comparison and show the
results on the console.

A 'qgroup check' pass is added to btrfsck. If any subvolume quota groups
differ from what we compute, the differences for them are printed.  We also
provide an option '--qgroup-report' which will run only the quota check code
and print a report on all quota groups.  Other than making it possible to
verify that our qgroup changes work correctly, this mode can also be used in
xfstests for automated checking after qgroup tests.

This patch does not address the following:
- compressed counts are identical to non compressed, because kernel doesn't
  make the distinction yet.  Adding the code to verify compressed counts
  shouldn't be hard at all though once kernel can do this.
- It is only concerned with subvolume quota groups (like most of
  btrfs-progs).

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: import ulist
Mark Fasheh [Wed, 7 May 2014 20:07:16 +0000 (13:07 -0700)]
btrfs-progs: import ulist

qgroup-verify.c wants this for walking root refs.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: print qgroup excl as unsigned
Mark Fasheh [Wed, 7 May 2014 20:07:15 +0000 (13:07 -0700)]
btrfs-progs: print qgroup excl as unsigned

It's unsigned in the structure definition.

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs-progs: receive, allow to continue after errors happen
Filipe David Borba Manana [Fri, 23 May 2014 19:14:56 +0000 (20:14 +0100)]
Btrfs-progs: receive, allow to continue after errors happen

Due to either bugs in send (kernel) that generate a command against
a wrong path for example, or transient errors on the receiving side,
we stopped processing the send stream immediately and exited with
an error.

It's often desirable to continue processing the send stream even if an
error happens while processing a single command from the send stream.

This change just adds a --max-errors <N> parameter, whose default value
is 1 (preserving current behaviour), that allows to tolerate N errors
before stopping. A value of 0 means to never stop no matter how many
errors we get into while processing the send stream. Regardless of its
value, errors are always printed to stderr when they happen, just like
before this change.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-image: Fix a data race in build_chunk_tree.
Adam Buchbinder [Mon, 19 May 2014 05:40:42 +0000 (22:40 -0700)]
btrfs-image: Fix a data race in build_chunk_tree.

A mdrestore_struct was being written to without its mutex being held.
This race was found with ThreadSanitizer; the relevant part of the report
looks like this:

WARNING: ThreadSanitizer: data race (pid=18828)
  Write of size 8 at 0x7fffffc3d088 by main thread:
    #0 build_chunk_tree .../btrfs-progs/btrfs-image.c:2233
    #1 __restore_metadump .../btrfs-progs/btrfs-image.c:2294
    #2 restore_metadump .../btrfs-progs/btrfs-image.c:2345
    #3 main .../btrfs-progs/btrfs-image.c:2545

  Previous read of size 8 at 0x7fffffc3d088 by thread T1 (mutexes: write M0):
    #0 restore_worker .../btrfs-progs/btrfs-image.c:1636

  Location is stack of main thread.

  Mutex M0 created at:
    #0 pthread_mutex_init ??:0
    #1 mdrestore_init .../btrfs-progs/btrfs-image.c:1766
    #2 __restore_metadump .../btrfs-progs/btrfs-image.c:2286
    #3 restore_metadump .../btrfs-progs/btrfs-image.c:2345
    #4 main .../btrfs-progs/btrfs-image.c:2545

  Thread T1 (tid=18830, running) created by main thread at:
    #0 pthread_create ??:0
    #1 mdrestore_init .../btrfs-progs/btrfs-image.c:1784
    #2 __restore_metadump .../btrfs-progs/btrfs-image.c:2286
    #3 restore_metadump .../btrfs-progs/btrfs-image.c:2345
    #4 main .../btrfs-progs/btrfs-image.c:2545

Signed-off-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: allow UUID specification at mkfs time
Eric Sandeen [Wed, 14 May 2014 17:39:07 +0000 (12:39 -0500)]
btrfs-progs: mkfs: allow UUID specification at mkfs time

Allow the specification of the filesystem UUID at mkfs time.

Non-unique unique IDs are rejected.  This includes attempting
to re-mkfs with the same UUID; if you really want to do that,
you can mkfs with a new UUID, then re-mkfs with the one you
wanted.

(Implemented only for mkfs.btrfs, not btrfs-convert).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
[converted help to asciidoc]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix compiler warning
Christian Hesse [Tue, 3 Jun 2014 11:37:45 +0000 (13:37 +0200)]
btrfs-progs: fix compiler warning

gcc 4.9.0 gives a warning: format ‘%d’ expects argument of type ‘int’,
but argument 2 has type ‘u64’

Using %llu and casting to unsigned long long (same as bytenr) fixes this.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix btrfs-fragments build
Eric Sandeen [Fri, 30 May 2014 16:29:19 +0000 (11:29 -0500)]
btrfs-progs: fix btrfs-fragments build

When I made all the btrfs-foo.c targets generic, I somehow
managed to break the libs definition for btrfs-fragments by
dropping the "s" off the end.

Fix that, although apparently nobody is building this tool.  :)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add dev uuid output for print_dev_item().
Qu Wenruo [Fri, 30 May 2014 02:19:04 +0000 (10:19 +0800)]
btrfs-progs: Add dev uuid output for print_dev_item().

The original print_dev_item() only prints device id,total bytes and
bytes used.

When it comes to debug duplicated device id, dev uuid
is needed to distinguish different devices since device id is not
reliable.
(Although the current dev replace implement will reuse the dev uuid,
so not really helpful)

This patch adds dev uuid output for print_dev_item().

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: clarify manpage for btrfstune seeding option
Gui Hecheng [Wed, 21 May 2014 08:03:57 +0000 (16:03 +0800)]
btrfs-progs: clarify manpage for btrfstune seeding option

The btrfstune -S option accepts a positive value to enable seeding,
and a zero to disable seeding, negtive is not allowed.

Add "positive, zero, negative" sentences to btrfstune manpage.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: clarify mkfs.btrfs --alloc-start option
Eric Sandeen [Thu, 15 May 2014 17:14:40 +0000 (19:14 +0200)]
btrfs-progs: clarify mkfs.btrfs --alloc-start option

Fedora had a bug where a poor user thought that --alloc-start
meant that the filesystem would be created at that offset into
the device, rather than just starting allocations at that offset.
A subtle difference, but worth clarifying, because the manpage
is misleading on this point.

The original commit log for this option says:

    Add mkfs.btrfs -A offset to control allocation start on devices

    This is a utility option for the resizer, it makes sure to allocate
    at offset bytes in the disk or higher.  It ensures the resizer will have
    something to move when testing it.

so allude to that intended use in the manpage.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
[converted to asciidoc]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add information about libblkid requirement to INSTALL file
Augusto Mecking Caringi [Sat, 31 May 2014 01:05:10 +0000 (22:05 -0300)]
btrfs-progs: Add information about libblkid requirement to INSTALL file

Signed-off-by: Augusto Mecking Caringi <augustocaringi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: doc: fix symlink target for btrfsck.8
David Sterba [Mon, 5 May 2014 14:54:00 +0000 (16:54 +0200)]
btrfs-progs: doc: fix symlink target for btrfsck.8

The manpage of btrfsck.8 is supposed to link to btrfs-check.8 .

Reported-by: WorMzy Tykashi <wormzy.tykashi@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix build, manpage compression command
Christian Hesse [Tue, 3 Jun 2014 06:09:25 +0000 (08:09 +0200)]
btrfs-progs: fix build, manpage compression command

man pages for btrfs-progs are compressed by gzip by default. In Makefile
the variable GZIP is use, this evaluates to 'gzip gzip' on my system.
>From man gzip:

> The environment variable GZIP can hold a set of default options for
> gzip. These options are interpreted first and can be overwritten by
> explicit command line parameters.

So using any other variable name fixes this.

Signed-off-by: Christian Hesse <mail@eworm.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs-progs: debug-tree, add option to dump a single tree
Filipe David Borba Manana [Fri, 23 May 2014 13:44:29 +0000 (14:44 +0100)]
Btrfs-progs: debug-tree, add option to dump a single tree

Very often while debugging filesystems with many subvolumes and/or
snapshots, specially when they are large, I want to see only the
content of one of the trees. So this change just adds an option
to btrfs-debug-tree to allow to specify the id of the tree we're
interesting in dumping to stdout.

Example:  btrfs-debug-tree -t 257 /dev/sdc

Will only dump the tree of the first snapshot or subvolume that was
created.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-show-super: don't try to print not-superblocks
Eric Sandeen [Wed, 14 May 2014 02:03:04 +0000 (21:03 -0500)]
btrfs-show-super: don't try to print not-superblocks

If we point btrfs-show-super at a not-btrfs-device and
try to print all superblocks, bad things are apt to happen:

superblock: bytenr=274877906944, device=/dev/sdc2
---------------------------------------------------------
btrfs-show-super: ctree.h:1984: btrfs_super_csum_size: \
Assertion `!(t >= (sizeof(btrfs_csum_sizes) / sizeof((btrfs_csum_sizes)[0])))' failed.
csum 0xAborted

Don't try to print superblocks that don't look like superblocks,
and add an "-f" (force) option to try anyway, if the user
really wants to give it a shot.

Fix some spelling & capitalization while we're at it.

The manpage says that if any problem happens, 1 will
be returned, but that's already not true today LOL, so
I didn't bother to make it true when we detect bad
sb magic, either...

I figure it's worth continuing and trying all superblocks
in case just one has a corrupt magic.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
[renamed -f to -F due to clash with existing option, converted
relevant docs to asciidoc]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use check_argc_exact to check arg number of btrfs-rescue
Gui Hecheng [Thu, 15 May 2014 01:29:09 +0000 (09:29 +0800)]
btrfs-progs: use check_argc_exact to check arg number of btrfs-rescue

The btrfs-rescue accepts exactly one arg for both
chunk-recover & super-recover, use check_argc_exact clearly.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add sys_chunk_array and backup roots info to show-super
Gui Hecheng [Fri, 16 May 2014 01:23:37 +0000 (09:23 +0800)]
btrfs-progs: add sys_chunk_array and backup roots info to show-super

Add sys chunk array and backup roots info if the new option '-f'
if specified.
This may be useful for debugging sys_chunk related issues.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Remove unneeded assert in find_good_parent().
Qu Wenruo [Mon, 12 May 2014 01:39:42 +0000 (09:39 +0800)]
btrfs-progs: Remove unneeded assert in find_good_parent().

find_good_parent() uses assert to deal with the problem that clone
source's parent can't be found.
But in fact the assert is somewhat overkilled since subvol_uuid_search()
has enough error messages for debug and caller of find_good_parent() can
handle the problems in find_good_parent(), so the assert can be removed
without any problem.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Replace the overkill assert with normal error message.
Qu Wenruo [Mon, 28 Apr 2014 08:37:30 +0000 (16:37 +0800)]
btrfs-progs: Replace the overkill assert with normal error message.

When 'btrfs replace status' encounters an unknown dev replace status, it
will cause an assert, which is somewhat overkilled and can be replaced
with a normal error message.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Improve the errno string about open_path_or_dev_mnt()
Qu Wenruo [Mon, 28 Apr 2014 08:37:29 +0000 (16:37 +0800)]
btrfs-progs: Improve the errno string about open_path_or_dev_mnt()

open_path_or_dev_mnt() is used to on *mounted* btrfs device or mount
point, when a unmounted btrfs device is passed, errno is set to EINVAL to
info the caller.
If ignore the errno and just print "ERROR: can't access '%s'", end users
will get confused.

This patch will add check for open_path_or_dev_mnt() caller and print
more meaningful error message when a unmounted btrfs device path is
given.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agov3.14.2
Chris Mason [Fri, 30 May 2014 00:56:59 +0000 (20:56 -0400)]
v3.14.2

Signed-off-by: Chris Mason <clm@fb.com>
10 years agoscrub: fix uninit return variable in scrub_progress_cycle
Chris Mason [Wed, 28 May 2014 21:01:39 +0000 (17:01 -0400)]
scrub: fix uninit return variable in scrub_progress_cycle

Signed-off-by: Chris Mason <clm@fb.com>
10 years agobtrfs-progs: doc: update the Availability section
David Sterba [Mon, 19 May 2014 16:04:26 +0000 (18:04 +0200)]
btrfs-progs: doc: update the Availability section

Does not reflect the current state. The wiki contains more details on
the first page.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: doc: make all commands and subcommands bold
David Sterba [Mon, 19 May 2014 15:49:35 +0000 (17:49 +0200)]
btrfs-progs: doc: make all commands and subcommands bold

Italic format is used for parameters and values.  also this makes the
text visually separated,

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: doc: autoformat user-supplied arguments by sed
David Sterba [Mon, 19 May 2014 15:38:03 +0000 (17:38 +0200)]
btrfs-progs: doc: autoformat user-supplied arguments by sed

Convert all values enclosed between <...> to italic before it goes to
asciidoc processor.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: doc: remove text for unmerged features
David Sterba [Mon, 19 May 2014 15:18:24 +0000 (17:18 +0200)]
btrfs-progs: doc: remove text for unmerged features

The asciidoc conversion was done on a development branch and there are
portions of text that do not reflect the code.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: doc: fix argument notation and typos
David Sterba [Mon, 19 May 2014 15:08:56 +0000 (17:08 +0200)]
btrfs-progs: doc: fix argument notation and typos

All user-supplied values should be enclosed in <...> to distinguish
them from verbatim strings.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: fix mkfs.btrfs segfault with --features option
Holger Hoffstätte [Sat, 26 Apr 2014 09:41:04 +0000 (09:41 +0000)]
btrfs-progs: fix mkfs.btrfs segfault with --features option

The mkfs.btrfs --features long option takes an argument but does not
declare it. Consequently getopt does not allocate an argument, which
makes an unconditional strdup() crash during options parsing.
Fix by declaring the argument in the options alias array.

Signed-off-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: mkfs: remove ununsed parameters
Rakesh Pandit [Fri, 25 Apr 2014 23:05:31 +0000 (02:05 +0300)]
Btrfs-progs: mkfs: remove ununsed parameters

Remove ununsed parameters since 71d6bd3c in create_raid_groups.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: set string end sing '\0' for property
Liu Bo [Fri, 25 Apr 2014 10:44:03 +0000 (18:44 +0800)]
Btrfs-progs: set string end sing '\0' for property

Set string "xattr_name" 's end with '\0' so that it won't be
violated in memory.

With this fix, xfstest/btrfs/048 can pass on my box.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: prevent close_root if the root to close is potentially NULL
Gui Hecheng [Thu, 24 Apr 2014 03:39:28 +0000 (11:39 +0800)]
btrfs-progs: prevent close_root if the root to close is potentially NULL

Originally only if 'block_only' is specified, the 'fs_root == NULL'
will be checked. But if 'block_only' is not specified and close_root
will be called blindly without checking 'fs_root == NULL', which is
unsafe.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: move arg_strtou64 to a separate file for library
David Sterba [Fri, 11 Apr 2014 11:22:50 +0000 (13:22 +0200)]
btrfs-progs: move arg_strtou64 to a separate file for library

Linking with libbtrfs fails because arg_strtou64 is not defined and we
cannot just add utils.o to library objects because it's not
library-clean.

Reported-by: Arvin Schnell <aschnell@suse.com>
Reported-by: Anton Farygin <rider@altlinux.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: add dev maxs limit for btrfs_alloc_chunk in user space
Gui Hecheng [Mon, 21 Apr 2014 12:13:32 +0000 (20:13 +0800)]
btrfs-progs: add dev maxs limit for btrfs_alloc_chunk in user space

For RAID0,5,6,10,
For system chunk, there shouldn't be too many stripes to
make a btrfs_chunk that exceeds BTRFS_SYSTEM_CHUNK_ARRAY_SIZE
For data/meta chunk, there shouldn't be too many stripes to
make a btrfs_chunk that exceeds a leaf.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: fix wrong max system array size check in user space
Gui Hecheng [Mon, 21 Apr 2014 12:13:31 +0000 (20:13 +0800)]
btrfs-progs: fix wrong max system array size check in user space

For system chunk array,
We copy a "disk_key" and an chunk item each time,
so there should be enough space to hold both of them,
not only the chunk item.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: mkfs: Remove 'zero_end =1' since it has been set to a value
Li Yang [Mon, 21 Apr 2014 09:38:08 +0000 (05:38 -0400)]
Btrfs-progs: mkfs: Remove 'zero_end =1' since it has been set to a value

In utils.c, zero_end is used as a parameter, should not force it to 1.
In mkfs.c, zero_end is set to 1 or 0(-b) at the beginning, should not
force it to 1 unconditionally.

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: fix double free memory crash
Rakesh Pandit [Sun, 20 Apr 2014 13:17:53 +0000 (16:17 +0300)]
Btrfs-progs: fsck: fix double free memory crash

Fix double free of memory if btrfs_open_devices fails:
*** Error in `btrfs': double free or corruption (fasttop): 0x000000000066e020 ***

Crash happened because when open failed on device inside
btrfs_open_devices it freed all memory by calling btrfs_close_devices but
inside disk-io.c we call btrfs_close_again it again.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: make smatch checker happy (trivial fixes)
Rakesh Pandit [Sat, 19 Apr 2014 19:05:41 +0000 (22:05 +0300)]
Btrfs-progs: make smatch checker happy (trivial fixes)

It complains errno never gets assigned to zero in find-root and since
errno anyway is zero at program started up, lets remove it.

Check "copy is less then zero" isn't possible because strtoull used by
arg_strtou64 wouldn't return -ve number.

Trivial space fixes.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: receive: remove return type of close_inode_for_write
Rakesh Pandit [Fri, 18 Apr 2014 23:14:14 +0000 (02:14 +0300)]
Btrfs-progs: receive: remove return type of close_inode_for_write

"close_inode_for_write" always returns 0, so just remove its return
value and remove dead checking in caller.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: while checking root refs print readable errors
Rakesh Pandit [Fri, 18 Apr 2014 23:13:55 +0000 (02:13 +0300)]
Btrfs-progs: fsck: while checking root refs print readable errors

Lets use "errors" instead of "error" because more then one ref errors
are possible. Also print error messages for unresolved refs in
check_root_refs.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: allow compression property gets for read-only subvolumes
Filipe David Borba Manana [Tue, 15 Apr 2014 19:47:27 +0000 (20:47 +0100)]
Btrfs-progs: allow compression property gets for read-only subvolumes

Because the function open_file_or_dir() always opened the input file in
read/write mode (O_RDWR), we were not able to due a compression property
get against a file living in a read-only subvolume/snapshot.
Fix this by opening the file with O_RDONLY mode if we're doing a property
get.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fix check to test trim support
Rakesh Pandit [Tue, 22 Apr 2014 13:30:27 +0000 (16:30 +0300)]
Btrfs-progs: fix check to test trim support

It was added in 25d82d22 but broke recently in 4724d7b0 while making
discard interruptible.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Fix the return value when executing 'btrfs prop get' on an uncompressed...
Qu Wenruo [Tue, 15 Apr 2014 09:22:24 +0000 (17:22 +0800)]
btrfs-progs: Fix the return value when executing 'btrfs prop get' on an uncompressed file

When executing 'btrfs prop get' on a file which is not compressed, return
value will always be 50 since prop_compress() return -ENOATTR.

But the codes have already check the errno to avoid unnecessary error
message, so the return value should also set to 0.

Signed-off-by: Qu Wenruo <quwenro@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Fix the return value of btrfs_scan_kernel()
Qu Wenruo [Tue, 8 Apr 2014 09:16:02 +0000 (17:16 +0800)]
btrfs-progs: Fix the return value of btrfs_scan_kernel()

btrfs_scan_kernel() is only used in 'btrfs fi show' but returns wrong
return value.  When search parameter is passed, it will never return 0
even the search can be matched.

This patch will change the whatever strange logic to a more easy to
understand one using 'found' var.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: chunk_recovery: fix mem leak and pthread_cancel call
Rakesh Pandit [Wed, 26 Mar 2014 19:34:30 +0000 (21:34 +0200)]
Btrfs-progs: chunk_recovery: fix mem leak and pthread_cancel call

Free memory if open call fails. Prevent pthread_cancel on threads
which have already finished successfully. If all calls to
pthread_create and pthread_join are successful, we mistakenly call
pthread_cancel because cancel_from and cancel_to are both zero.

Make POSIX.1-2001 happy by supplying a non-NULL second argument to
pthread_setcanceltype.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: scrub: disable thread cancelability during mutex locks
Rakesh Pandit [Tue, 25 Mar 2014 14:47:07 +0000 (16:47 +0200)]
Btrfs-progs: scrub: disable thread cancelability during mutex locks

scrub_progress_cycle thread runs in asynchronous type but locks mutex
while reading shared data. This patch disables cancelability for a
brief time while locks are on so as to make sure they are unlocked
before thread is canceled.

scrub_write_progress gets called from scrub_progress_cycle in
asynchronous thread but cancelability is disabled after mutex is
locked. This patch moves the call to set cancelability type before
mutex lock and makes corresponding changes to labels for error
handling.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: remove unsed pthread attribute objects
Rakesh Pandit [Mon, 24 Mar 2014 09:04:47 +0000 (11:04 +0200)]
Btrfs-progs: remove unsed pthread attribute objects

Threads always use default attributes in all tools, so pthread
attribute objects and their initializations are of no use. Just pass
NULL as attr attribute to pthread_create for default attributes.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: btrfs-image: don't call pthread_join on IDs not present
Rakesh Pandit [Fri, 21 Mar 2014 01:06:23 +0000 (03:06 +0200)]
Btrfs-progs: btrfs-image: don't call pthread_join on IDs not present

If pthread_create fails in mdrestore_init, then number of threads
created could be less then num of threads option. Hence pass number of
successful pthread_create calls to mdrestore_destroy, so that we don't
call pthread_join on IDs not present when pthread_create fails.

metadump_init already had this fixed, but repeats code from
metadump_destroy. Reuse metadump_destroy by passing number of threads
created (successful pthread_create calls) and save repeated cleaup
code. Had to move metadump_destroy before metadump_init for obvious
reasons.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: doc: link btrfsck to btrfs-check
David Sterba [Wed, 16 Apr 2014 16:33:44 +0000 (18:33 +0200)]
btrfs-progs: doc: link btrfsck to btrfs-check

The 'btrfsck' command has been deprecated in favor of 'btrfs check'. For
compatibility install a symlink to the btrfs-check.8 manpage.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: add separate make target to clean docs
David Sterba [Fri, 4 Apr 2014 14:36:40 +0000 (16:36 +0200)]
btrfs-progs: add separate make target to clean docs

Regenerating the asciidoc takes much longer now and makes quick build
tests long. There's separate clean-doc target for that and clean-all
that cleans docs and sources.

Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Add btrfs wiki reference to man pages.
Qu Wenruo [Tue, 15 Apr 2014 07:04:51 +0000 (15:04 +0800)]
btrfs-progs: Add btrfs wiki reference to man pages.

Add btrfs wiki page reference to btrfs-check/btrfsck, btrfs-restore and
btrfs-device as supplement.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-property.
Qu Wenruo [Tue, 15 Apr 2014 07:04:50 +0000 (15:04 +0800)]
btrfs-progs: Convert man page for btrfs-property.

Convert the man page for the newly added btrfs-property subcommand.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-restore.
Qu Wenruo [Tue, 15 Apr 2014 07:04:49 +0000 (15:04 +0800)]
btrfs-progs: Convert man page for btrfs-restore.

Convert man page for btrfs-restore, which I forgot to convert in the
previous patchset. :P

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Add explain on btrfs-zero-log.
Qu Wenruo [Fri, 11 Apr 2014 02:43:53 +0000 (10:43 +0800)]
btrfs-progs: Add explain on btrfs-zero-log.

Add more explain on btrfs-zero-log about when to use it.

Reviewed-by: Marc MERLIN <marc@merlins.org>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Add device management related paragraph.
Qu Wenruo [Fri, 11 Apr 2014 02:43:52 +0000 (10:43 +0800)]
btrfs-progs: Add device management related paragraph.

Add device management related paragraph to better explain btrfs device
management.

Cc: Marc MERLIN <marc@merlins.org>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Switch to the new asciidoc Documentation.
Qu Wenruo [Wed, 2 Apr 2014 08:29:38 +0000 (16:29 +0800)]
btrfs-progs: Switch to the new asciidoc Documentation.

Since all man page are converted to the new asciidoc, the old man page
can be removed.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for mkfs.btrfs.
Qu Wenruo [Wed, 2 Apr 2014 08:29:37 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for mkfs.btrfs.

Convert man page for mkfs.btrfs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for fsck.btrfs.
Qu Wenruo [Wed, 2 Apr 2014 08:29:36 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for fsck.btrfs.

Convert man page for fsck.btrfs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-zero-log
Qu Wenruo [Wed, 2 Apr 2014 08:29:35 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-zero-log

Convert man page for btrfs-zero-log

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfstune.
Qu Wenruo [Wed, 2 Apr 2014 08:29:34 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfstune.

Convert man page for btrfstune.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-show-super.
Qu Wenruo [Wed, 2 Apr 2014 08:29:33 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-show-super.

Convert man page for btrfs-show-super.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-map-logical.
Qu Wenruo [Wed, 2 Apr 2014 08:29:32 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-map-logical.

Convert man page for btrfs-map-logical.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-image.
Qu Wenruo [Wed, 2 Apr 2014 08:29:31 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-image.

Convert man page for btrfs-image.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-find-root.
Qu Wenruo [Wed, 2 Apr 2014 08:29:30 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-find-root.

Convert man page for btrfs-find-root.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-debug-tree.
Qu Wenruo [Wed, 2 Apr 2014 08:29:29 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-debug-tree.

Convert man page for btrfs-debug-tree.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-convert.
Qu Wenruo [Wed, 2 Apr 2014 08:29:28 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-convert.

Convert man page for btrfs-convert.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-replace.
Qu Wenruo [Wed, 2 Apr 2014 08:29:25 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-replace.

Convert man page for btrfs-replace.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert and enhance the man page of btrfs-qgroup.
Qu Wenruo [Wed, 2 Apr 2014 08:29:24 +0000 (16:29 +0800)]
btrfs-progs: Convert and enhance the man page of btrfs-qgroup.

Convert and enhance the man page of btrfs-qgroup.

The original man page for btrfs-qgroup subcommand is almost useless for
new user(like me), so adds more information on it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-quota.
Qu Wenruo [Wed, 2 Apr 2014 08:29:23 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-quota.

Convert man page for btrfs-quota.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-receive.
Qu Wenruo [Wed, 2 Apr 2014 08:29:22 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-receive.

Convert man page for btrfs-receive.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-send.
Qu Wenruo [Wed, 2 Apr 2014 08:29:21 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-send.

Convert man page for btrfs-send.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-inspect-internal
Qu Wenruo [Wed, 2 Apr 2014 08:29:20 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-inspect-internal

Convert man page for btrfs-inspect-internal.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-rescue
Qu Wenruo [Wed, 2 Apr 2014 08:29:19 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-rescue

Convert man page for btrfs-rescue.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-check.
Qu Wenruo [Wed, 2 Apr 2014 08:29:18 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-check.

Convert man page for btrfs-check.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-scrub
Qu Wenruo [Wed, 2 Apr 2014 08:29:17 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-scrub

Convert man page for btrfs-scrub.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-device subcommand.
Qu Wenruo [Wed, 2 Apr 2014 08:29:16 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-device subcommand.

Convert man page for btrfs-device subcommand.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-balance.
Qu Wenruo [Wed, 2 Apr 2014 08:29:15 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-balance.

Convert man page for btrfs-balance.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for filesystem subcommand.
Qu Wenruo [Wed, 2 Apr 2014 08:29:14 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for filesystem subcommand.

Convert man page for filesystem subcommand.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Convert man page for btrfs-subvolume
Qu Wenruo [Wed, 2 Apr 2014 08:29:13 +0000 (16:29 +0800)]
btrfs-progs: Convert man page for btrfs-subvolume

Convert man page for btrfs-subvolume.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Introduce asciidoc based man page and btrfs man page.
Qu Wenruo [Wed, 2 Apr 2014 08:29:12 +0000 (16:29 +0800)]
btrfs-progs: Introduce asciidoc based man page and btrfs man page.

The old man page of btrfs will grow larger with new functions adding to
btrfs-progs and harder to maintain because the reader-unfriendly roff
grammar and one LARGE btrfs.in.

This patch will introduce the simplified Documentation directory mainly
'stolen' from git and include the first man page for 'btrfs(8)'.
This time, man page will be written in human-friendly asciidoc grammar
and each commands of btrfs will have a separate man page, which I hope
can reduce the effort to maintain the man page.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agov3.14.1
Chris Mason [Fri, 18 Apr 2014 17:46:31 +0000 (10:46 -0700)]
v3.14.1

Signed-off-by: Chris Mason <clm@fb.com>
10 years agobtrfs-progs: correct prompt of minimal num of devs for raid56
Gui Hecheng [Thu, 10 Apr 2014 03:55:36 +0000 (11:55 +0800)]
btrfs-progs: correct prompt of minimal num of devs for raid56

For btrfs,
Raid5 can't go below 2 devs, not 3;
Raid6 can't go below 3 devs, not 4.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: update btrfs_file_extent_inline_len to match kernel version
Filipe David Borba Manana [Tue, 8 Apr 2014 17:25:43 +0000 (18:25 +0100)]
Btrfs-progs: update btrfs_file_extent_inline_len to match kernel version

The following kernel commit changed the definition of the inline function
btrfs_file_extent_inline_len():

    commit 514ac8ad8793a097c0c9d89202c642479d6dfa34
    Author: Chris Mason <clm@fb.com>
    Date:   Fri Jan 3 21:07:00 2014 -0800

    Btrfs: don't use ram_bytes for uncompressed inline items

    If we truncate an uncompressed inline item, ram_bytes isn't updated to reflect
    the new size.  The fixe uses the size directly from the item header when
    reading uncompressed inlines, and also fixes truncate to update the
    size as it goes.

Not having this new definition implies that the restore tool might misbehave when
restoring files with an inline extent that got truncated on a kernel older than
release 3.14.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: restore, for compressed extents don't read more bytes than needed
Filipe David Borba Manana [Tue, 8 Apr 2014 16:37:22 +0000 (17:37 +0100)]
Btrfs-progs: restore, for compressed extents don't read more bytes than needed

We need to read a number of bytes corresponding to the disk size of the file extent
item, and not to the number of bytes in the num_bytes field. Normally disk_size is
smaller than num_bytes (when using compression), except for files created with lzo
compression in a kernel older then the one which introduced the following change:

commit 59516f6017c589e7316418fda6128ba8f829a77f
Author: Stefan Agner <stefan@agner.ch>
Date:   Mon Jul 1 20:33:39 2013 +0200

    Btrfs: return -1 when lzo compression makes data bigger

    With this fix the lzo code behaves like the zlib code by returning an
    error
    code when compression does not help reduce the size of the file.
    This is currently not a bug since the compressed size is checked again
    in
    the calling method compress_file_range.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Make property work with -t option
Kusanagi Kouichi [Tue, 8 Apr 2014 13:38:02 +0000 (22:38 +0900)]
btrfs-progs: Make property work with -t option

# btrfs prop list -t f .
btrfs property list: too many arguments
...
# btrfs prop get -t f . label
btrfs property get: too many arguments
...
# btrfs prop set -t f . label abc
btrfs property set: too many arguments
...

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Constify getters
Kusanagi Kouichi [Tue, 8 Apr 2014 13:37:39 +0000 (22:37 +0900)]
btrfs-progs: Constify getters

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: btrfs: remove dead code in handle_options
Rakesh Pandit [Thu, 20 Mar 2014 09:43:35 +0000 (11:43 +0200)]
Btrfs-progs: btrfs: remove dead code in handle_options

Just cleanup: remove useless return type, while loop and dead code.

Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs: Modify the help string to keep consistent with man page.
Qu Wenruo [Wed, 19 Mar 2014 06:10:02 +0000 (06:10 +0000)]
btrfs-progs: Modify the help string to keep consistent with man page.

Help string of "btrfs dev scan" is inconsistent with man page,
which lacks the fact that -d|--all-device is conflict with <device>.
This patch fixes the description

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: fix wrong index in pick_next_pending()
Wang Shilong [Tue, 18 Mar 2014 12:02:47 +0000 (20:02 +0800)]
Btrfs-progs: fsck: fix wrong index in pick_next_pending()

Though all tree blocks have same size, we'd better use right
index here.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: reduce memory usage of extent record struct
Wang Shilong [Tue, 18 Mar 2014 12:02:46 +0000 (20:02 +0800)]
Btrfs-progs: fsck: reduce memory usage of extent record struct

Two changes:
1.use bit filed for @found_rec
2.u32 is enough to calculate duplicate extent number.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: fix possible memory leaks in run_next_block()
Wang Shilong [Tue, 18 Mar 2014 12:02:43 +0000 (20:02 +0800)]
Btrfs-progs: fsck: fix possible memory leaks in run_next_block()

We still need free allocated cache memory in case error happens.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agoBtrfs-progs: fsck: don't free @seen cache until we finish searching
Wang Shilong [Tue, 18 Mar 2014 12:02:42 +0000 (20:02 +0800)]
Btrfs-progs: fsck: don't free @seen cache until we finish searching

@seen cache is used to avoid iterating same block more than once, and
we can not free them until we have finished searching.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
10 years agobtrfs-progs v3.14
Chris Mason [Sun, 6 Apr 2014 23:33:55 +0000 (19:33 -0400)]
btrfs-progs v3.14

Signed-off-by: Chris Mason <clm@fb.com>
10 years agobtrfs-progs: fix listing deleted subvolumes
David Sterba [Fri, 28 Mar 2014 12:39:57 +0000 (13:39 +0100)]
btrfs-progs: fix listing deleted subvolumes

The real check whether to show deleted or live subvolumes was skipped if
just '-d' was specified without other filters. The 'deleted' filter was
not accounted.

It is now handled as a normal filter, that additionally sets the only_delete
global status in order to be processed before any other filters in
filter_root().

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
10 years agobtrfs-progs: make device discard process interruptible
David Sterba [Thu, 27 Mar 2014 15:19:37 +0000 (16:19 +0100)]
btrfs-progs: make device discard process interruptible

The ioctl for the whole range is not interruptible, which can be
annoying when the discard is not wanted but user forgets to use the -K
option.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>