Btrfs: don't assume to be on the correct extent in add_all_parents
authorAlexander Block <ablock84@googlemail.com>
Tue, 19 Jun 2012 13:42:26 +0000 (07:42 -0600)
committerChris Mason <chris.mason@fusionio.com>
Thu, 21 Jun 2012 11:19:34 +0000 (07:19 -0400)
commit69bca40d41c613927b150c5392505f1894fe3010
tree924b5d5f914a254f4348fc6b20e0e1e2e131a53c
parent1c8f52a5e9539600543347bcdefafa1854e07986
Btrfs: don't assume to be on the correct extent in add_all_parents

add_all_parents did assume that path is already at a correct extent data
item, which may not be true in case of data extents that were partly
rewritten and splitted.

We need to check if we're on a matching extent for every item and only
for the ones after the first. The loop is changed to do this now.

This patch also fixes a bug introduced with commit 3b127fd8 "Btrfs:
remove obsolete btrfs_next_leaf call from __resolve_indirect_ref".
The removal of next_leaf did sometimes result in slot==nritems when
the above described case happens, and thus resulting in invalid values
(e.g. wanted_obejctid) in add_all_parents (leading to missed backrefs
or even crashes).

Signed-off-by: Alexander Block <ablock84@googlemail.com>
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
fs/btrfs/backref.c