Commit Graph

2973 Commits (6f306e8d62f8cca23fcb3aa56b3594d1ac531359)
 

Author SHA1 Message Date
David Sterba 6f306e8d62 btrfs-progs: tests: make the ioctl-test actually useful
Enhance the test to verify ioctl uniqueness, compare the defined values
against the hardcoded expected values, and take care of the 32bit/64bit
compatibility workarounds.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:57:19 +02:00
David Sterba 32a168684e btrfs-progs: ioctl: add 64bit compat for SEND
The ioctl value of SEND will be different on 32bit userspace and 64bit
kernel due to different pointer type width, that unfortunatelly made it
into the structure definition.

To maintain backward compatibility, we must do it in the 64bit->32bit
way, because we don't have the kernel side workardound like
SET_RECEIVED_SUBVOL has.  Changing value of SEND would then break
existing users of the raw ioctl.

The compatibility structure and ioctl should not be used, exists for
documentation, and testing.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:57:02 +02:00
David Sterba bbda9a2892 btrfs-progs: ioctl: add 32bit compat for SET_RECEIVED_SUBVOL
The ioctl value of SET_RECEIVED_SUBVOL will be different on 32bit
userspace and 64bit kernel. This is transparently handled on the kernel
side. We now define the same structure so we can verify the ioctl value.

The defined structure and ioctl should not be used. It is exists only
for testing purposes, documenting the mess and as a warning for the
future.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-24 14:56:40 +02:00
David Sterba d8d0a60406
Btrfs progs v4.8.1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-12 15:20:29 +02:00
David Sterba 483d0a55cb btrfs-progs: update CHANGES for v4.8.1
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-12 15:19:50 +02:00
David Sterba 5aade6f9c3 btrfs-progs: ioctl: make build-time structure size checks optional
Temporarily make the build checks optional. The structure sizes could
change on arches due to alignment requirements or padding inserted into
the structures. We need more extensive tests to make sure we'd not break
ioctls.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 10:11:31 +02:00
David Sterba 805ac27248 btrfs-progs: fix printf format of sizeof on 32bit build
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:54 +02:00
David Sterba ba253d4ea5 btrfs-progs: tests: add script to help build coverage
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:51 +02:00
Qu Wenruo bb5bcb8a4a btrfs-progs: Fix warning_trace compile error if backtrace is disabled
If we disable backtrace, btrfs-progs can't be compiled since we don't
have warning_trace defined.

Fix by move it out of #ifndef BTRFS_DISABLE_BACKTRACE block.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ move warning_trace to the right place ]
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:42 +02:00
David Sterba 01ddfdbbcb btrfs-progs: build: add explicit option separator to rm commands
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-10 09:46:24 +02:00
David Sterba 81f4d96f3d
Btrfs progs v4.8
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:47:51 +02:00
David Sterba 5a8f85d837 btrfs-progs: update CHANGES for v4.8
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:42:20 +02:00
David Sterba 64b195d34f btrfs-progs: add build-time checks for size of ioctl structures
All structures that become part of ioctl definition must never change
size. Add the build time checks for that.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba a288d6dafc btrfs-progs: mkfs: fix warning for printf format on 32bit
Compiler complains about nlink_t and %ld format on 32bit build. Add
typecast and fix the format.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba c8d9f05cec btrfs-progs: kerncompat: add build-time assertion support
Macro to verify compile-time conditions, like sie of structures or
types.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba eae42a1fe4 btrfs-progs: build: add alias for check tests
$ make test-check"

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba dabfc65124 btrfs-progs: kerncompat: call abort at the end of assert_trace
The assert* helpers should not exit normally, mimick the behaviour of
the std library assert.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 26619538da btrfs-progs: kerncompat: make WARN_ON more verbose
Curretnly WARN_ON would crash but that's not it's purpose. Add helper
that prints the warning, optionally with trace.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba a08ca376f7 btrfs-progs: tests: teach run_mayfail about sigabrt
Mayfail helper should stop when we encoutner an abort.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 942dc5f29d btrfs-progs: dump-super: print chunks after validation
The fuzz test 005-simple-dump-super hits a crash, because we print the
chunks too early.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba d27c586c5b btrfs-progs: convert: add new callback to check state
Make the hardcoded ext2 call to a generic per-fs callback.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 5e96864dfd btrfs-progs: rename __setup_root and change to return void
Exported function should use a prefix.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba b6bf79eb96 btrfs-progs: tests: don't treat segfault as ignorable error
Some fuzzed images cause various tools to crash but the mayfail helper
would not recognize that. We don't mind if the utility failes but it
must not crash.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba a5ac954153 btrfs-progs: tests: split test 004 to separate tests
Makes testing specific tool easier.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba ea0fd88b5a btrfs-progs: don't access freed memory in btrfs_close_devices
Caught by ASAN, as we don't access fs_devices directly, there's no null
deref but 0x30 is still wrong.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 61d5425fd3 btrfs-progs: chunk-recover: handle duplicate cache entries
Triggered by fuzzed image bko-155621-bad-block-group-offset.raw .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 9adce1abe4 btrfs-progs: print value when assertion fails
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba db64e0a636 btrfs-progs: image: drop useless bug_on
The callers touch 'target', no point checking it inside restore_metadump
again.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:01 +02:00
David Sterba 9287b8630c btrfs-progs: image: return negativer error from all paths in mdrestore_init
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-05 12:39:00 +02:00
David Sterba 3956c16d0b btrfs-progs: image: catch zero length extents, avoid endless loop
If an extent is found to have length 0, we'd loop endlessly in
copy_from_extent_tree. Reproduced by fuzzed image
bko-166361-blocksize-zero.raw within test 002-simple-image .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 35d0588b64 btrfs-progs: tests: add fuzzed image with bad parent refs, qgroup-verify
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba d89205c4a5 btrfs-progs: check: better error handling in find_parent_roots
Fix use-before-sanity-check leading to undefined behaviour and handle
errors more gracefully.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156811
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 801f15bdf1 btrfs-progs: tests: add fuzzed images with bad blocksize/lengh of eb
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 6cca2ea9be btrfs-progs: more sanity checks in read_tree_block_fs_info
If blocksize is 0, it passes the IS_ALIGNED check but fails later as the
length of ebs will be zero.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=169311
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba 14de259f1f btrfs-progs: btrfstune: use common message helpers
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:24 +02:00
David Sterba f446c027ca btrfs-progs: image: use common message helpers
Usage errors are turned to normal errors.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
Qu Wenruo b2fbec8be1 btrfs-progs: Remove unnecessary parameter to clear_extent_uptodate
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
Qu Wenruo 7c646c538e btrfs-progs: qgroup: Fix regression leads to corrupted qgroup status
Commit 93dabf211d
Author: Mark Fasheh <mfasheh@suse.de>
Date:   Fri Jun 17 13:37:48 2016 -0700

    btrfs-progs: check: verify qgroups above level 0

This commit introduced a new regression which corrupts
read_qgroup_status, since it iterate leaf with manually specified slot,
not correct path->slot[0].

This leads to wrong slot[0] and read_qgroup_status() will read out wrong
flags, leading to regression.

Fix read_qgroup_status() by using eb and slot instread of wrong path
strucutre.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Cc: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
David Sterba 85d608f7ec btrfs-progs: constify string arguments where appropriate
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
David Sterba 9fcdf8f894 btrfs-progs: don't write to optarg in btrfs_qgroup_parse_sort_string
Dup the string that gets passed to strtok so we don't destroy callers
buffer.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
David Sterba 2761c37d25 btrfs-progs: remove stray function declaration
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:23 +02:00
David Sterba 6c5d2a7f6f btrfs-progs: restore: update help text
Make it clear that --xattr restores the xattrs. Fix some whitespace
damage and add an enum for the long-only option.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
Qu Wenruo 3296d058b7 btrfs-progs: super-recover: Reuse btrfs_read_dev_super function
We have enhanced super block validation check in disk_io.c, while
super-recover doesn't use that function and use a custom one.

That is duplicated, so reuse btrfs_read_dev_super to handle it, which
not only enhanced super check, but also reduce the code length.

Reported-by: hawken <hawken@thehawken.org>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
Qu Wenruo 50c8c995ea btrfs-progs: Return more meaningful value for btrfs_read_deve_super
btrfs_read_dev_super() only returns 0 or -1, which doesn't really help,
caller won't know if it's caused by bad superblock or superblock out of
range.

Return -errno if pread64() return -1, and return -EOF if none or part of
the super is read out, and return what check_super() returned.

So caller can get -EIO to catch real corrupted super blocks.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
Nicholas D Steeves 6bdb1cfbc1 btrfs-progs: fix user-facing typos in docs and help strings
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
Adam Borowski aa8ad8d4ae btrfs-progs: docs: document exit codes from scrub
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
David Sterba 1200be31e6 btrfs-progs: move 3rd party kernel library modules to own directory
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:22 +02:00
David Sterba 605ed50b8c btrfs-progs: build: add basic support for subdirectory build
Add explicit target file names and set the top source directory.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00
David Sterba 8d8de7c2e5 btrfs-progs: tests: add script to scan results for some known runtime errors
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00
David Sterba 5a38a52194 btrfs-progs: tests: iterate over fuzzed images and test various tools
Signed-off-by: David Sterba <dsterba@suse.com>
2016-10-03 15:07:21 +02:00