Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dadcaf78 authored by Jan Schmidt's avatar Jan Schmidt
Browse files

Btrfs: bugfix in btrfs_find_parent_nodes



That one has been around since the addition of backref.c. Due to the way we
calculate our slot numbers, after adding inline refs we're missing one keyed
ref unless it's located at the beginning of a new leaf.

Reported-by: default avatarAlexander Block <ablock84@googlemail.com>
Signed-off-by: default avatarJan Schmidt <list.btrfs@jan-o-sch.net>
parent cd1b413c
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -413,7 +413,7 @@ static int __add_inline_refs(struct btrfs_fs_info *fs_info,
	 * enumerate all inline refs
	 * enumerate all inline refs
	 */
	 */
	leaf = path->nodes[0];
	leaf = path->nodes[0];
	slot = path->slots[0] - 1;
	slot = path->slots[0];


	item_size = btrfs_item_size_nr(leaf, slot);
	item_size = btrfs_item_size_nr(leaf, slot);
	BUG_ON(item_size < sizeof(*ei));
	BUG_ON(item_size < sizeof(*ei));
@@ -661,8 +661,9 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
		struct extent_buffer *leaf;
		struct extent_buffer *leaf;
		int slot;
		int slot;


		path->slots[0]--;
		leaf = path->nodes[0];
		leaf = path->nodes[0];
		slot = path->slots[0] - 1;
		slot = path->slots[0];
		btrfs_item_key_to_cpu(leaf, &key, slot);
		btrfs_item_key_to_cpu(leaf, &key, slot);
		if (key.objectid == bytenr &&
		if (key.objectid == bytenr &&
		    key.type == BTRFS_EXTENT_ITEM_KEY) {
		    key.type == BTRFS_EXTENT_ITEM_KEY) {