Commit Graph

2434 Commits (9db13dca2f00b8a7cfd31fb737cfd0e73ad48abf)
 

Author SHA1 Message Date
Qu Wenruo 9db13dca2f 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>
2016-02-26 17:27:58 +01:00
Qu Wenruo 43318324d2 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>
2016-02-26 17:27:58 +01:00
Qu Wenruo e2e0dae926 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>
2016-02-26 17:27:58 +01:00
Hongxu Jia bfc2cb7cfb 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>
2016-02-26 17:27:58 +01:00
David Sterba 476d17fe38 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>
2016-02-23 19:02:23 +01:00
David Sterba 0ad5efde1a 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>
2016-02-23 19:02:23 +01:00
Lakshmipathi.G cc57faac2e 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>
2016-02-23 19:02:23 +01:00
Satoru Takeuchi be09626592 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>
2016-02-05 16:19:52 +01:00
Satoru Takeuchi 194a4053f9 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>
2016-02-04 15:19:32 +01:00
Satoru Takeuchi bf111ecf90 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>
2016-02-04 15:19:29 +01:00
Tsutomu Itoh 060a55c331 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>
2016-01-28 12:42:00 +01:00
Tsutomu Itoh 39ac3d16c1 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>
2016-01-28 12:41:56 +01:00
David Sterba d30b0be836 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>
2016-01-25 15:35:30 +01:00
Mike Gilbert 30ce6c76c1 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>
2016-01-21 19:35:33 +01:00
David Sterba 21258fab2c
Btrfs progs v4.4
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-18 13:56:35 +01:00
David Sterba 2460df7cd6 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>
2016-01-15 15:19:50 +01:00
David Sterba a2b24489da 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>
2016-01-15 14:16:36 +01:00
Noah Massey 1bb0bba1b6 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>
2016-01-15 13:31:44 +01:00
Mike Gilbert 17e204bb5e 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>
2016-01-14 11:46:59 +01:00
David Sterba 0de3c18b95
Btrfs progs v4.4-rc1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:16:27 +01:00
David Sterba 62cb593894 btrfs-progs: subvol show: use clean_args_no_options instead of opencoding
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba a6cc8ea10a 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>
2016-01-14 11:07:10 +01:00
David Sterba c26dc1ef33 btrfs-progs: move prefixcmp to utils
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba 3f248d2431 btrfs-progs: receive: don't leak open find handle
Resolves-coverity-id: 1348121
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba 7faf96e30a 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>
2016-01-14 11:07:10 +01:00
David Sterba dddc3e08cb btrfs-progs: more verbose errors from test_issubvolume
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba 7afde59e38 btrfs-progs: let test_issubvolume return the exact error
Return any error from stat, minor cleanups.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba 33ac47b5fb btrfs-progs: use symbolic name for subvolume inode number in test_issubvolume
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:10 +01:00
David Sterba 5b56fe9db5 btrfs-progs: handle errors from test_isdir
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-14 11:07:09 +01:00
David Sterba 1267c58e58 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>
2016-01-13 17:45:41 +01:00
David Sterba 2078848983 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>
2016-01-13 16:43:48 +01:00
David Sterba 0aa796cad7 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>
2016-01-13 16:43:48 +01:00
David Sterba b9ec406c0f 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>
2016-01-13 16:43:13 +01:00
David Sterba ecd4bb607f btrfs-progs: docs: enhance btrfs-filesystem manual page
Wording, formatting, explanations, examples.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 18:42:49 +01:00
David Sterba ac45d64c04 btrfs-progs: tests: add missing prerequisites
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:16:11 +01:00
David Sterba 4b9d4fe00f btrfs-porgs: fi usage: rename variable to avoid shadowing
Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:57 +01:00
David Sterba 39e98213eb btrfs-porgs: check: rename variable to avoid shadowing
Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:56 +01:00
David Sterba df3a134d0e btrfs-porgs: qgroup: rename variable to avoid shadowing
Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:56 +01:00
David Sterba 407f928cd2 btrfs-progs: add function attributes for the printf-like
Reported by gcc -Wsuggest-attribute=format .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:55 +01:00
David Sterba f9ae914756 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>
2016-01-12 15:02:55 +01:00
David Sterba ac4ec4d4f4 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>
2016-01-12 15:02:55 +01:00
David Sterba 633dc6f80f 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>
2016-01-12 15:02:55 +01:00
David Sterba 374d67fdef btrfs-progs: free-space-tree: minor message adjustments
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:55 +01:00
Khem Raj fcb6b102eb 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>
2016-01-12 15:02:54 +01:00
David Sterba 83a7413318 btrfs-progs: docs: document new mount option fragment
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:54 +01:00
David Sterba 23c51533ae btrfs-progs: docs: sort mount options alphabetically
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:54 +01:00
Omar Sandoval e4797df6a9 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>
2016-01-12 15:02:54 +01:00
Omar Sandoval d8c537e71f 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>
2016-01-12 15:02:54 +01:00
David Sterba 32c063ccb7 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>
2016-01-12 15:02:53 +01:00
David Sterba a8829f5335 btrfs-progs: docs, btrfs-mount: enhance file attributes section
Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:53 +01:00