Qu Wenruo [Fri, 29 Jan 2016 05:03:31 +0000 (13:03 +0800)]
btrfs-progs: convert: Strictly avoid meta or system chunk allocation
Before this patch, btrfs-convert only rely on large enough initial
system/metadata chunk size to ensure no newer system/meta chunk will be
created.
But that's not safe enough. So add two new members in fs_info,
avoid_sys/meta_chunk_alloc flags to prevent any newer system or meta
chunks to be created before init_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:30 +0000 (13:03 +0800)]
btrfs-progs: Convert: Add support for rollback new convert behavior
Add support to rollback new btrfs-convert.
The support is quite easy unlike the new convert behavior, which in fact
makes the rollback less restricted.
The core is, rollback must support both old and new convert result.
For old convert, all fs image extents can be covered by any chunk type.
But any extents inside reserved range must be covered by chunk.
For new convert, all fs image extents are covered by data chunk.
Allowing any condition will just make another fail to pass.
So make the convert condition a little less restricted to allow both can
be converted.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:29 +0000 (13:03 +0800)]
btrfs-progs: Introduce do_convert_v2 function
Introduce new function do_convert_v2() to do new convert.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ use __strncpy_null for label ]
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:28 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce init_btrfs_v2 function.
Introduce new init_btrfs_v2() function for later newer do_convert().
Since we have good enough chunk allocation, a lot of wired chunk hack
won't ever be used.
We only need to insert data chunks and create needed subvolume.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:27 +0000 (13:03 +0800)]
btrfs-progs: convert: Enhance record_file_blocks to handle reserved ranges
Enhance record_file_blocks() to handle reserved ranges.
Old file system can use the space in btrfs reserved ranges.
So we could not use the bytenr of old filesystem directly.
Thanks to previous patches, we have a full fs image in convert_root, and
it has already relocated the blocks in reserved ranges.
So here we just search the convert_root to get correct disk_bytenr and
use it.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:26 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce function to migrate reserved ranges
Introduce new function, migrate_reserved_ranges() to migrate used fs
data in btrfs reserved space.
Unlike old implementation, which will need to relocate all the
complicated csum and reference relocation, previous patches already
ensure such reserved ranges won't be allocated. So here we only need
copy these data out and create new extent/csum/reference.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:25 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce new function to create converted image
Use new function, create_convert_image_v2() to create snapshot of old
filesystem.
Unlike old function which is called after copying all inodes, this
function need to be called before copying inodes.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:24 +0000 (13:03 +0800)]
btrfs-progs: extent-tree: Enhance btrfs_record_file_extent
Btrfs_record_file_extent() has some small problems like:
1) Can't handle overlapping extents
2) May create extent larger than BTRFS_MAX_EXTENT_SIZE
So enhance it using previously added facilites.
This is used for later btrfs-convert, as for new convert, we create
saved image first, then copy inode.
Which will also cause extent overlapping.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:23 +0000 (13:03 +0800)]
btrfs-progs: extent-tree: Introduce function to find the first overlapping extent
Introduce a new function, btrfs_search_overlap_extent() to find the first
overlapping extent.
It's useful for later btrfs-convert rework.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:22 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to create convert data chunks
Introduce new function, make_convert_data_chunks(), to build up data
chunks for convert.
It will call a modified version of btrfs_alloc_data_chunk() to force
data chunks to covert all known ext* data.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:21 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to setup temporary extent tree
Introduce new function, setup_temporary_extent_tree() to build a
temporary extent tree for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:20 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to initialize csum tree
Introduce new function, setup_temp_csum_tree(), to setup temporary
csum tree for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:19 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to initialize fs tree
Introudce new function, setup_temp_fs_tree(), to setup temporary fs tree
for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:18 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to initialize device tree
Introduce new function, setup_temp_device_tree(), to setup temporary
device tree for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:17 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to setup temporary chunk root
Introduce new function, setup_temp_chunk_root(), to initialize temporary
chunk root for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:16 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to setup temporary tree root
Introduce new function, setup_temp_tree_root(), to initialize temporary
tree root for make_btrfs_v2().
The new function will setup tree root at metadata chunk and ensure data
won't be written into metadata chunk.
Also, new make_btrfs_v2() will have a much better code structure than
old make_btrfs().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:15 +0000 (13:03 +0800)]
btrfs-progs: Introduce function to setup temporary superblock
Introduce a new function, setup_temp_super(), to setup temporary super
for make_btrfs_v2().
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ use __strncpy_null in setup_temp_super ]
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:14 +0000 (13:03 +0800)]
btrfs-progs: utils: Introduce new function for convert
Introduce new function make_convert_btrfs() for convert.
This new function will have the following features:
1) Allocate temporary sb/metadata/system chunk, avoiding old used data
2) More structured functions
No more over 1000 lines function, better function split and code
reuse
This will finally replace current make_btrfs(), but now only used for
convert.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:13 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce function to calculate the available space
Introduce a new function, calculate_available_space() to get available
space cache_tree data_chunks cache_tree.
Unlike old implementation, this function will do the new work:
1) batch used ext* data space.
To ensure data chunks will recovery them all.
And restore the result into mkfs_cfg->convert_data_chunks for later
use.
2) avoid SB and reserved space at chunk level
Both batched data space or free space will not cover reserved space,
like SB or the first 1M.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:12 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce new function to remove reserved ranges
Introduce functions to remove reserved ranges for later btrfs-convert
rework.
The reserved ranges includes:
1. [0,1M)
2. [btrfs_sb_offset(1), +BTRFS_STRIPE_LEN)
3. [btrfs_sb_offset(2), +BTRFS_STRIPE_LEN)
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 29 Jan 2016 05:03:11 +0000 (13:03 +0800)]
btrfs-progs: convert: Introduce functions to read used space
Before we do real convert, we need to read and build up used space cache
tree for later data/meta separate chunk layout.
This patch will iterate all used blocks in ext2 filesystem and record it
into cctx->used cache tree, for later use.
This provides the very basic of later btrfs-convert rework.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Mon, 9 May 2016 04:46:46 +0000 (12:46 +0800)]
btrfs-progs: convert: add compatibility layer for e2fsprogs < 1.42
The new convert framework copies code from current dumpe2fs, which uses
BIGALLOC feature introduced in e2fsprogs v1.42.
While there are a lot of enterprise distributions which are still using
v1.41 e2fsprogs, this will cause compile error for them.
This patch introduces backward compatibility for new convert framework,
by manually introduce macros for ext2 BIGALLOC feature.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 15:08:43 +0000 (17:08 +0200)]
btrfs-progs: tests: 004-ext2-backup-superblock-ranges, use common helpers for image loop
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 14:52:57 +0000 (16:52 +0200)]
btrfs-progs: tests: 004-ext2-backup-superblock-ranges, drop unnecessary root privs
We really use root only for mount/umount and access to the ext2_saved
image (that has 0600). Also switch to common variable so we can use
helpers.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 14:01:51 +0000 (16:01 +0200)]
btrfs-progs: tests: unify test drivers
Remove unnecessary code, add exports to all common variables.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:54:32 +0000 (15:54 +0200)]
btrfs-progs: tests: convert: set common variables
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:46:39 +0000 (15:46 +0200)]
btrfs-progs: tests: clean up the test driver of convert tests
Everything is now in separate tests, and TEST=mask now works.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:37:25 +0000 (15:37 +0200)]
btrfs-progs: tests: convert: separate ext4 tests
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:37:25 +0000 (15:37 +0200)]
btrfs-progs: tests: convert: separate ext3 tests
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:37:25 +0000 (15:37 +0200)]
btrfs-progs: tests: convert: separate ext2 tests
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 3 Jun 2016 13:28:44 +0000 (15:28 +0200)]
btrfs-progs: tests: move convert helpers to a separate file
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 3 Jun 2016 02:34:26 +0000 (10:34 +0800)]
btrfs-progs: convert-tests: Add test case for backup superblock migration
New convert introduced simpler chunk/extent allocation algorithm, at the
cost of complex backup superblock migration codes.
Use specially built ext2 images to test if btrfs-convert can convert and
rollback images without problem.
All these special ext2 image have blocks/holes across 2nd btrfs backup
superblock.
The naming of test image is like the following:
|<------superblock migration range----->|
64M 64M + 64K
|-Data--|-Data--|/Hole//|-Data--|/Hole//|-Data--|--Data--| = drdhdhdrd
These test cases should check all typical layouts and make sure new
convert works.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Fri, 3 Jun 2016 02:34:25 +0000 (10:34 +0800)]
btrfs-progs: convert-tests: Add support for custom test scripts
Add support for custom convert test scripts, just like fsck tests.
Instead of generic convert tests, we need more specifically created images
for new convert tests.
This patch provide the needed infrastructure for later convert test
cases.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Thu, 2 Jun 2016 08:14:57 +0000 (17:14 +0900)]
btrfs-progs: btrfs-crc: make argc check more strict
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Thu, 2 Jun 2016 08:13:10 +0000 (17:13 +0900)]
btrfs-progs: btrfs-crc: improve usage message
- If -c is set, filename argument is ignored.
- Describe about -h option
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Thu, 2 Jun 2016 08:11:51 +0000 (17:11 +0900)]
btrfs-progs: btrfs-crc: print usage on receiving invalid arguments
Usage is only printed if -h option is set. However it's nice to
do it when wrong option is set or the number of argument is wrong.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Thu, 2 Jun 2016 08:10:18 +0000 (17:10 +0900)]
btrfs-progs: btrfs-crc should be ignored by git
It's a binary built from btrfs-crc.c
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Thu, 2 Jun 2016 08:06:37 +0000 (17:06 +0900)]
btrfs-progs: btrfs-crc: fix build error
Remove the following build error.
====================================
$ make btrfs-crc
[CC] btrfs-crc.o
[LD] btrfs-crc
btrfs-crc.o: In function `usage':
/home/sat/src/btrfs-progs/btrfs-crc.c:26: multiple definition of `usage'
help.o:/home/sat/src/btrfs-progs/help.c:125: first defined here
collect2: error: ld returned 1 exit status
Makefile:294: recipe for target 'btrfs-crc' failed
make: *** [btrfs-crc] Error 1
=====================================
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 2 Jun 2016 16:18:41 +0000 (18:18 +0200)]
btrfs-progs: use wider int type in btrfs_min_global_blk_rsv_size
We know nodesize should not overflow with the shift, but le'ts make the
code correct if the resulting type can store the full value.
Resolves-coverity-id: 1358120
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 26 May 2016 02:56:51 +0000 (10:56 +0800)]
btrfs-progs: Use new random number API
Replace old and not so informal srand()/rand() calls to new random
number API.
Including btrfs-corrupt-block(main user), btrfs-image and btrfs-crc.
Some tests like dir-test/random-test/quick-test is not modified.
As random-test itself can't even pass build.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 26 May 2016 02:56:50 +0000 (10:56 +0800)]
btrfs-progs: utils: Introduce new pseudo random API
David has reported some quite chaos usage of pseudo random numbers.
Like using static srand seed, or even calling rand() without setting
seed correctly.
The new pseudo random API will initialize the random seed on its first
calling and use uniformly distributed pseudo random number generator as
backend.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ renamed variables and functions, added prefixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 26 May 2016 02:36:02 +0000 (10:36 +0800)]
btrfs-progs: corrupt-block: Add support to corrupt extent for skinny metadata
For skinny metadata case, btrfs-corrupt-block can't corrupt a metadata
extent due to the type check missing BTRFS_METADATA_ITEM_KEY.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Wed, 1 Jun 2016 01:51:21 +0000 (09:51 +0800)]
btrfs-progs: convert-tests: Add test for backup superblock migration
New convert framework uses new and simpler chunk layout, while the cost
is the more complex superblock range migration logical, compared to old
convert.
Enhance the convert test script to create file which will takes up 2nd
backup superblock space, to ensure the superblock migration is working
as expected.
Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 1 Jun 2016 11:22:44 +0000 (13:22 +0200)]
btrfs-progs: tests: document cli-tests in readme
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 31 May 2016 17:17:02 +0000 (19:17 +0200)]
btrfs-progs: tests: convert: dump all superblocks after conversion
We want to see all of them, even if they're not valid.
Signed-off-by: David Sterba <dsterba@suse.com>
Lu Fengqi [Thu, 26 May 2016 09:43:00 +0000 (17:43 +0800)]
btrfs-progs: make btrfs-image restore to support dup
Previously btrfs-image restore would set the chunk items to have 1 stripe,
even if the chunk is dup. If you use btrfsck on the restored file system,
some dev_extent will not find any relative chunk stripe, and the
bytes-used of dev_item will not equal to the dev_extents's total_bytes.
This patch store a additional physical just for the dup case when build
the in-memory chunk-tree.
Currently btrfsck on the restored file system, only single and dup is no
problem. raid* support should be added in the future.
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 30 May 2016 15:11:19 +0000 (17:11 +0200)]
btrfs-progs: tests: run rollback after conversion
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 30 May 2016 15:07:35 +0000 (17:07 +0200)]
btrfs-progs: tests: convert, run md5sum with sudo helper
Some of the files might not end up in the checksum list because of
permissions. This is reported by md5sum as incorrectly formatted lines.
Signed-off-by: David Sterba <dsterba@suse.com>
Lu Fengqi [Mon, 30 May 2016 02:58:13 +0000 (10:58 +0800)]
btrfs-progs: tests: add 020-extent-ref-cases
In order to confirm that btrfsck supports to check a variety of
refs, add the
following cases:
* keyed_block_ref
* keyed_data_ref
* shared_block_ref
* shared_data_ref
* no_inline_ref (a extent item without inline ref)
* no_skinny_ref
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Merlin Hartley [Thu, 19 May 2016 14:17:24 +0000 (15:17 +0100)]
btrfs-progs: doc: fix typo in btrfs-subvolume
Signed-off-by: Merlin Hartley <merlinhartley@hotmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 20 May 2016 11:39:02 +0000 (13:39 +0200)]
btrfs-progs: switch to common message helpers in utils.c
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 20 May 2016 11:20:28 +0000 (13:20 +0200)]
btrfs-progs: fix type mismatch in backtrace dumping functions
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 20 May 2016 11:09:17 +0000 (13:09 +0200)]
btrfs-progs: drop O_CREATE from open_ctree_fs_info
We stat the filesystem path before trying to open it so there's no point
to pass O_CREAT ("btrfs-progs: add stat check in open_ctree_fs_info").
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 May 2016 02:54:39 +0000 (10:54 +0800)]
btrfs-progs: Return earlier for previous item
Follow kernel code to return earlier for btrfs_previous_item() function.
Before this patch, btrfs_previous_item() doesn't use its min_objectid to
exit, this makes caller to check key to exit, and if caller doesn't
check, it will iterate all previous item.
This patch will check min_objectid and type, to early return and save
some time.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Thu, 19 May 2016 08:44:35 +0000 (16:44 +0800)]
btrfs-progs: Enhance tree block check by checking empty leaf or node
For btrfs, it's possible to have empty leaf, but empty node is not
possible.
Add check for empty node for tree blocks.
Suggested-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 19 May 2016 12:20:51 +0000 (14:20 +0200)]
btrfs-progs: makefile: add target for testing installation
Signed-off-by: David Sterba <dsterba@suse.com>
Anand Jain [Thu, 19 May 2016 05:13:14 +0000 (13:13 +0800)]
btrfs-progs: clean up commands.h
This function is declared in utils.h so remove it from commands.h int
test_issubvolume(const char *path);
This function does not exists delete the declaration
get_subvol_name(char *mnt, char *full_path);
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Anand Jain [Thu, 19 May 2016 05:13:13 +0000 (13:13 +0800)]
btrfs-progs: makefile: add clean-all to the usage
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 17 May 2016 14:21:00 +0000 (16:21 +0200)]
btrfs-progs: device usage: report slack space
The total filesystem space on a given device might be smaller than the
device size. We should report that space as well. The original idea was
to report the 'occupied' size but the term was not all clear, so the
logic was reversed to report the slack space.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 17 May 2016 14:13:44 +0000 (16:13 +0200)]
btrfs-progs: docs: compression is disabled with nodatasum/nodatacow
Explicitly mention the constraints in all involved options.
Signed-off-by: David Sterba <dsterba@suse.com>
Zhao Lei [Fri, 13 May 2016 03:44:52 +0000 (11:44 +0800)]
btrfs-progs: autogen: Make build success in CentOS 6 and 7
btrfs-progs build failed in CentOS 6 and 7:
#./autogen.sh
...
configure.ac:131: error: possibly undefined macro: PKG_CHECK_VAR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
...
Seems PKG_CHECK_VAR is new in pkgconfig 0.28 (24-Jan-2013):
http://redmine.audacious-media-player.org/boards/1/topics/736
And the max available version for CentOS 7 in yum-repo and
rpmfind.net is: pkgconfig-0.27.1-4.el7
http://rpmfind.net/linux/rpm2html/search.php?query=pkgconfig&submit=Search+...&system=centos&arch=
I updated my pkgconfig to 0.30, but still failed at above error.
(Maybe it is my setting problem)
To make user in centos 6 and 7 building btrfs-progs without
more changes, we can avoid using PKG_CHECK_VAR in following
way found in:
https://github.com/audacious-media-player/audacious-plugins/commit/
f95ab6f939ecf0d9232b3165f9241d2ea9676b9e
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Zhao Lei [Fri, 13 May 2016 03:44:53 +0000 (11:44 +0800)]
btrfs-progs: autogen: Don't show success message on fail
When autogen.sh failed, the success message is still in output:
# ./autogen.sh
...
configure.ac:131: error: possibly undefined macro: PKG_CHECK_VAR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
Now type './configure' and 'make' to compile.
#
Fixed by check return value of autoconf.
After patch:
# ./autogen.sh
...
configure.ac:132: error: possibly undefined macro: PKG_CHECK_VAR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
#
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Zhao Lei [Fri, 13 May 2016 03:44:51 +0000 (11:44 +0800)]
btrfs-progs: autogen: Avoid chdir fail on dirname with blank
If source put in dir with blanks, as:
/var/lib/jenkins/workspace/btrfs progs
autogen will failed:
./autogen.sh: line 95: cd: /var/lib/jenkins/workspace/btrfs: No such file or directory
Can be fixed by adding quotes into cd command.
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
M G Berberich [Thu, 12 May 2016 19:49:25 +0000 (21:49 +0200)]
btrfs-progs: send: add quiet option
Add new options -q,--quiet to prevent printing messages on stderr, added
--verbose as alternative for -v. Moved 'Mode NO_FILE_DATA enabled'
message to stderr. The default verboisty level is 1 to keep some
backward compatibility.
Signed-off-by: M G Berberich <btrfs@oss.m-berberich.de>
[ minor adjustments in the options, help text and changelog, added
manual page text ]
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Thu, 12 May 2016 12:13:30 +0000 (14:13 +0200)]
btrfs-progs: build: add support for debugging builds
Add an easy way to build a debugging version, without optimizations and
with debugging info by default. Any overrides can be done via
DEBUG_CFLAGS that are added on top of the defaults. Can be combined with
V, C or W options.
Usage:
$ make D=1
Signed-off-by: David Sterba <dsterba@suse.com>
Nicholas D Steeves [Wed, 11 May 2016 23:50:36 +0000 (19:50 -0400)]
btrfs-progs: typo review of strings and comments
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Jeff Mahoney [Mon, 9 May 2016 15:44:26 +0000 (11:44 -0400)]
btrfs-progs: udev: add rules for dm devices
Systemd's btrfs rule runs btrfs dev ready on each device
as it's discovered. The btrfs command is executed as a builtin
command via an IMPORT{builtin} rule, which means it gets
executed at rule evaluation time, not rule execution time. That
means that the device mapper links haven't been setup yet and the only
nodes that can be depended upon are /dev/dm-#. That we see
/dev/mapper/name names in /proc/mounts is only because we replace the
device name we have cached with the one passed in via mount. If
we have a multi-device file system and the primary device is removed,
the remaining devices will show /dev/dm-#. In addition, if the
udev rule is executed again by someone generating a change event (e.g.
partprobe), the names are also replaced by the /dev/dm-# names.
This patch adds a new rule that adds a run rule that calls btrfs dev
ready again using the device mapper links once they're created.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Mon, 9 May 2016 07:52:11 +0000 (16:52 +0900)]
btrfs-progs: prop: remove conditions which never be satisfied
parse_args() always set at least one parameter, 'object', for
{get,list} subcommands. In addition, it always set all three
parameters, 'object', 'name', and 'value' for set subcommand.
So the following conditions can be removed.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Mon, 9 May 2016 07:49:19 +0000 (16:49 +0900)]
btrfs-progs: prop: simplify parse_args()
Since <object> parameter is mandatory for all subcommands,
'object' is always set by parse_args()'s callers.
In addition, on setting '*name' and '*value', if 'optind < argc'
is satisfied here, they are always set by parse_args()'s callers.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Wed, 11 May 2016 14:40:33 +0000 (16:40 +0200)]
Btrfs progs v4.5.3
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 13:32:02 +0000 (15:32 +0200)]
btrfs-progs: update CHANGES for 4.5.3
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Mon, 2 May 2016 18:18:55 +0000 (11:18 -0700)]
btrfs-progs: add fuzzed testing images, superblock and chunks
This adds 4 fuzz testing images, btrfsck either doesn't detect errors
in them or crashes immediately.
Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Wed, 11 May 2016 13:40:38 +0000 (15:40 +0200)]
btrfs-progs: replace printf with message helpers in check_super
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Wed, 11 May 2016 13:40:07 +0000 (15:40 +0200)]
btrfs-progs: add three more validation checks for superblock
This adds validation checks for super_total_bytes, super_bytes_used and
super_stripesize.
Since these checks are made after superblock finishes checksum
checking, this also adds a notice of "superblock checksum matches but..".
Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
[ adjusted message wording ]
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Mon, 2 May 2016 18:18:53 +0000 (11:18 -0700)]
btrfs-progs: add validation checks for chunk loading
To survive fuzz filesystem images, we need various validation checks to
make btrfsck detect any invalid value inside chunks including those in
sys_array.
Note that these checks may not be sufficient to cover all corner cases,
we may need to add more later.
This also refractor previous various checks into a helper function so
that we can add more checks into it in the future.
Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Reported-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Satoru Takeuchi [Mon, 9 May 2016 07:20:01 +0000 (16:20 +0900)]
btrfs-progs: prop: convert error messages to use error()
props.c uses 'fprintf(stderr, "ERROR: ...")' as its error messages,
however we have generic error() function.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 15:56:51 +0000 (17:56 +0200)]
btrfs-progs: docs: clarify why mkfs selects single for SSDs
The section raised some user questions on IRC.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 12:45:57 +0000 (14:45 +0200)]
btrfs-progs: docs: update btrfs-check
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 11:28:17 +0000 (13:28 +0200)]
btrfs-progs: docs: update btrfs-select-super
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 11:12:42 +0000 (13:12 +0200)]
btrfs-progs: docs: update btrfs-receive
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 10:59:47 +0000 (12:59 +0200)]
btrfs-progs: docs: update btrfs-send
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 10:42:21 +0000 (12:42 +0200)]
btrfs-progs: docs: update btrfs-scrub
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 6 May 2016 10:27:31 +0000 (12:27 +0200)]
btrfs-progs: docs: update btrfs-man5
Wording, added new options.
Signed-off-by: David Sterba <dsterba@suse.com>
Noah Massey [Wed, 4 May 2016 19:43:26 +0000 (15:43 -0400)]
btrfs-progs: Adjust timing of safety delay countdown
When printing the countdown in the safety delay, the number should
correspond to the number of seconds remaining to wait at the time the
delay is printed.
In other words, there should be a one second sleep after printing '1'.
Signed-off-by: Noah Massey <noah.massey@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Marek Rusinowski [Wed, 4 May 2016 13:36:35 +0000 (15:36 +0200)]
btrfs-progs: subvolume sync: fix handling of -s option
Setting check interval for subvolume sync resulted
in picking wrong element from argv for it's value:
$ btrfs subvolume sync -s 10 ./dir
ERROR: invalid sleep interval ./dir
$ btrfs subvolume sync ./dir -s 10
Segmentation fault
Signed-off-by: Marek Rusinowski <marekrusinowski@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Liu Bo [Mon, 2 May 2016 18:13:20 +0000 (11:13 -0700)]
btrfs-progs: fix incorrect flag check while recovering super
The flag OPEN_CTREE_RECOVER_SUPER is set when it's going to recover
any bad superblock copy, the current code doesn't match that.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 3 May 2016 14:20:52 +0000 (16:20 +0200)]
btrfs-progs: use ioctl search headers everywhere
Generated by following semantic patch and manually tweaked.
<SmPL>
@@
struct btrfs_ioctl_search_header *SH;
@@
(
- SH->objectid
+ btrfs_search_header_objectid(SH)
|
- SH->offset
+ btrfs_search_header_offset(SH)
|
- SH->transid
+ btrfs_search_header_transid(SH)
|
- SH->len
+ btrfs_search_header_len(SH)
|
- SH->type
+ btrfs_search_header_type(SH)
)
</SmPL>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=112131
Reported-and-tested-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 3 May 2016 14:00:05 +0000 (16:00 +0200)]
btrfs-progs: add getters for ioctl search_header
The search header is usually accessed in an unaligned way, we could
trigger errors (SIGBUS) on architectures that do not support that.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Tue, 3 May 2016 13:59:45 +0000 (15:59 +0200)]
btrfs-progs: kerncompat: introduce get_unaligned helpers
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 16:29:26 +0000 (18:29 +0200)]
btrfs-progs: fi du: switch to negative error codes
We're using the kernel-style negative error numbers.
Signed-off-by: David Sterba <dsterba@suse.com>
Qu Wenruo [Tue, 26 Apr 2016 02:49:49 +0000 (10:49 +0800)]
btrfs-progs: check: fix found bytes accounting error
In the new add_extent_rec_nolookup() function, we add bytes_used to
update found bytes accounting.
However there is a typo that we used tmpl->nr, which should be rec->nr.
This will make us to add 1 for data backref, instead the correct size.
Reported-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 4 Apr 2016 11:15:46 +0000 (13:15 +0200)]
btrfs-progs: check: check stripe crossing against nodesize
The extent record's max_size might be 0 and the stripe crossing check
will report a false positive, should use the filesyste nodesize. There's
a global fs_info available.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 1 Apr 2016 15:46:10 +0000 (17:46 +0200)]
btrfs-progs: check: refactor add_extent_rec, reduce argument count
Similar to add_extent_rec_nolookup, pass the arguments via a temporary
structure. In case the extent is found, some of the values are not
assigned directly so the semantics is preserved.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 1 Apr 2016 15:08:51 +0000 (17:08 +0200)]
btrfs-progs: check: reduce size of extent_record
There are just 3 values of flag_block_full_backref, we can utilize a
bitfield and save 8 bytes (192 now).
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 1 Apr 2016 14:07:56 +0000 (16:07 +0200)]
btrfs-progs: check: simplify assignments in add_extent_rec_nolookup
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Fri, 1 Apr 2016 13:47:01 +0000 (15:47 +0200)]
btrfs-progs: check: pass a template to add_extent_rec_nolookup
Reduce number of parameters that just fill the extent_record from a
temporary template that's supposed to be zeroed and filled by the
callers.
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 13:34:39 +0000 (15:34 +0200)]
Btrfs progs v4.5.2
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 13:32:02 +0000 (15:32 +0200)]
btrfs-progs: update CHANGES for 4.5.2
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 13:03:24 +0000 (15:03 +0200)]
btrfs-progs: handle memory allocation error in cmd_device_stats
Resolves-coverity-id: 1359012
Signed-off-by: David Sterba <dsterba@suse.com>
David Sterba [Mon, 2 May 2016 12:59:48 +0000 (14:59 +0200)]
btrfs-progs: tests: add 002-balance-full-no-filters
Coverage of new balance option --full-balance.
Signed-off-by: David Sterba <dsterba@suse.com>