Gui Hecheng [Thu, 18 Dec 2014 03:32:35 +0000 (11:32 +0800)]
btrfs-progs: remove uneccessary subvol name check for subvol deletion
When we want to delete a subvol, we first check to see whether it is
a subvolume or not. After the check, we are sure that it is a valid
subvol, don't have to check its name.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
[removed unused variable 'len']
Signed-off-by: David Sterba <dsterba@suse.cz>
Fan Chengniang [Fri, 9 Jan 2015 08:11:42 +0000 (16:11 +0800)]
btrfs-progs: btrfstune: fix multiple options error
when we use multiple options, error return status will be override by the
last option status.
example: btrfstune -S 1 -r /dev/loop0
when -S option fails and -r option succeeds, return value is 0, rather than
1, where 1 is the right return status.
Reported-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Fan Chengniang [Tue, 13 Jan 2015 03:53:16 +0000 (11:53 +0800)]
btrfs-progs: add missing options to qgroup limit
btrfs qgroup limit has two options -c and -e,. They were forgotten to add
to manpage.
Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 14 Jan 2015 06:50:40 +0000 (14:50 +0800)]
btrfs-progs: Fix wrong return value when executing 'fi show' on umounted device.
When executing 'btrfs fi show' on unmounted device, even no problem
happens, the return value is still 1 not 0.
The problem lies in search_umounted_fs_uuids(), where when it finds the
given uuid, it should return 1, but later uuid copy overwrites the return
value, causing it always return 0 under that case.
Fix it by pass found as pointer, and return value only indicates
whether anything wrong happens, whether found or not is stored in the
new parameter.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Merlijn Wajer [Wed, 14 Jan 2015 12:13:15 +0000 (13:13 +0100)]
btrfs-progs: restore backtrace functionality on glibc
Originally broke in commit
c2691f807ddd2c6b261c5707f6838a45d9275390
__glibc__ should have been __GLIBC__
We also include features.h ; although most includes (at least stdlib.h)
typically already include it -- at least on glibc, where it matters.
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Reported-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Martin Volf [Fri, 9 Jan 2015 21:27:21 +0000 (22:27 +0100)]
btrfs-progs: Remove redundant short description from cmd_snapshot_usage
cmd_snapshot_usage in cmds-subvolume.c contains the short description
twice. Remove the first one.
Signed-off-by: Martin Volf <martin.volf.42@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 9 Jan 2015 18:22:29 +0000 (19:22 +0100)]
Btrfs progs v3.18.1
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 22 Dec 2014 02:53:36 +0000 (10:53 +0800)]
btrfs-progs: Don't increase error count if the inode can be repaired.
The original check_inode_recs() will return -1 if found any error in a
inode_record. This is OK for original design since there is almost
nothing can repair at that time.
However more and more error from nlink mismatch to missing inode item
can be repaired in try_repair_inode(), check_inode_recs() should not
increase the error count if the inode can be repair.
With this patch, repair function for leaf-corruption will not return
error if all corruption inode can be recovered.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Fan Chengniang [Fri, 9 Jan 2015 07:08:56 +0000 (15:08 +0800)]
btrfs-progs: fix some format errors in doc
Signed-off-by: Fan Chengniang <fancn.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Tsutomu Itoh [Thu, 8 Jan 2015 02:40:53 +0000 (11:40 +0900)]
btrfs-progs: doc: fix format of btrfs-replace
Current 'man btrfs-replace' is as follows:
========================================================================
...
...
-f
force using and overwriting <targetdev> even if it looks like
containing a valid btrfs filesystem.
A valid filesystem is assumed if a btrfs superblock is found
which contains a correct checksum. Devices which are currently
mounted are never allowed to be used as the <targetdev>. -B::::
no background replace.
...
...
========================================================================
The format of 'B' option is wrong. So, fix it.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 7 Jan 2015 09:23:43 +0000 (17:23 +0800)]
btrfs-progs: Fix a copy-n-paste bug in btrfs_read_fs_root().
Introduced in commit
96ec888aad41969 ("btrfs-progs: add quota group
verify code").
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 6 Jan 2015 09:30:44 +0000 (17:30 +0800)]
btrfs-progs: Fix a buffer overflow causing segfault in fstests/btrfs/069
The newly introduced search_chunk_tree_for_fs_info() won't count devid 0
in fi_arg->num_devices, which will cause buffer overflow since later
get_device_info() will fill di_args with devid.
This can be trigger by fstests/btrfs/069 and any operations needs to
iterate over all the devices like 'fi show' or 'dev stat' while
replacing.
The fix is do an extra probe specifically for devid 0 after
search_chunk_tree_for_fs_info() and change num_devices if needed.
Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Peter Wu [Mon, 5 Jan 2015 14:10:09 +0000 (15:10 +0100)]
btrfs-progs: Documentation: fix broken conversion
Fixes various formatting issues:
Fixes quoting issues in various manpages. Before/After excerpts for
mkfs.btrfs(8), btrfs-qgroup(8):
mkfs.btrfs [-A|--alloc-start '<alloc-start>']
mkfs.btrfs [-A|--alloc-start <alloc-start>]
id 0/<subvolume id>''
id 0/<subvolume id>
If multiple '<attr>'s is given, use comma to separate.
If multiple <attr>s is given, use comma to separate.
The one that is most apparent is the removal of text in
btrfs-subvolume(8) and others. Before/After:
list [options] [-G <value>] [-C <value>] [--sort=rootid,gen,ogen,path] <path>
list [options] [-G [+|-]<value>] [-C [+|-]<value>] [--sort=rootid,gen,ogen,path] <path>
create [-i <qgroupid>] <name>
create [-i <qgroupid>] [<dest>]<name>
This happens because `<foo>` was replaced by `'<foo>'` in the sed
expression, which is then treated as a constrained quote. As a result,
the `[...]` before the string gets interpreted as "quoted text
attributes".
In this patch, the sed expression is dropped and asciidoc is configured
to recognize `<...>` as a unconstrained quoted string (such that
`<attr>s` is correctly emphasized) and to avoid adding quotes in
contexts where it is not needed.
A remaining problem is that some texts (the one between brackets) do not
add the emphasis for `<...>`. While this could be solved by replacing
`[` and `]` with `[` and `]` using sed, it introduces formatting
problems in btrfs-zero-log(8) because the context is ignored.
Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 5 Jan 2015 07:56:15 +0000 (15:56 +0800)]
btrfs-progs: Fix a extent buffer leak in count_csum_range().
The commit
f495a2ac6611 ("btrfs-progs: fsck: remove unfriendly BUG_ON()
for searching tree failure") is causing tons of extent buffer leak if some
csum mismatches in btrfsck.
This is caused by a misplaced btrfs_release_path(), fix it.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 5 Jan 2015 06:24:27 +0000 (14:24 +0800)]
btrfs-progs: Allow debug-tree to be executed on regular file.
The commit
1bad43fbe002 ("btrfs-progs: refine btrfs-debug-tree error
prompt when a mount point given")
add judgement on btrfs-debug-tree to restrict only block device to be
executed on, but the command can also be used on regular file, so add
regular file support for the judgement.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 6 Jan 2015 17:54:48 +0000 (18:54 +0100)]
btrfs-progs: convert, handle pwrite error in do_rollback
Resolves-coverity-id: 1242984
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 6 Jan 2015 17:46:03 +0000 (18:46 +0100)]
btrfs-progs: handle orphan creation error in btrfs_unlink
The error handling is simple and just returns an error upward, no
cleanup.
Resolves-coverity-id: 1260251
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 02:33:31 +0000 (03:33 +0100)]
btrfs-progs: fix leak of path in reset_balance
A path may leak after an unlikely error condition.
Resolves-coverity-id: 1199474
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 02:24:10 +0000 (03:24 +0100)]
btrfs-progs: safely copy path in btrfs_scan_lblkid
We should terminate the string, let's use the wrapper.
Resolves-coverity-id: 1127097
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 02:13:11 +0000 (03:13 +0100)]
btrfs-progs: cleanup whitespace in is_same_blk_file
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 02:10:55 +0000 (03:10 +0100)]
btrfs-progs: use strncpy in is_same_blk_file
Although we're getting strings from the caller, let's be safe.
Resolves-coverity-id: 1199475
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:47:32 +0000 (02:47 +0100)]
btrfs-progs: check, handle error in fix_key_order
In case the buffer is corrupted and the for loop does not happen, we'd
return garbage. The caller retunrs -EIO in case of any corruption, use
that value in fix_key_order.
Resolves-coverity-id: 1246944
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:27:41 +0000 (02:27 +0100)]
btrfs-progs: doc subvolume, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:22:10 +0000 (02:22 +0100)]
btrfs-progs: doc scrub, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:20:50 +0000 (02:20 +0100)]
btrfs-progs: doc replace, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:20:06 +0000 (02:20 +0100)]
btrfs-progs: doc quota, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:19:31 +0000 (02:19 +0100)]
btrfs-progs: doc qgroup, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:18:15 +0000 (02:18 +0100)]
btrfs-progs: doc property, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:17:28 +0000 (02:17 +0100)]
btrfs-progs: doc inspect-internal, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:15:55 +0000 (02:15 +0100)]
btrfs-progs: doc device, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:12:56 +0000 (02:12 +0100)]
btrfs-progs: doc, undocument old balance syntax
Standalone balance subcommand has been around since 3.3.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 01:09:08 +0000 (02:09 +0100)]
btrfs-progs: doc balance, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:49:24 +0000 (01:49 +0100)]
btrfs-progs: doc filesystem, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:45:17 +0000 (01:45 +0100)]
btrfs-progs: doc btrfs, sort subcommands alphabetically
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:37:40 +0000 (01:37 +0100)]
btrfs-progs: doc restore, cleanups for wiki conversion
Properly format the patch regex and add a line break.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:36:39 +0000 (01:36 +0100)]
btrfs-progs: doc filesystem, cleanups for wiki conversion
Remove trailing space, add line break before NOTE.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:34:05 +0000 (01:34 +0100)]
btrfs-progs: doc balance, cleanups for wiki conversion
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:30:25 +0000 (01:30 +0100)]
btrfs-progs: doc mkfs, cleanups for wiki conversion
- remove trailing whitespace
- use +mono+ formatting for command line example
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Sat, 3 Jan 2015 00:26:31 +0000 (01:26 +0100)]
btrfs-progs: doc mkfs, mark leafsize deprecated
Signed-off-by: David Sterba <dsterba@suse.cz>
Tsutomu Itoh [Wed, 24 Dec 2014 07:10:52 +0000 (16:10 +0900)]
btrfs-progs: doc: fix incorrect format of 'l' option in mkfs.btrfs
The format of 'l' option in mkfs.btrfs.txt is wrong.
And, when the head of the character string is 65536, the following warning
is displayed.
$ make
Making all in Documentation
[ASCII] mkfs.btrfs.xml
asciidoc: WARNING: mkfs.btrfs.xml.tmp1: line 67: list item index: expected 1 got 65536
[XMLTO] mkfs.btrfs.8
[GZ] mkfs.btrfs.8.gz
rm mkfs.btrfs.8 mkfs.btrfs.xml
So, fix it.
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 2 Jan 2015 16:51:06 +0000 (17:51 +0100)]
btrfs-progs: doc filesystem, add unit suffixes to option descriptions
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 2 Jan 2015 16:22:07 +0000 (17:22 +0100)]
btrfs-progs: doc filesystem, fix quoting of size suffixes
Escape the first quote of two to cancel effects of ordinary '...' .
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 16:23:12 +0000 (17:23 +0100)]
Btrfs progs v3.18
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 14:37:29 +0000 (15:37 +0100)]
btrfs-progs: fix minor leak of dev_info in btrfs_scan_kernel
Resolves-coverity-id: 1127098
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 14:16:17 +0000 (15:16 +0100)]
btrfs-progs: fix overflow check in btrfs_insert_inode_ref
Resolves-coverity-id: 1260247
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 14:05:50 +0000 (15:05 +0100)]
btrfs-progs: check, missing parens around compound block in find_normal_file_extent
Resolves-coverity-id: 1260248
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 14:01:13 +0000 (15:01 +0100)]
btrfs-progs: fi show, don't leak canonical path
Resolves-coverity-id: 1260252
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 30 Dec 2014 13:52:55 +0000 (14:52 +0100)]
btrfs-progs: check, fix path leak in error branch
Resolves-coverity-id: 1260250
Signed-off-by: David Sterba <dsterba@suse.cz>
Gui Hecheng [Tue, 30 Dec 2014 01:52:17 +0000 (09:52 +0800)]
btrfs-progs: Documentation: add T/P/E description for resize cmd
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Gui Hecheng [Thu, 25 Dec 2014 01:16:35 +0000 (09:16 +0800)]
btrfs-progs: refine btrfs-debug-tree error prompt when a mount point given
Now, if exec:
# btrfs-debug-tree <mount_point>
it echos:
: Superblock bytenr is larger than device size
But it is quite misleading, because it is a valid btrfs.
In this case, we should tell the developer to provide a block device.
After apply:
: '<mount_point>' is not a block device
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Gui Hecheng [Thu, 25 Dec 2014 01:16:34 +0000 (09:16 +0800)]
btrfs-progs: move check_arg_type() to util.c
The check_arg_type() function does quite generic thing, move it to
utils.c.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Justin Maggard [Tue, 23 Dec 2014 19:34:52 +0000 (11:34 -0800)]
btrfs-progs: Fix btrfs fi show by uuid and label
Commit 8be2fff (btrfs-progs: apply realpath for btrfs fi
show when mount point is given) changed the behavior of
btrfs fi show to return an error if the call to realpath()
failed. This broke the ability to specify a filesystem by
uuid or label.
So let's not consider a failed call to realpath() as an
error. If the user really specified a bad device, just
return nothing like we did before.
Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Reviewed-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 23 Dec 2014 01:29:44 +0000 (09:29 +0800)]
btrfs-progs: Fix a bug in reset_nlink() which may deletes the recovered file
In reset_nlink(), we believe rec->found_link as accurate number of the
valid links. However it only records the number of found DIR_ITEM, so we
can't use it as reliable value.
Before this patch, in some case, leaf corruption recovery will believe
there is a valid backref but don't add_link() since it can't find any
valid one and don't put it into the lost+found dir.
So the recovered inode will be considered as an orphan item without
orphan item and repair_inode_orphan_item() will add orphan item for it,
causing all the filename/filetype we recovered being a waste of time.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Satoru Takeuchi [Thu, 18 Dec 2014 07:39:26 +0000 (16:39 +0900)]
btrfs-progs fix wrong memory free on check_is_root
When "/" is Btrfs, "btrfs property <subcommand> /" regards it
as non-root by mistake.
check_is_root() regards @object as a file system root if
the following two conditions are satisfied.
a) Both @object and its parent directory are Btrfs object
(file system root, subvolume, inode, and device
used for Btrfs).
b) fsid of the above mentioned two objects are different.
It doesn't work if @object is "/" because, in this case,
fsid of "/" and its parent (it's also "/"), are the same.
* Test environment
Two Btrfs file system (not subvolume) "/" and "/home/sat/mnt".
* How to reproduce
Submit "btrfs prop get" against the above mentioned file systems.
* Test Result
** Actual result (without my patch)
==========================
ro=false
label= # label is displayed because it's a file system root
ro=false # label is not displayed even if it's a file system root
==========================
** Expected result (with my patch)
==========================
ro=false
label=
ro=false
label=foo # label is displayed
===========================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Reported-by: Naohiro Aota <naota@elisp.net>
Reviewed-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 16:01:40 +0000 (17:01 +0100)]
btrfs-progs: let btrfs_free_path accept NULL
Same in kernel and matches semantics of free().
Resolves-Coverity-CID: 1054881
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 15:55:32 +0000 (16:55 +0100)]
btrfs-progs: check allocation result in add_clone_source
Resolves-Coverity-CID: 1054894
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 15:22:59 +0000 (16:22 +0100)]
btrfs-progs: check result of first_cache_extent
If the tree's empty, we'll get NULL and dereference it.
Resolves-Coverity-CID: 1248828
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 15:15:39 +0000 (16:15 +0100)]
btrfs-progs: fragments, close output file on error
Resolves-Coverity-CID: 1258794
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 15:11:59 +0000 (16:11 +0100)]
btrfs-progs: corrupt block, add break after option U
Resolves-Coverity-CID: 1258793
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 15:08:48 +0000 (16:08 +0100)]
btrfs-progs: corrupt block, add missing break to option I
Using -I would imply -d.
Resolves-Coverity-CID: 1258792
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 14:31:00 +0000 (15:31 +0100)]
btrfs-progs: move contents of math.h to utils.h and delete
Signed-off-by: David Sterba <dsterba@suse.cz>
Satoru Takeuchi [Fri, 19 Dec 2014 05:31:54 +0000 (14:31 +0900)]
btrfs-progs: cleanup: avoid to use literal for getopt val
Signed-off-by: David Sterba <dsterba@suse.cz>
Satoru Takeuchi [Fri, 19 Dec 2014 07:22:49 +0000 (16:22 +0900)]
btrfs-progs: Enhance the document of btrfs property
Enhance the document of btrfs property as follows.
- Add the description about the candidates of <name>.
- Enrich the description of <object>.
- Fix typos and some redundancy.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Reported-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 19 Dec 2014 06:13:12 +0000 (14:13 +0800)]
btrfs-progs: Remove deprecated _BSD_SOURCE macro.
Fix the following gcc(>4.9) and clang warning:
In file included from cmds-receive.c:24:
In file included from ./kerncompat.h:22:
In file included from /usr/include/stdio.h:27:
/usr/include/features.h:148:3: warning: "_BSD_SOURCE and _SVID_SOURCE
are deprecated, use _DEFAULT_SOURCE" [-W#warnings]
^
1 warning generated.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 19 Dec 2014 06:13:11 +0000 (14:13 +0800)]
btrfs-progs: Remove a unused function offset_to_bitmap()
Fix the following clang warning:
free-space-cache.c:464:19: warning: unused function 'offset_to_bitmap'
[-Wunused-function]
static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl,
^
1 warning generated.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 19 Dec 2014 06:13:10 +0000 (14:13 +0800)]
btrfs-progs: Remove a unused function root_gtp_mask().
Fix the following clang warning when compiling btrfs-progs:
radix-tree.c:78:21: warning: unused function 'root_gfp_mask'
[-Wunused-function]
static inline gfp_t root_gfp_mask(struct radix_tree_root *root)
^
1 warning generated.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 19 Dec 2014 06:13:09 +0000 (14:13 +0800)]
btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
When compiled with clang, the following warning is outputted.
disk-io.c:1017:15: warning: comparison of unsigned expression < 0 is
always false [-Wtautological-compare]
if (dev_size < 0)
~~~~~~~~ ^ ~
1 warning generated.
This is because dev_size is defined as unsigned type, but lseek() will
return singed valued.
So the judgement will always to false.
Use temporary off_t return value to solve it.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Fri, 19 Dec 2014 06:13:08 +0000 (14:13 +0800)]
btrfs-progs: Makefile: Move linker only option to LDFLAGS
Move the linker only option -rdynamic to LDFLAGS.
This resolve lots of the following warning if using clang as CC:
clang: warning: argument unused during compilation: '-rdynamic'
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 19 Dec 2014 13:59:22 +0000 (14:59 +0100)]
btrfs-progs: remove false dependency on libm
It ends up in the final binary, but there are not math functions used.
Signed-off-by: David Sterba <dsterba@suse.cz>
Merlijn Wajer [Sat, 13 Dec 2014 14:08:43 +0000 (15:08 +0100)]
btrfs-progs: disable backtrace and define __always_inline
Disable backtrace and define __always_inline when glibc is not used as
libc. This, together with some header changes allows btrfs-progs to
compile with musl-libc.
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
Merlijn Wajer [Sat, 13 Dec 2014 14:07:25 +0000 (15:07 +0100)]
btrfs-progs: include headers required for musl-libc
This fixes various compilation errors where PATH_MAX and XATTR_SIZE_MAX
were missing. To my knowledge, this should have no bad side effects.
Signed-off-by: Merlijn Wajer <merlijn@wizzup.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Mon, 15 Dec 2014 03:16:29 +0000 (11:16 +0800)]
btrfs-progs: Add testcase for leaf-corrupted btrfsck repairing.
Add testcase for leaf-corrupted btrfsck repairing using the new
generate_image.sh method.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Josef Bacik [Fri, 10 Oct 2014 20:50:42 +0000 (16:50 -0400)]
Btrfs-progs: add two new test images
This adds two new test images
1) 008-bad-offset-snapshots. This has a corrupt item with multiple snapshots
pointing to it, to make sure the bad block repair stuff doesn't loop and
actually repairs stuff. It also requires the dir index repair stuff to pass our
built in tests which is why it's not tied to the same commit.
2) 009-bad-dir-index-name.img. This has a corrupt name in a dir index to make
sure our dir index repair stuff is working properly.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
David Sterba [Thu, 18 Dec 2014 15:04:10 +0000 (16:04 +0100)]
btrfs-progs: check, update documentation
Add recently added options to manpage, a few other rewordings.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 18 Dec 2014 13:52:36 +0000 (14:52 +0100)]
btrfs-progs: unify unit mode parameters and variables
Use unsigned type and a common name everywhere.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 18 Dec 2014 14:23:08 +0000 (15:23 +0100)]
btrfs-progs: dev usage, update manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 17 Dec 2014 17:16:18 +0000 (18:16 +0100)]
btrfs-progs: dev usage, add switches to set output units
Same set of options as 'fi df': binary and decimal bases, human readable
options etc.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 18 Dec 2014 14:20:11 +0000 (15:20 +0100)]
btrfs-progs: fi usage, update manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 17 Dec 2014 17:11:58 +0000 (18:11 +0100)]
btrfs-progs: fi usage, add switches to set output units
Same set of options as 'fi df': binary and decimal bases, human readable
options etc.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Wed, 17 Dec 2014 17:05:48 +0000 (18:05 +0100)]
btrfs-progs: fi usage, change option for tabular output to T
We're going to use -t for tera- units prefix, same as 'fi df' does.
Signed-off-by: David Sterba <dsterba@suse.cz>
Satoru Takeuchi [Tue, 16 Dec 2014 09:42:38 +0000 (18:42 +0900)]
btrfs-progs: Add a brief explanation of btrfs property in man 8 btrfs
As Chris reported at the following mail, although
btrfs property has its own manpage, man 8 btrfs-property,
there is no explanation about it in man 8 btrfs.
https://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg40134.html
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Karel Zak [Fri, 12 Dec 2014 10:58:04 +0000 (11:58 +0100)]
btrfs-progs: fix typedef
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 12 Dec 2014 14:49:26 +0000 (15:49 +0100)]
btrfs-progs: tests: build prerequisities, btrfs-image and btrfs
Build required utilities from the main Makefile and just check in the
test scripts.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Fri, 12 Dec 2014 14:50:41 +0000 (15:50 +0100)]
btrfs-progs: tests: use 'btrfs check' instead of btrfsck
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 27 Nov 2014 18:34:22 +0000 (19:34 +0100)]
btrfs-progs: subvol delete: rename variable to match the option name
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 27 Nov 2014 18:26:35 +0000 (19:26 +0100)]
btrfs-progs: subvol delete: add verbosity option
Add an the option -v and use it for the transaction commit mode message.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 27 Nov 2014 18:15:06 +0000 (19:15 +0100)]
btrfs-progs: let subvol delete print commit mode inline
There are options to specify if the subvolume deletion should wait for
commit after each subvol or at the end. This is reported at the
beginning and considered as a noise. We'd like to report the mode for
each subvolume instead.
http://www.mail-archive.com/linux-btrfs%40vger.kernel.org/msg34617.html
Reported-by: Marc MERLIN <marc@merlins.org
Signed-off-by: David Sterba <dsterba@suse.cz>
Wang Shilong [Wed, 26 Nov 2014 02:58:52 +0000 (10:58 +0800)]
Btrfs-progs, fsck: move root items repair after root rebuilding
If some critical roots are corrupt, reapr_root_items() will fail,
this is detected by fsck_tests.sh's extent rebuilding tests.
Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Wang Shilong [Wed, 26 Nov 2014 02:58:51 +0000 (10:58 +0800)]
Btrfs-progs: fsck: add ability to rebuild extent tree with snapshots
This patch makes us to rebuild a really corrupt extent tree with snapshots.
To implement this, we have to verify whether a block is FULL BACKREF.
This idea come from Josef Bacik:
1) We walk down the original tree, every eb we encounter has
btrfs_header_owner(eb) == root->objectid. We add normal references
for this root (BTRFS_TREE_BLOCK_REF_KEY) for this root. World peace
is achieved.
2) We walk down the snapshotted tree. Say we didn't change anything
at all, it was just a clean snapshot and then boom. So the
btrfs_header_owner(root->node) == root->objectid, so normal backref.
We walk down to the next level, where btrfs_header_owner(eb) !=
root->objectid, but the level above did, so we add normal refs for all
of these blocks. We go down the next level, now our
btrfs_header_owner(parent) != root->objectid and
btrfs_header_owner(eb) != root->objectid. This is where we need to
now go back and see if btrfs_header_owner(eb) currently has a ref on
eb. If it does we are done, move on to the next block in this same
level, we don't have to go further down.
3) Harder case, we snapshotted and then changed things in the original
root. Do the same thing as in step 2, but now we get down to
btrfs_header_owner(eb) != root->objectid && btrfs_header_owner(parent)
!= root->objectid. We lookup the references we have for eb and notice
that btrfs_header_owner(eb) no longer refers to eb. So now we must
set FULL_BACKREF on this extent reference and add a
SHARED_BLOCK_REF_KEY for this eb using the parent->start as the
offset. And we need to keep walking down and doing the same thing
until we either hit level 0 or btrfs_header_owner(eb) has a ref on the
block.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Wang Shilong [Wed, 26 Nov 2014 02:58:50 +0000 (10:58 +0800)]
Btrfs-progs: fsck: deal with snapshot one by one when rebuilding extent tree
Previously, we deal with node block firstly and then leaf block which can
maximize readahead. However, to rebuild extent tree, we need deal with snapshot
one by one.
This patch makes us deal with snapshot one by one if we need rebuild extent
tree otherwise we drop into previous way.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Tue, 25 Nov 2014 17:46:16 +0000 (18:46 +0100)]
btrfs-progs: basic support for TREE_SEARCH_V2 ioctl
Add the interface and helper that checks if the v2 ioctl is supported.
Signed-off-by: David Sterba <dsterba@suse.cz>
David Sterba [Thu, 4 Dec 2014 18:16:30 +0000 (19:16 +0100)]
btrfs-progs: mkfs: make skinny-metadata default
According to public poll, this is desired and deemed to be safe. Feature
introduced in kernel 3.10 (Jun 2013).
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:32 +0000 (16:27 +0800)]
btrfs-progs: Add inode item rebuild function.
Add a basic inode item rebuild function for I_ERR_NO_INODE_ITEM.
The main use case is to repair btrfs which fs root has corrupted leaf,
but it is already working for case if the corrupteed fs root leaf/node
contains no inode extent_data.
The repair needs 3 elements for inode rebuild:
1. inode number
This is quite easy, existing inode_record codes will detect it quite
well.
2. inode type
This is the trick part. The only reliable method is to recovery it from
parent's dir_index/item.
The remaining method will search for regular file extent for FILE
type or child's backref for DIR(todo).
Fallback will be FILE.
Inode name(inode_ref) will be recoverd by nlink repair function.
This is just a fundamental implement, some advanced recovery can be
improved later with btrfs-progs infrastructure change.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:31 +0000 (16:27 +0800)]
btrfs-progs: Recover btree by dropping corrupted leaf/node.
Current btrfsck can skip corrupted leaf and even repair some corrupted
one if their bytenr or key order is wrong.
However when it comes to csum error leaf, btrfsck can only skip them,
which is OK for read-only iteration, but is bad for write.
This patch introduce the new repair_btree() function to recover the
btree, deleting all the corrupted leaf/node including corresponding
extent, allowing later write into the btree.
This patch provides the basis for later recovery with corrupted leaves.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:30 +0000 (16:27 +0800)]
btrfs-progs: record and report leaf/node corruption in fs/subvol tree
When leaf/node is corrupted in fs/subvolume root, btrfsck can ignore it
without much pain except some stderr messages complaining about it.
But this works fine doing read-only works, if we want to do deeper
recovery like rebuild missing inodes in the b+tree, it will cause
problem.
At least, info user that there is something wrong in the btree,
and this patch provides the base for later btree repair.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:29 +0000 (16:27 +0800)]
btrfs-progs: Add fixing function for inodes whose nlink dismatch
[BUG]
At least two users have already hit a bug in btrfs causing file
missing(Chromium config file).
The missing file's nlink is still 1 but its backref points to non-exist
parent inode.
This should be a kernel bug, but btrfsck fix is needed anyway.
[FIX]
For such nlink mismatch inode, we will reset all the inode_ref with its
dir_index/item (including valid one), and re-add the valids.
If there is no valid backref for it, create 'lost+found' under the root
of the subvolume and add link to the directory.
Reported-by: Mike Gavrilov <mikhail.v.gavrilov@gmail.com>
Reported-by: Ed Tomlinson <edt@aei.ca>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:28 +0000 (16:27 +0800)]
btrfs-progs: Add helper function find_file_name/type for nlink and inode_item repair.
Add find_file_name() and find_file_type() function for later nlink and
inode_item repair.
Later nlink repair will use both function and and inode_item repair will
use find_file_type().
They are done by searching the backref list, dir_item/index for type
search and dir_item/index or inode_ref for name search.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:27 +0000 (16:27 +0800)]
btrfs-progs: Add count_digits() function to help calculate filename len.
Add count_digits() function in utils.h to help calculate filename with
ino suffix.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Tue, 9 Dec 2014 08:27:26 +0000 (16:27 +0800)]
btrfs-progs: Add btrfs_mkdir() function for the incoming 'lost+found' fsck mechanism.
With the previous btrfs inode operations patches, now we can use
btrfs_mkdir() to create the 'lost+found' dir to do some data salvage in
btrfsck.
This patch along with previous ones will make data salvage easier.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Qu Wenruo [Wed, 3 Dec 2014 04:18:30 +0000 (12:18 +0800)]
btrfs-progs: Add btrfs_unlink() and btrfs_add_link() functions.
Add btrfs_unlink() and btrfs_add_link() functions in inode.c,
for the incoming btrfs_mkdir() and later inode operations functions.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>