summaryrefslogtreecommitdiff
path: root/backref.c
Commit message (Collapse)AuthorAge
* btrfs-progs: backref: Allow backref walk to handle direct parent refQu Wenruo2018-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [BUG] Btrfs lowmem mode fails with the following ASSERT() on certain valid image. ------ backref.c:466: __add_missing_keys: Assertion `ref->root_id` failed, value 0 ------ [REASON] Lowmem mode uses btrfs_find_all_roots() when walking down fs trees. However if a tree block with only shared parent backref like below, backref code from btrfs-progs doesn't handle it correct. ------ item 72 key (604653731840 METADATA_ITEM 0) itemoff 13379 itemsize 60 refs 4 gen 7198 flags TREE_BLOCK|FULL_BACKREF tree block skinny level 0 shared block backref parent 604498477056 shared block backref parent 604498460672 shared block backref parent 604498444288 shared block backref parent 604498411520 ------ Such shared block ref is *direct* ref, which means we don't need to solve its key, nor its rootid. As the objective of backref walk is to find all direct parents until it reaches tree root. So for such direct ref, it should be pended to pref_stat->pending, other than pending it to pref_stat->pending_missing_key. [FIX] For direct ref, pending it to pref_state->pending directly to solve the problem. Reported-by: Chris Murphy <chris@colorremedies.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: backref: use separate list for indirect refsJeff Mahoney2017-10-06
| | | | | | | | | | | | | | Rather than iterate over all outstanding backrefs to resolve indirect refs, use a separate list that only contains indirect refs. When we process missing keys, the ref moves to the indirect ref list. Once the indirect ref is resolved, move the ref to the pending list. Eventually these lists will be replaced by rbtrees. Signed-off-by: Jeff Mahoney <jeffm@suse.com> [ added assertion fix from Josef ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: backref: use separate list for missing keysJeff Mahoney2017-10-06
| | | | | | | | | | Rather than iterate over all outstanding backrefs to resolve missing keys, use a separate list that only contains refs that need missing keys resolved. Once the missing key is resolved, move the ref to the pending list. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: backref: add list_first_pref helperJeff Mahoney2017-10-06
| | | | | Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: backref: push state tracking into a helper structureJeff Mahoney2017-10-06
| | | | | | | Eventually, we'll have several lists and trees, as well as some statistics. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop blocksize from read_tree_blockDavid Sterba2017-09-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop local blocksize variables if they're nodesizeDavid Sterba2017-09-08
| | | | | | Prep work so we can drop the blocksize argument from several functions. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor read_tree_block to get rid of btrfs_rootQu Wenruo2017-07-03
| | | | | | | | | | | | | The only reasom read_tree_block() needs a btrfs_root parameter is to get its node/sector size. And long ago, I have already introduced a compactible interface, read_tree_block_fs_info() to pass btrfs_fs_info instead of btrfs_root. Since we have cleaned up all root->sector/node/stripesize users, we should be OK to refactor read_tree_block() function. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Refactor block sizes users in backref.cQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: move ulist.[ch] to kernel-sharedDavid Sterba2017-03-08
| | | | | | | The implementation of ulist_* is same for kernel and userspace, without dependencies, so we can keep it separately for code sync. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: make incompat bit wrappers more compactDavid Sterba2016-12-14
| | | | | | Use the same macro tricks as in kernel code. 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: typo review of strings and commentsNicholas D Steeves2016-06-01
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: deprecate and stop using btrfs_level_sizeDavid Sterba2016-05-02
| | | | | | Size of a b-tree node is always nodesize, regardless of the level. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: replace leafsize with nodesizeDavid Sterba2016-05-02
| | | | | | | | Nodesize is used in kernel, the values are always equal. We have to keep leafsize in headers, similarly the tree setting functions still take and set leafsize, but it's effectively a no-op. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: libbtrfs: remove max/min macros from APIOndrej Kozina2016-03-14
| | | | | | | | | kerncompat.h header file is part of libbtrfs API. min/max macros cause conflict while building projects dependant on libbtrfs. Moving those macros to btrfs-progs internal header file fixes the conflict. Signed-off-by: Ondrej Kozina <okozina@redhat.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mute coverity warnings about deadcodeEryu Guan2015-11-02
| | | | | | | | Coverity reports execution cannot reach this statements. So put WARN_ON in if-else conditions. Signed-off-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: read_tree_block() and read_node_slot() cleanup.Qu Wenruo2015-02-02
| | | | | | | | | | | | Allow read_tree_block() and read_node_slot() to return error pointer. This should help caller to get more specified error number. For existing callers, change (!eb) judgmentt to (!extent_buffer_uptodate(eb)) to keep the compatibility, and for caller missing the check, use PTR_ERR(eb) if possible. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: pull back backref.c and fix it upJosef Bacik2014-10-14
This patch pulls back backref.c, adds a couple of helpers everywhere that it needs, and cleans up backref.c to fit in btrfs-progs. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> [removed free_some_buffers after "do not reclaim extent buffer"] Signed-off-by: David Sterba <dsterba@suse.cz>