summaryrefslogtreecommitdiff
path: root/check
Commit message (Collapse)AuthorAge
* 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: 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: 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: Unify btrfs_leaf_free_space() parameter with kernelQu Wenruo2018-04-24
| | | | | | | | | | Instead of struct btrfs_root, use struct btrfs_fs_info, since nodesize is now a per-fs setting, and with the need to pass a @root, caller don't need to wonder which root should be passed. 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>
* btrfs-progs: check: Skip data csum verification for metadata dumpQu Wenruo2018-04-24
| | | | | | | | | | | | For metadata dump (fs restored by btrfs-image), no data is restored and check sum verification will definitely report error. Add such check in check_csums() and prompt for user input. Issue: #103 Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check/original: Remove unused variable first_keyQu Wenruo2018-03-30
| | | | | | | | | | | | | | This @first_key variable is introduced in f5c4c4f3b75b ("btrfsck: add code to rebuild extent records"), however it's not only unused, but also used incorrectly. It's calling btrfs_item_key_to_cpu() on an node extent buffer. Anyway, just remove it. Fixes: f5c4c4f3b75b ("btrfsck: add code to rebuild extent records") Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check/lowmem mode: Check inline extent sizeQu Wenruo2018-03-30
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: original mode: Check inline extent sizeQu Wenruo2018-03-30
| | | | | | | | | | | | | | | For inline compressed file extent, kernel doesn't allow inline extent ram size larger than sector size and on-disk inline extent size should not exceed BTRFS_MAX_INLINE_DATA_SIZE(). For inline uncompressed file extent, kernel doesn't allow inline extent ram and on-disk size larger than either BTRFS_MAX_INLINE_DATA_SIZE() or sector size. Check it in original mode. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: check, fix false error reports for shared prealloc extentsFilipe Manana2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under some cases the filesystem checker reports an error when it finds checksum items for an extent that is referenced by an inode as a prealloc extent. Such cases are not an error when the extent is actually shared (was cloned/reflinked) with other inodes and was written through one of those other inodes. Example: $ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt $ touch /mnt/foo $ xfs_io -c "falloc 0 256K" /mnt/foo $ sync $ xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo $ touch /mnt/bar $ xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar $ xfs_io -c "fsync" /mnt/bar <power fail> $ mount /dev/sdb /mnt $ umount /mnt $ btrfs check /dev/sdc Checking filesystem on /dev/sdb UUID: 52d3006e-ee3b-40eb-aa21-e56253a03d39 checking extents checking free space cache checking fs roots root 5 inode 257 errors 800, odd csum item ERROR: errors found in fs roots found 688128 bytes used, error(s) found total csum bytes: 256 total tree bytes: 163840 total fs tree bytes: 65536 total extent tree bytes: 16384 btree space waste bytes: 138819 file data blocks allocated: 10747904 referenced 10747904 $ echo $? 1 So teach check to not report such cases as errors by checking if the extent is shared with other inodes and if so, consider it an error the existence of checksum items only if all those other inodes are referencing the extent as a prealloc extent. This case can be hit often when running the generic/475 testcase from fstests. A test case will follow in a separate patch. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: lowmem: Fix false alert about orphan inodeQu Wenruo2018-03-30
| | | | | | | | | | | | | | | | | | | | Btrfs can delay inode deletion and in that case btrfs will unlink the victim inode from its parent dir, and insert a marker to info btrfs to delete it later. In that case, such victim inode will have nlinks == 0, but is still completely valid. Original mode won't report such problem, but lowmem mode doesn't check the ORPHAN_ITEM key for such inode, and can report false alert like: ------ ERROR: root 257 INODE[28891726] is orphan item ------ Fix such false alert by checking orphan item for inode whose nlink is 0. Signed-off-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: check/lowmem: Fix false alert of data extent backref lost for ↵Lu Fengqi2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | snapshot Btrfs lowmem check reports the following false alert: ------ ERROR: file extent[267 2162688] root 256 owner 5 backref lost ------ The file extent is in the leaf which is shared by file tree 256 and fs tree. ------ leaf 30605312 items 46 free space 4353 generation 7 owner 5 ...... item 45 key (267 EXTENT_DATA 2162688) itemoff 5503 itemsize 53 generation 7 type 2 (prealloc) prealloc data disk byte 13631488 nr 65536 prealloc data offset 32768 nr 32768 ------ And there is the corresponding extent_data_ref item in the extent tree. ------ item 1 key (13631488 EXTENT_DATA_REF 1007496934287921081) itemoff 15274 itemsize 28 extent data backref root 5 objectid 267 offset 2129920 count 1 ------ The offset of EXTENT_DATA_REF which is the hash of the owner root objectid, the inode number and the calculated offset (file offset - extent offset). What caused the false alert is the code mix up the owner root objectid and the file tree objectid. Fixes: b0d360b541f0 ("btrfs-progs: check: introduce function to check data backref in extent tree") 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: check/lowmem: Fix the incorrect error message of ↵Lu Fengqi2018-03-30
| | | | | | | | | | | | | check_extent_data_item Instead of the disk_bytenr and disk_num_bytes of the extent_item which the file extent references, we should output the objectid and offset of the file extent. And the leaf may be shared by the file trees, we should print the objectid of the root and the owner of the leaf. Fixes: b0d360b541f0 ("btrfs-progs: check: introduce function to check data backref in extent tree") Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: free-space-cache: Enhance free space cache free space checkQu Wenruo2018-03-30
| | | | | | | | | | | | | | | | | | | | | | | When we found free space difference between free space cache and block group item, we just discard this free space cache. Normally such difference is caused by btrfs_reserve_extent() called by delalloc which is out of a transaction. And since all btrfs_release_extent() is called with a transaction, under heavy race free space cache can have less free space than block group item. Normally kernel will detect such difference and just discard that cache. However we must be more careful if free space cache has more free space cache, and if that happens, paried with above race one invalid free space cache can be loaded into kernel. So if we find any free space cache who has more free space then block group item, we report it as an error other than ignoring it. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Move chunk stripe size calculation function to volumes.hQu Wenruo2018-03-06
| | | | | Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: btrfs-progs: Fix read beyond boundary bug in ↵Qu Wenruo2018-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | build_roots_info_cache() This bug is exposed by fsck-test with D=asan, hit by test case 020, with the following error report: ================================================================= ==10740==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x621000061580 at pc 0x56051f0db6cd bp 0x7ffe170f3e20 sp 0x7ffe170f3e10 READ of size 1 at 0x621000061580 thread T0 #0 0x56051f0db6cc in btrfs_extent_inline_ref_type /home/adam/btrfs/btrfs-progs/ctree.h:1727 #1 0x56051f13b669 in build_roots_info_cache /home/adam/btrfs/btrfs-progs/cmds-check.c:14306 #2 0x56051f13c86a in repair_root_items /home/adam/btrfs/btrfs-progs/cmds-check.c:14450 #3 0x56051f13ea89 in cmd_check /home/adam/btrfs/btrfs-progs/cmds-check.c:14965 #4 0x56051efe75bb in main /home/adam/btrfs/btrfs-progs/btrfs.c:302 #5 0x7f04ddbb0f49 in __libc_start_main (/usr/lib/libc.so.6+0x20f49) #6 0x56051efe68c9 in _start (/home/adam/btrfs/btrfs-progs/btrfs+0x5b8c9) 0x621000061580 is located 0 bytes to the right of 4224-byte region [0x621000060500,0x621000061580) allocated by thread T0 here: #0 0x7f04ded50ce1 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:70 #1 0x56051f04685e in __alloc_extent_buffer /home/adam/btrfs/btrfs-progs/extent_io.c:553 #2 0x56051f047563 in alloc_extent_buffer /home/adam/btrfs/btrfs-progs/extent_io.c:687 #3 0x56051efff1d1 in btrfs_find_create_tree_block /home/adam/btrfs/btrfs-progs/disk-io.c:187 #4 0x56051f000133 in read_tree_block /home/adam/btrfs/btrfs-progs/disk-io.c:327 #5 0x56051efeddb8 in read_node_slot /home/adam/btrfs/btrfs-progs/ctree.c:652 #6 0x56051effb0d9 in btrfs_next_leaf /home/adam/btrfs/btrfs-progs/ctree.c:2853 #7 0x56051f13b343 in build_roots_info_cache /home/adam/btrfs/btrfs-progs/cmds-check.c:14267 #8 0x56051f13c86a in repair_root_items /home/adam/btrfs/btrfs-progs/cmds-check.c:14450 #9 0x56051f13ea89 in cmd_check /home/adam/btrfs/btrfs-progs/cmds-check.c:14965 #10 0x56051efe75bb in main /home/adam/btrfs/btrfs-progs/btrfs.c:302 #11 0x7f04ddbb0f49 in __libc_start_main (/usr/lib/libc.so.6+0x20f49) It's completely possible that one extent/metadata item has no inline reference, while build_roots_info_cache() doesn't have such check. Fix it by checking @iref against item end to avoid such problem. Issue: #92 Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: rename files after moving codeDavid Sterba2018-02-02
| | | | | | Add prefixes to the files so it's clear they belong to the mode group. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Cleanup all checkpatch error and warningQu Wenruo2018-02-02
| | | | | | | | | | | | | | | | | | | | | Since we're moving tons of code, it's a good idea to fix all errors and warnings from checkpatch. Note: we don't rely on checkpatch, take its warnings and errors as a hint and do not blindly fix anything that gets reported. The code follows some style that should be kept and is not in 100% with what checkpatch finds. Always apply your common sense and decide if the change makes sense or if it is really making the code better. Additional fixes from dsterba: - %Lu -> %llu - lowercase first word or messages Signed-off-by: Qu Wenruo <wqu@suse.com> [ added note ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check/lowmem: Cleanup unnecessary _v2 suffixesQu Wenruo2018-02-02
| | | | | | | | | | | | | There used to be some functions with _v2 suffix to distinguish them from original mode that had similar functions. However now when the lowmem mode is moved to own check/lowmem.[ch], cleanup the _v2 suffixes, and for functions that really need to be distinguished from original mode (exported functions), change the _v2 suffix to _lowmem. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move lowmem check code to its own check/lowmem.[ch]Qu Wenruo2018-02-02
| | | | | | | | | | | | | Since lowmem mode code is highly internally connected, it's pretty hard to move them piece by piece. In theory it's possible to move part of the functions and temporarily export them, but it will just cause extra temporarily modifications. So this patch moves the whole lowmem check part into its own check/lowmem.[ch]. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move reset_cached_block_groups to check/common.cQu Wenruo2018-02-02
| | | | | | Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move check_child_node to check/common.cQu Wenruo2018-02-02
| | | | | | Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: move reada_walk_down to check/common.cQu Wenruo2018-02-02
| | | | | | | | Both original and lowmem modes share this function to do readahead. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move check_dev_size_alignment to check/common.cQu Wenruo2018-02-02
| | | | | | Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move link_inode_to_lostfound function to common.cQu Wenruo2018-02-02
| | | | | | Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move __create_inode_item function to check/common.cQu Wenruo2018-02-02
| | | | | | | | | Move __create_inode_item() function to check/common.c and rename it to insert_inode_item(), with comment added. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move count_csum_range function to check/common.cQu Wenruo2018-02-02
| | | | | | | | | | | | Despite of moving it to check/common.c, also: 1) Add extra comment of the function 2) Change @root parameter to @fs_info Since @root is never used, csum_root is picked from fs_info anyway. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move fs_root_objectid function to check/common.hQu Wenruo2018-02-02
| | | | | | | | Just another small wrapper shared between original and lowmem mode. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Move imode_to_type function to check/common.hQu Wenruo2018-02-02
| | | | | | | | | This function is shared between original and lowmem mode, and it's small enough, so move it to check/common.h. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: Export check global variables to check/common.hQu Wenruo2018-02-02
| | | | | | | | | | | | | | | | There are a dozen of variables which are used as "check global" variables, like @total_csum_bytes or @no_holes. These variables are used freely across the check code, however since we're splitting check code, they need to be exported so they can be used in other files. This patch just export them and add declarations for them in check/common.h. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>