summaryrefslogtreecommitdiff
path: root/cmds-check.c
Commit message (Collapse)AuthorAge
* btrfs-progs: return best entry, if it is the first oneGoldwyn Rodrigues2016-11-23
| | | | | | | | | | | | The find_most_right_entry() tends to miss on the best entry if it is the first one on the list and there are only two entries in the list. So, we assign both prev and best to entry. To do this, the selection process (rather the rejection) has to be performed earlier to skip on broken==count. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: remove unused variable in record_extentDavid Sterba2016-11-09
| | | | | | | | In a similar code, it's used for a message. Not used in this code since the beggingin, safe to remove. Resolves-coverity-id: 1364085 Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in repair_root_itemsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in build_roots_info_cacheDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in fill_csum_tree_from_extentDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in fill_csum_tree_from_fsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in fill_csum_tree_from_one_fs_rootDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in delete_bad_itemDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in recow_extent_bufferDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in reset_balanceDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in reset_block_groupsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in fixup_extent_flagsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in fixup_extent_refsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in record_orphan_data_extentsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in delete_duplicate_recordsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in check_extent_existsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in check_extent_csumsDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in verify_space_cacheDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in try_to_fix_bad_blockDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in repair_btreeDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in try_repair_inodeDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in find_normal_file_extentDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in delete_dir_indexDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: use on-stack path buffer in add_missing_dir_indexDavid Sterba2016-11-09
| | | | | | | We don't need to conserve stack space too much unlike kernel, also remove one error condition. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: reorder fields in inode_backref for better packingDavid Sterba2016-11-09
| | | | | | | The structure size went from 56 bytes to 48, which could save some bytes in larger scale. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: unify type for inode_backref::itemtypeDavid Sterba2016-11-09
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: unify type for inode_backref::filetypeDavid Sterba2016-11-09
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: add support to clear v1 free space cacheQu Wenruo2016-11-09
| | | | | | | | | | | | | | | | Kernel clear_cache mount option will only rebuild free space cache if the used space of that chunk has changed. So it won't ensure any corrupted free space cache get cleared. So add a new option "--clear-space-cache v1|v2" to btrfsck, to completely wipe out free space cache. So kernel won't complain again. Reported-by: Ivan P <chrnosphered@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ adjusted error messages, doc wording changes ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: release path after usageGoldwyn Rodrigues2016-10-25
| | | | | | | | While performing an fsck, an assertion failure occurs because of reusing path in a loop. ctree.c:1112: btrfs_search_slot: Warning: assertion `p->nodes[0] != NULL` failed, value 0 Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Fix wrong tree block alignment for unalianged block groupQu Wenruo2016-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 854437ca(btrfs-progs: extent-tree: avoid allocating tree block that crosses stripe boundary) introduces check for logical bytenr not crossing stripe boundary. However that check is not completely correct. It only checks if the logical bytenr and length agaist absolute logical offset. That's to say, it only check if a tree block lies in 64K logical stripe. But in fact, it's possible a block group starts at bytenr unaligned with 64K, just like the following case. Then btrfsck will give false alert. 0 32K 64K 96K 128K 160K ... |--------------- Block group A --------------------- |<-----TB 32K------>| |/Scrub stripe unit/| | WRONG UNIT | In that case, TB(tree block) at bytenr 32K in fact fits into the kernel scrub stripe unit. But doesn't fit into the pure logical 64K stripe. Fix check_crossing_stripes() to compare bytenr to block group start, not to absolute logical bytenr. Reported-by: Jussi Kansanen <jussi.kansanen@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix user-facing typos in docs and help stringsNicholas D Steeves2016-10-03
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: change btrfs_csum_final result param type to u8Domagoj Tršan2016-10-03
| | | | | Signed-off-by: Domagoj Tršan <domagoj.trsan@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, kill trivial btrfs_key_type helperDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cleanup, kill trivial btrfs_set_key_type helperDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: improve error handling in clone_inode_recDavid Sterba2016-10-03
| | | | | | Cleanup the rb_tree. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: switch some messages to common helpersDavid Sterba2016-10-03
| | | | | | | Switch the messages that do not come from the actual image checking, more like the parameter verification. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: improve error handling in add_extent_rec_nolookupDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: handle errors returned by add_extent_rec_nolookupDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use standard allocation functions in non-kenrel codeDavid Sterba2016-10-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: improved error handling in calc_extent_flagDavid Sterba2016-09-21
| | | | | | All callers handle errors. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: make low memory mode support partially dropped snapshotsWang Xiaoguang2016-09-21
| | | | | Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Revert "btrfs-progs: check: supplement extent backref list with rbtree"David Sterba2016-09-05
| | | | | | | | | | | | | | | | This reverts commit 31d8235410985e0b64487354c9ba67d40c4bdfe3. False report of backref mismatches, lots of messages similar to: Incorrect local backref count on 12713984 root 5 owner 257 offset 12845056 found 1 wanted 0 back 0x7b3ed0 backpointer mismatch on [12713984 131072] Repairing will make things worse. A fix has been proposed, but is not finalized so we go with a revert. Reported-by: Chris Murphy <bugzilla@colorremedies.com> References: https://bugzilla.kernel.org/show_bug.cgi?id=155791 Signed-off-by: David Sterba <dsterba@suse.com>
* Revert "btrfs-progs: check: switch to iterating over the backref_tree"David Sterba2016-09-05
| | | | This reverts commit bbebe814c0e335745cfa773df966418e754b50e3.
* btrfs-progs: fsck: Avoid abort and BUG_ON in add_tree_backrefQu Wenruo2016-09-05
| | | | | | | | | | | | Add_tree_backref() can cause BUG_ON() and abort() in quite a lot of cases, from the ENOMEM to existing tree backref records. Change all these BUG_ON() and abort() to return proper values. And modify all callers to handle such problems. Reported-by: Lukas Lueg <lukas.lueg@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck: Check bytenr alignment for extent itemQu Wenruo2016-09-05
| | | | | | | Check bytenr alignment for extent item to filter invalid items early. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fsck: Check drop level before walking through fs treeQu Wenruo2016-09-05
| | | | | | | | | | | | Exposed by fuzzed image from Lukas, which contains invalid drop level (16), causing segfault when accessing path->nodes[drop_level]. This patch will check drop level against fs tree level and BTRFS_MAX_LEVEL to avoid such problem. Reported-by: Lukas Lueg <lukas.lueg@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Do extra chunk check before processing chunk itemQu Wenruo2016-09-05
| | | | | | | | | | | | | | | | | | | Current we only do chunk validation check at mount time. It's good for most case, but for fuzzed or manually crafted images, we can insert a CHUNK_ITEM key into root tree. Since mount time check will only check chunk tree, it will not check CHUNK_ITEM in root tree. Even with previous key type check against leaf owner, it is still possible to modify the leaf owner to by-pass it. So we still need to check chunk validation before processing it. Reported-by: Lukas Lueg <lukas.lueg@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: ignore invalid key in invalid rootQu Wenruo2016-09-05
| | | | | | | | | | | | | Btrfs tree implies a lot of restriction on which key types are allowed in specific roots. Like CHUNK_ITEM keys are only valid in chunk root. This patch will add such check at run_next_block() for original mode. Reported-by: Lukas Lueg <lukas.lueg@gmail.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: pass OPEN_CTREE flags as unsignedDavid Sterba2016-08-24
| | | | | | | As we're passing a set of flags, the enum type is not appropriate. Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: adjust command line options for the low-memory modeDavid Sterba2016-08-17
| | | | | | | | Change the single-purpose option --low-memory to a generic option that takes the mode. Currently supported are the original mode and the low-memory in the same way. Signed-off-by: David Sterba <dsterba@suse.com>