summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: check: Drop ext_ref argument from check_inode_itemNikolay Borisov2018-06-07
| | | | | | | | | We can derive this argument from root->fs_info and also make it local to the sole switch case it's used. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref param from check_dir_itemNikolay Borisov2018-06-07
| | | | | | | | This parameter is no longer used in this function, so drop it Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Drop ext_ref parameter from find_inode_refNikolay Borisov2018-06-07
| | | | | | | | | | This is a boolean parameter which signals whether the fs has the EXTENDED_IREF feature flag toggled or not. Since a reference to fs_info can be obtained there is no need to pollute the interface. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test for collision DIR_ITEM handlingNikolay Borisov2018-06-07
| | | | | | | | | | | | | | Verify that if we have an otherwise clean filesystem, containging collided DIR_ITEM, btrfs check lowmem's mode can correctly handle those and not produce any false positives. This if fixed by commit titled: "btrfs-progs: check: fix DIR_ITEM checking in lowmem" Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: fix DIR_ITEM checking in lowmemNikolay Borisov2018-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When checking the validity of a DIR_ITEM item the index variable is explicitly set to -1 so that the index check in find_inode_ref() is ignored. This is necessary due to possible name collisions in DIR_ITEMS (i.e. multiple files with the same crc32c for their names, resulting in the identical key->offset). Currently the code is broken due to index being set to -1 at the beginning of check_dir_item and subsequently reset to the index found in find_inode_ref. On subsequent iterations of the while loop in check_dir_items we are going to erroneously perform index checking, since index is not -1 but whatever the index value of the last handled INODE_REF ITEM. Without this patch check in lowmem mode produces the following false warnings positivess: ERROR: root 5 INODE REF[1991456, 256] name 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK filetype 1 missing But the items for this name are in fact correct: ------------------SNIP------------------------ item 13 key (256 DIR_ITEM 4227063046) itemoff 2945 itemsize 140 location key (220890 INODE_ITEM 0) type FILE transid 2278 data_len 0 name_len 40 name: 5ab4e1bb~~~~~~~~65KNTAWVJ5VD4SV2R3BKFCXL location key (1991456 INODE_ITEM 0) type FILE transid 2285 data_len 0 name_len 40 name: 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK item 21 key (1991456 INODE_REF 256) itemoff 2104 itemsize 50 index 1934146 namelen 40 name: 5ab4e28b~~~~~~~~QBXUT2GBJDRT5CB6ZWAJVDHK -------------------SNIP------------------------- Fix this by moving the code setting index at the beginning of the while loop. This ensure that for each item in DIR_ITEM we have index set correctly. Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()") Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case to ensure btrfs check returns error for ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | corrupted qgroups Since the test case uses run_mustfail(), which is pretty easy pass due to other unexpected problems, so here an extra run_check() is added to ensure we don't only report qgroup error, but also fix it without problem. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Make btrfs check return error for qgroup mismatchQu Wenruo2018-06-07
| | | | | | | | | | | | | | | Current btrfs-check will check qgroup consistency, but even when it finds something wrong, the return value is still 0. Fix it by allowing report_qgroups() to return int to indicate qgroup mismatch, and also add extra logic to return no error if qgroup repair is successful. Without this patch, fstests can't detect qgroup corruption by its fsck alone. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use exclude_super_stripes instead of account_super_bytesNikolay Borisov2018-06-07
| | | | | | | | | | | | | | | | | | Originally commit 2681e00f00fe ("btrfs-progs: check for matchingi free space in cache") added the account_super_bytes function to prevent false negative when running btrfs check. Turns out this function is really copied exclude_super_stripes, excluding the calls to exclude_super_stripes. Later commit e4797df6a9fa ("btrfs-progs: check the free space tree in btrfsck") introduced proper version of exclude_super_stripes. Instead of duplicating the function, just remove account_super_bytes and use exclude_super_stripes instead of the former. This also has the benefit of bringing the userspace code a bit closer to the kernel counterpart. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: check btrfs qgroup parent-child relation outputLu Fengqi2018-06-07
| | | | | | | | | | | Since commit aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments") cause qgroup show to output the wrong qgroup parent-child relationship, in addition to fixing the problem, a test case is needed to prevent the similar problem in the future. Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: qgroup: swap the argument in the caller of update_qgroup_relationLu Fengqi2018-06-07
| | | | | | | | | | | | | | | The QGROUP_RELATION item is very special, it always exists in pairs (with objectid and offset exchanged). Its objectid and offset are the ids of a pair of parent and child qgroups, respectively. The larger one is parent and the smaller one is child. After the following commit, the order of the parameters is wrong and causes qgroup show to output the wrong qgroup parent-child relationship. Fixes: aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to reduce arguments") Issue: #129 Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case for dump-tree on heavily corrupted leafQu Wenruo2018-06-07
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: Avoid segfault for heavily corrupted item pointersQu Wenruo2018-06-07
| | | | | | | | | | | | | | | | | | | | | Normally corrupted leaf should be caught by csum check, but sometimes corrupted item pointers (out of leaf range) can still pass csum check. In fact, our fsck/005 test case image has such corrupted item pointer and btrfs check can surprisingly fix it. Anyway, make print-tree to skip such item and remaining slots to avoid segfault. Please note that, in btrfs-progs we can't put such check into check_tree_block() nor do kernel level comprehensive check as under certain case, btrfs-progs can handle or even repair it. A strict check_tree_block() or backporting kernel btrfs_check_leaf() could break such test cases and reduce the utility of btrfs-progs. Issue: #128 Reported-by: Hubert Kario <hubert@kario.pl> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove objectid argument from alloc_cache_extentNikolay Borisov2018-06-07
| | | | | | | | | | This function is always called with objectid set to 0. So remove the parameter and statically set the ->objectid to 0 when allocating a new extent. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove add_cache_extent2Nikolay Borisov2018-06-07
| | | | | | | | | | | | | | Commit 17793e3e6a49 ("Btrfs-progs: extend the extent cache for the device extent") extended the cache extent APIs to support objectid to distinguish between phyisical extents with same dimensions but on different devices. However, it seems that this particular function is not used to allocate a device extent with accompanying objectid. Instead such extents as processed solely by insert_device_extent_record. Remove the unused code as a result. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove devid parameter from btrfs_rmap_blockNikolay Borisov2018-06-07
| | | | | | | | | This parameter was introduced with the original implementation of the function but has never really been used, so just remove it. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: update log markersDavid Sterba2018-06-07
| | | | | | | Use visual markers that separate tests and individual commands run via the run_* helpers. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: add image with no extent with normal device sizeSu Yue2018-06-07
| | | | | | | | | | | | | | This new image misses one extent which leads lowmem mode to allocate new chunks in repair. Rename original image to no_extent_bad_dev.img. Because of its bad used bytes, it should let lowmem mode exclude blocks in repair. Due to problems of btrfs-image, choose xz as compression tool. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: end of removing parameters @trans in lowmemSu Yue2018-06-07
| | | | | | | | | Remove @trans in check_chunks_and_extents_lowmem(). After this patch, lowmem repair works again. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: introduce repair_block_accountingSu Yue2018-06-07
| | | | | | | | | | | | | | Introduce repair_block_accounting() which calls btrfs_fix_block_accounting() to repair block group accouting. Replace btrfs_fix_block_accounting() with the new function. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of check_btrfs_rootSu Yue2018-06-07
| | | | | | | | | | | Remove parameters @trans of delete_extent_item() and walk_down_tree_v2(). Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of repair_tree_back_refSu Yue2018-06-07
| | | | | | | | | | | | | This patch removes parameter @trans of repair_tree_back_ref(). It calls try_avoid_extents_overwrite() and starts a transaction by itself. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of check_leaf_itemsSu Yue2018-06-07
| | | | | | | | | | | This patch removes parameter @trans of check_leaf_items(). Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of repair_extent_itemSu Yue2018-06-07
| | | | | | | | | | | | | This patch removes parameter @trans of repair_extent_item(). It calls try_avoid_extents_overwrite() and starts a transaction by itself. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of repair_chunk_itemSu Yue2018-06-07
| | | | | | | | | | | | | This patch removes parameter @trans of repair_chunk_item(). It calls try_avoid_extents_overwrite() and starts a transaction by itself. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: remove parameter @trans of delete_extent_itemSu Yue2018-06-07
| | | | | | | | | | | | | This patch removes the parameter @trans of delete_extent_item(). It calls try_avoid_extents_overwrite() and starts a transaction by itself. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: start to remove parameters @trans in lowmemSu Yue2018-06-07
| | | | | | | | | | | | | | | | Since extents can be avoided to be overwrittten by excluding or chunk allocation. It's not necessary to do all repairs in one transaction. This patch removes parameter @trans of repair_extent_data_item(). repair_extent_data_item() calls try_avoid_extents_overwrite() and starts a transaction by itself. Note: This patch and next patches cause error in lowmem repair like: "Error: Commit_root already set when starting transaction". Such error will disappear after removing @trans finished. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: exclude extents if init-extent-tree in lowmemSu Yue2018-06-07
| | | | | | | | | | | | | If options '--init-extent-tree' and '--mode=lowmem' are both input, all metadata blocks will be traversed twice. First one is done by pin_metadata_blocks() in reinit_extent_tree(). Second one is in check_chunks_and_extents_v2(). Excluding instead of pinning metadata blocks before reinitializing th extent tree in lowmem can save some time. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: introduce avoid_extents_overwriteSu Yue2018-06-07
| | | | | | | | | | | | | | Declare a global u64 variable last_allocated_chunk records start of the last chunk allocated by lowmem repair. Although global variable is not nice, it simplifies the code a lot. avoid_extents_overwrite() prefers to allocate a new chunk first. If it failed because of no space or wrong used bytes (like in fsck-tests/004), then it tries to exclude metadata blocks which costs a lot of time in large filesystems. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: introduce try_force_cow_in_new_chunkSu Yue2018-06-07
| | | | | | | | | | | | | | | | | | | | | Introduce create_chunk_and_block_block_group() to allocate a new chunk and corresponding block group. The new function force_cow_in_new_chunk() firstly allocates new chunk and records its start. Then it modifies all metadata block groups cached and full. Finally it marks the new block group uncached and unfree. In the next COW, extents states will be updated automatically by cache_block_group(). New function try_to_force_cow_in_new_chunk() will try to mark block groups full, allocate a new chunk and records the start. If the last allocated chunk is almost full, a new chunk will be allocated. Suggested-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: introduce mark/clear_block_groups_fullSu Yue2018-06-07
| | | | | | | | | | | | | | | | Excluding or pining all metadata blocks is time-inefficient for large filesystems. Here is another way to mark all metadata block groups full and allocate new chunks for COW. Then new reserved extents never overwrite extents. Introduce modify_block_groups_cache() to modify all blocks groups cache state and set all extents in block groups unfree in free space cache. mark/clear_block_groups_full() are wrappers of above function. Suggested-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: exclude extents of metadata blocksSu Yue2018-06-07
| | | | | | | | | | | | | | | | | | | | Commit d17d6663c99c ("btrfs-progs: lowmem check: Fix regression which screws up extent allocator") removes pin_metadata_blocks() from lowmem repair. So we have to find another way to exclude extents which should be occupied by existing tree blocks. Modify pin_down_tree_blocks() and rename it to traverse_tree_blocks for sharing code with new function exclude_metadata_blocks(). * exclude_metadata_blocks() traverses and marks extents of all tree blocks dirty in fs_info->excluded_extents. * cleanup_excluded_extents() is responsible for cleanup. Export them to mode-common.h since they will be used both in original and lowmem modes. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: move pin_down_tree_blocks to mode-common.cSu Yue2018-06-07
| | | | | | | | | Move pin_down_tree_blocks from main.c to mode-common.c for further patches. And export pin_metadata_blocks to mode-common.h. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Distinguish csum checking output for --check-data-csumQu Wenruo2018-06-07
| | | | | | | | | | | No matter --check-data-csum is passed or not, btrfs check will always output message like "checking csum". This message could be a little confusing, change it according to --check-data-csum option. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Continue check even if csum error is foundQu Wenruo2018-06-07
| | | | | | | | Since data csum mismatch is not a fatal error compared to fs/extent trees, continue check. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Fix data csum check return valueQu Wenruo2018-06-07
| | | | | | | | | | When --check-data-csum option found csum mismatch, btrfs check still return 0. Fix it so log-replay could automatically pause when it finds csum error. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Check data csum for all copiesQu Wenruo2018-06-07
| | | | | | | | | | | Original --check-data-csum option will skip the extra copy if the first copy matches csum. Since offline scrub (with recoverability report) is still out-of-tree, at least enhance --check-data-csum option to handle multiple copies. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: assign parent early in repair_extent_data_itemSu Yue2018-06-07
| | | | | | | | | | | The variable @eb is assigned to leaf in fs_tree before insertion of backref. It will cause wrong parent of new inserted backref. Set @parent at beginning to fix the problem. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: record returned errors after walk_down_tree_v2Su Yue2018-06-07
| | | | | | | | | | | | | | | | | In lowmem mode with '--repair', check_chunks_and_extents_v2 will fix accounting in block groups and clear the error bit BG_ACCOUNTING_ERROR. However, return value of check_btrfs_root() doesn't contain error bits. If extent tree is on error, lowmem repair always prints error and returns nonzero value even the filesystem is fine after repair. Introduce FATAL_ERROR for lowmem mode to represent negative return values since negative and positive can't be mixed in the bit operations. Then let check_btrfs_root() return error bits. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: release path in repair_extent_data_item()Su Yue2018-06-07
| | | | | | | | | In repair_extent_data_item(), path is not released if some errors occurs which causes extent buffer leak. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: dir-item: Make btrfs_delete_one_dir_name more robust to handle ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | | | | | | | | corrupted name len Function btrfs_delete_one_dir_name() will check if the dir_item is the last content of the item, and delete the whole item if needed. However if @name_len of one dir_item/dir_index is corrupted and larger than the item size, the function will still try to treat it as partly remove, which will screw up the whole leaf. This patch will enhance the item deletion check, to cover corrupted name len, so in that case we just delete the whole item. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: dir-item: Don't do extra filetype validation check for ↵Qu Wenruo2018-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | btrfs_match_dir_item_name verify_dir_item() is called in btrfs_match_dir_item_name() to ensure we won't search beyond item boundary and does extra filetype check. However in the following call chain, such extra filetype check can cause problems: 1) btrfs_add_link() |- check_dir_conflict() |- btrfs_lookup_dir_index() |- btrfs_match_dir_item_name() And if we have an offending dir index whose filetype is invalid, btrfs_match_dir_item_name() will return NULL, meaning no match dir index is found. So btrfs_add_link() will still try to insert a dir index, which may have same key->offset and leading to duplicated dir index. 2) btrfs_unlink() |- btrfs_lookup_dir_index() |- btrfs_lookup_dir_index() |- btrfs_match_dir_item_name() For the same offending dir index with invalid filetype, this will return NULL, and btrfs_unlink() will just consider there is no existing dir_index and do nothing. Leave an orphan and invalid dir_index hanging there forever. The patch removes the extra filetype check, as "btrfs check" can already handle invalid filetype correctly for both modes. And this makes "btrfs check --repair --mode=lowmem" to delete the offending dir index to repair it correctly. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: Remove corupted link before readding correct linkQu Wenruo2018-05-07
| | | | | | | | | | | | | | | | | | | For repair_ternary_lowmem() used in lowmem mode, if it found 1 of DIR_INDEX/DIR_ITEM/INODE_REF missing, it will try to insert correct link. However for case like invalid type in DIR_INDEX, we should delete the corrupted DIR_INDEX first before inserting the correct link. This patch will remove the corrupted link before re-inserting. This should solve the duplicated DIR_INDEX problem in old lowmem mode repair. Reported-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.16.1David Sterba2018-04-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: update CHANGES for v4.16.1David Sterba2018-04-24
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use more loose open ctree flags for dump-tree and restoreQu Wenruo2018-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | Corrupted extent tree (either the root node or leaf) can normally block us from open the fs. As normally open_ctree() has the following call chain: __open_ctree_fd() |- btrfs_setup_all_roots() |- btrfs_read_block_groups() And we will search block group items in extent tree. And considering how block group items are scattered around the whole extent tree, any error would block the fs from being mounted. Fortunately, we already have OPEN_CTREE_NO_BLOCK_GROUPS flags to disable block group items search, which will not only allow us to open some fs, but also hugely speed up open time. Currently dump-tree and btrfs-restore is ensured that they care nothing about block group items. So specify OPEN_CTREE_NO_BLOCK_GROUPS flag as default. Reported-by: Christoph Anton Mitterer <calestyo@scientia.net> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Rename OPEN_CTREE_FS_PARTIAL to OPEN_CTREE_TEMPORARY_SUPERQu Wenruo2018-04-24
| | | | | | | | | | | | | | | | | | | | | | | | The old flag OPEN_CTREE_FS_PARTIAL is in fact quite easy to be confused with OPEN_CTREE_PARTIAL, which allow btrfs-progs to open damaged filesystem (like corrupted extent/csum tree). However OPEN_CTREE_FS_PARTIAL, unlike its name, is just allowing btrfs-progs to open fs with temporary superblocks (which only has 6 basic trees on SINGLE meta/sys chunks). The usage of FS_PARTIAL is really confusing here. So rename OPEN_CTREE_FS_PARTIAL to OPEN_CTREE_TEMPORARY_SUPER, and add extra comment for its behavior. Also rename BTRFS_MAGIC_PARTIAL to BTRFS_MAGIC_TEMPORARY to keep the naming consistent. And with above comment, the usage of FS_PARTIAL in dump-tree is obviously incorrect, fix it. Fixes: 8698a2b9ba89 ("btrfs-progs: Allow inspect dump-tree to show specified tree block even some tree roots are corrupted") Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: build btrfs.static needs libbtrfsutil to buildBaruch Siach2018-04-24
| | | | | | | | | | | | | | | | Add libbtrfsutil objects to btrfs.static link command. This fixes static build failure: utils.static.o: In function `parse_qgroupid': utils.c:(.text.parse_qgroupid+0xb0): undefined reference to `btrfs_util_is_subvolume' props.static.o: In function `prop_read_only': props.c:(.text.prop_read_only+0x70): undefined reference to `btrfs_util_set_subvolume_read_only' ... Makefile:457: recipe for target 'btrfs.static' failed make[1]: *** [btrfs.static] Error 1 Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: configure: check if xmlto exists at configure timeMisono Tomohiro2018-04-24
| | | | | | | | | | AC_PATH_PROG won't fail even if it fails to find command path. xmlto is required for document build and we should report error if it doesn't exist at configure time. Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: reorder extent buffer members for better packingDavid Sterba2018-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Afther the fs_info was added, the size was over 128 bytes but we still have 8 bytes of holes, so with minor reordering we get back to that size. Before: struct extent_buffer { struct cache_extent cache_node; /* 0 48 */ u64 start; /* 48 8 */ u64 dev_bytenr; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ u32 len; /* 64 4 */ /* XXX 4 bytes hole, try to pack */ struct extent_io_tree * tree; /* 72 8 */ struct list_head lru; /* 80 16 */ struct list_head recow; /* 96 16 */ int refs; /* 112 4 */ u32 flags; /* 116 4 */ int fd; /* 120 4 */ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 2 boundary (128 bytes) --- */ struct btrfs_fs_info * fs_info; /* 128 8 */ char data[0]; /* 136 0 */ /* size: 136, cachelines: 3, members: 12 */ /* sum members: 128, holes: 2, sum holes: 8 */ /* last cacheline: 8 bytes */ }; After: struct extent_buffer { struct cache_extent cache_node; /* 0 48 */ u64 start; /* 48 8 */ u64 dev_bytenr; /* 56 8 */ /* --- cacheline 1 boundary (64 bytes) --- */ struct extent_io_tree * tree; /* 64 8 */ struct list_head lru; /* 72 16 */ struct list_head recow; /* 88 16 */ u32 len; /* 104 4 */ int refs; /* 108 4 */ u32 flags; /* 112 4 */ int fd; /* 116 4 */ struct btrfs_fs_info * fs_info; /* 120 8 */ /* --- cacheline 2 boundary (128 bytes) --- */ char data[0]; /* 128 0 */ /* size: 128, cachelines: 2, members: 12 */ }; Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: print-tree: Remove btrfs_root parameterQu Wenruo2018-04-24
| | | | | | | | | | | | Just like kernel cleanup made by David, btrfs_print_leaf() and btrfs_print_tree() doesn't need btrfs_root parameter at all. With previous patches as preparation, now we can remove the btrfs_root parameter. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>