Commit Graph

3705 Commits (1224f7343eae4d74f8e08e314c6e5b3a910dac5a)
 

Author SHA1 Message Date
David Sterba 1224f7343e btrfs-progs: print-tree: rename item callbacks to match the key name
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b3d343fc9c btrfs-progs: check: move fs roots check mode switch to a helper
Simplify main a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 902535a951 btrfs-progs: check: cleanup use of fs_info in check_fs_roots
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 12fe1a57f6 btrfs-progs: check: pass fs_info to check_fs_roots
The root pointer is not used anyway, will be cleaned up next.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 3ca3f20071 btrfs-progs: check: move chunk and extent check mode switch to a helper
Simplify main a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b3e08c27e1 btrfs-progs: check: pass fs_info to check_chunks_and_extents_v2
The root pointer is set to fs_root as was originally.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 7e9a270a12 btrfs-progs: check: use local fs_info in check_chunks_and_extents
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 7349edaf28 btrfs-progs: check: pass fs_info to check_chunks_and_extents
The root pointer is set to fs_root as was originally.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 04f480bc01 btrfs-progs: check: verify critical root pointers before use
The pointers to critical roots must be valid before we start using them,
eg. as the space clearing code.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba f03b293fdf btrfs-progs: check: move more of space cache clearing to a helper
Move the code out of main.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba af3369ae31 btrfs-progs: check: remove old mixed backref code
A code added in 2009 (95d3f20b51) for a very short-lived change in
the format is no concern to us nowadays.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 4851de27f1 btrfs-progs: tests: add more sanitizer message patterns to log scanner
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 87adfe8254 btrfs-progs: convert: don't print message when fs is not recognized, ext2
Bad magic error means it's not the desired filesystem so the error
message is just noise.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c9141313ec btrfs-progs: tests: limit size of log dump from conver tests
The convert tests generate lots of log material, travis CI has limit 4MB
so we don't see anything useful when a late test fails.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 73de02b1c5 btrfs-progs: handle failed search in find_search_start better
The warning can pop up frequently on a fuzzed image, the message seems
to be enough. Add a more fitting error code too.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 1fc20730db btrfs-progs: add more error handling to btrfs_free_block_group
As btrfs_update_block_group fails when the block group is not found in
cache, we can exit btrfs_free_block_group, not much to rollback. The
caller will also exit in turn.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba eae83c46f7 btrfs-progs: tests: fix TEST_LOG=dump in convert tests
Test failure in convert tests with log dump does not happen because
_fail is called before that and exits. Other test types are ok.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c6487a7d1d btrfs-progs: handle transaction start failure in close_ctree
Closing the fs will try to commit a pending transaction, but may fail to
do so if the filesystem state is not well defined. This will eg.  fail
for some fuzz tests. The data structures are freed but no furhter
attempt to commit is made.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c4dd5fef8a btrfs-progs: tests: update README
Wording, runtime dependencies.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 7da5841e3f btrfs-progs: tests: install missing CI packages
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 847ff667ce btrfs-progs: tests: add more checks for tools used in convert tests
Tools that may not be present in common installations should be checked
in the tests.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 1d5f84831c btrfs-progs: tests: build preparation phases out of script section
The logs of before_install are folded and we don't need to see the
details, unlike the test logs.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 72fbe845d4 btrfs-progs: don't start or commit after transaction abort
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 355a052647 btrfs-progs: start framework for transaction abort
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 0ee0b57f0b btrfs-progs: store pointer to fs_info in transaction handle
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba f2b0cbe8e8 btrfs-progs: move transaction code out of disk-io
Temporarily export the low-level helpers.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 37c271b216 btrfs-progs: move transaction implementation out of header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 599f46ade3 btrfs-progs: use kzalloc to allocate transaction handle
Use the kernel-style allocation helpers and remove redundant zeroing.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b423d18229 btrfs-progs: switch fs_info::system_allocs to bit
The value really is 0 or 1, the test in btrfs_reserve_extent can be
simplified.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 6db6afd993 btrfs-progs: return errors from btrfs_start_transaction
Now that all callers will catch errors, we can return them from the
function.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 448999d84d btrfs-progs: add crude error handling when transaction start fails
Currently transaction bugs out insided btrfs_start_transaction in case
of error, we want to lift the error handling to the callers. This patch
adds the BUG_ON anywhere it's been missing so far. This is not the best
way of course. Transforming BUG_ON to a proper error handling highly
depends on the caller and should be dealt with case by case.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 4ef5a112c9 btrfs-progs: tests: pull and build reiserfs lib inside CI
The functionality needed to support reiserfs in convert has been added
recently and is not yet available in the CI images, so we'll download
and build it there.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba ee37252115 btrfs-progs: tests: add build checks for sanitization features
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba a31458b966 btrfs-progs: build: fix asan and ubsan build
Probably with a new gcc (7.1.1) I started to see asan/ubsan link failures.
Fixed by explicitly linking the libraries.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 2e5617c9a6 btrfs-progs: build: fix building libbtrfs.so with tsan
Except libbtrfs.so object, all other tools compile fine. The error is:

ld: send-stream.o: relocation R_X86_64_PC32 against symbol
`stderr@@GLIBC_2.2.5' can not be used when making a shared object;
recompile with -fPIC

Compiling with -fPIC fixes the problem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba b8c9c457c1 btrfs-progs: build: properly pass the LDFLAGS during tsan build
The variable LD_FLAGS does not exist and the flags are not used, we need
to use the newly added internal debugging linker flags.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 339019c934 btrfs-progs: build: add internal LDFLAGS for the D= features
We might want to pass additional linker flags for various sanitization
features.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 092698b40a btrfs-progs: tests: add more fuzzed images from bugzilla
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 9b47f18aec btrfs-progs: handle blockgroup errors when opening filesystem
The call to btrfs_read_block_groups could loop if the metadata are
damaged (reported eg. for an unaligned block), due to lack of error
handling. We have to check for restored images or currently created
filesystems, that do not contain the blockgroups.

Can be reproduced by fuzzed image bko-155551.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=155551
Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 145a5969bd btrfs-progs: drop blocksize argument from readahead_tree_block
Tree blocks are always nodesize. As readahead is only an optimization,
exact size is not required and is only advisory.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 2030f49751 btrfs-progs: drop blocksize argument from btrfs_find_create_tree_block
Metadata blocks are always nodesize. When reading the
superblock::sys_array, the actual size of data is fixed to 4k and
smaller than nodesize, but otherwise everything works as before.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba d1b968dcba btrfs-progs: drop redundant check of blocksize in read_tree_block
The tree blocks are supposed to be always of nodesize. Before the
parameter has been dropped, it was unlikely but possible to pass a
misaligned value.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 819a496ded btrfs-progs: check: cleanup use of level_size
Nodesize is same for all levels, besides it's been only set and not
used, in root_item_record.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 98909c21d7 btrfs-progs: drop blocksize from read_tree_block
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 1fa9653dc8 btrfs-progs: drop local blocksize variables if they're nodesize
Prep work so we can drop the blocksize argument from several functions.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 5d8b645f6f btrfs-progs: build: fix PIE build
Patch from Marcus Meissner <meissner@suse.com>. The CFLAGS are passed to
the linker and mix up the compilation and linker flags for PIE support.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 1fe20f4c64 btrfs-progs: convert: move reiserfs struct definitions to header
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 4856215f51 btrfs-progs: convert: move and rename dev_t helpers to common file
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba c05c70c77c btrfs-progs: convert: move acl helper to common source file
There were 2 copies of ext2_acl_count and acl_ea_size.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00
David Sterba 385bbf35e2 btrfs-progs: convert: move duplicated acl code to common header
The ACL types and macros are same for both source filesystem.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-08 16:15:05 +02:00